[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 3979f83cd60 7/7: Inhibit slash commands in erc--input-review-func
From: |
F. Jason Park |
Subject: |
master 3979f83cd60 7/7: Inhibit slash commands in erc--input-review-functions |
Date: |
Mon, 2 Oct 2023 20:38:28 -0400 (EDT) |
branch: master
commit 3979f83cd60f2d0168690883423b63ae434da929
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>
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)
---
lisp/erc/erc.el | 17 +++++++++++------
test/lisp/erc/erc-tests.el | 9 ++-------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 37502b4c743..fb236f1f189 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -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))))))
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index 2da1f7b29c1..8a68eca6196 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -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")
- master updated (ad2bb3e9f36 -> 3979f83cd60), F. Jason Park, 2023/10/02
- master a3c6ed0e364 6/7: Improve erc-warn-about-blank-lines behavior, F. Jason Park, 2023/10/02
- master 06fb8b76208 4/7: Exempt text-scale-mode from erc-scrolltobottom-all, F. Jason Park, 2023/10/02
- master 019baf28599 1/7: Remove newline from erc-fill regexp, F. Jason Park, 2023/10/02
- master 6135fec6926 3/7: ; Increase ERC test server queue size, F. Jason Park, 2023/10/02
- master 8db56235cbc 5/7: Prefer ticks/hz pairs for some ERC timestamps on 29+, F. Jason Park, 2023/10/02
- master 3979f83cd60 7/7: Inhibit slash commands in erc--input-review-functions,
F. Jason Park <=
- master ffd5d2f38d3 2/7: Fix wrong "User" column count in erc-ibuffer, F. Jason Park, 2023/10/02