Inhibit slash commands in erc--input-review-functions
* lisp/erc/erc.el (erc--input-review-functions): Add new review function `erc--inhibit-slash-cmd-insertion'. (erc--check-prompt-input-functions): Move `erc--check-prompt-input-for-multiline-command' above `erc--check-prompt-input-for-multiline-blanks'. (erc--inhibit-slash-cmd-insertion): New "review" function to suppress insertion of prompt input for slash commands. Doesn't affect "meta" slash commands like /SAY. (erc--send-input-lines): Don't bother checking whether message is a command. Instead, trust verdict handed down by message-prep and review functions. This opens the door to optional insertion for debugging purposes or when echoing command lines in a shell-like fashion. * test/lisp/erc/erc-tests.el (erc-send-whitespace-lines): clean up portion dealing with trimming slash commands. (Bug#66073)
This commit is contained in:
parent
a3c6ed0e36
commit
3979f83cd6
2 changed files with 13 additions and 13 deletions
|
@ -1104,7 +1104,8 @@ subprotocols should probably be handled manually."
|
|||
'erc--input-review-functions "30.1")
|
||||
(defvar erc--input-review-functions '(erc--split-lines
|
||||
erc--run-input-validation-checks
|
||||
erc--discard-trailing-multiline-nulls)
|
||||
erc--discard-trailing-multiline-nulls
|
||||
erc--inhibit-slash-cmd-insertion)
|
||||
"Special hook for reviewing and modifying prompt input.
|
||||
ERC runs this before clearing the prompt and before running any
|
||||
send-related hooks, such as `erc-pre-send-functions'. Thus, it's
|
||||
|
@ -6543,10 +6544,10 @@ a separate message."
|
|||
(defvar erc--check-prompt-input-functions
|
||||
'(erc--check-prompt-input-for-point-in-bounds
|
||||
erc--check-prompt-input-for-something
|
||||
erc--check-prompt-input-for-multiline-command
|
||||
erc--check-prompt-input-for-multiline-blanks
|
||||
erc--check-prompt-input-for-running-process
|
||||
erc--check-prompt-input-for-excess-lines
|
||||
erc--check-prompt-input-for-multiline-command)
|
||||
erc--check-prompt-input-for-excess-lines)
|
||||
"Validators for user input typed at prompt.
|
||||
Called with two arguments: the current input submitted by the
|
||||
user, as a string, along with the same input as a list of
|
||||
|
@ -6571,6 +6572,11 @@ ERC prints them as a single message joined by newlines.")
|
|||
(message "%s" (string-join (nreverse erc--check-prompt-explanation)
|
||||
"\n"))))))
|
||||
|
||||
(defun erc--inhibit-slash-cmd-insertion (state)
|
||||
"Don't insert STATE object's message if it's a \"slash\" command."
|
||||
(when (erc--input-split-cmdp state)
|
||||
(setf (erc--input-split-insertp state) nil)))
|
||||
|
||||
(defun erc-send-current-line ()
|
||||
"Parse current line and send it to IRC."
|
||||
(interactive)
|
||||
|
@ -6679,9 +6685,8 @@ queue. Expect LINES-OBJ to be an `erc--input-split' object."
|
|||
"Send lines in `erc--input-split-lines' object LINES-OBJ."
|
||||
(when (erc--input-split-sendp lines-obj)
|
||||
(dolist (line (erc--input-split-lines lines-obj))
|
||||
(unless (erc--input-split-cmdp lines-obj)
|
||||
(when (erc--input-split-insertp lines-obj)
|
||||
(erc-display-msg line)))
|
||||
(when (erc--input-split-insertp lines-obj)
|
||||
(erc-display-msg line))
|
||||
(erc-process-input-line (concat line "\n")
|
||||
(null erc-flood-protect)
|
||||
(not (erc--input-split-cmdp lines-obj))))))
|
||||
|
|
|
@ -1316,17 +1316,12 @@
|
|||
(should-not (funcall next)))
|
||||
|
||||
(ert-info ("Multiline command with trailing blank filtered")
|
||||
(pcase-dolist (`(,p . ,q)
|
||||
'(("/a b\r" "/a b\n") ("/a b\n" "/a b\n")
|
||||
("/a b\n\n" "/a b\n") ("/a b\r\n" "/a b\n")
|
||||
("/a b\n\n\n" "/a b\n")))
|
||||
(dolist (p '("/a b" "/a b\n" "/a b\n\n" "/a b\n\n\n"))
|
||||
(insert p)
|
||||
(erc-send-current-line)
|
||||
(erc-bol)
|
||||
(should (eq (point) (point-max)))
|
||||
(while q
|
||||
(should (pcase (funcall next)
|
||||
(`(,cmd ,_ nil) (equal cmd (pop q))))))
|
||||
(should (pcase (funcall next) (`(,cmd ,_ nil) (equal cmd "/a b\n"))))
|
||||
(should-not (funcall next))))
|
||||
|
||||
(ert-info ("Multiline command with non-blanks errors")
|
||||
|
|
Loading…
Add table
Reference in a new issue