aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorF. Jason Park2021-11-06 03:09:43 +0100
committerLars Ingebrigtsen2021-11-06 03:09:43 +0100
commit4d656ea5ff7ba79315af42e159254867bfd157ad (patch)
tree03965e6c5cd08400222cbadbbe6741459d9514df /lisp
parent82d0550648969ce10303b67b7a8da51c4e855501 (diff)
downloademacs-4d656ea5ff7ba79315af42e159254867bfd157ad.tar.gz
emacs-4d656ea5ff7ba79315af42e159254867bfd157ad.zip
Don't send empty lines for implicit targets in ERC
* erc.el (erc-send-input-line): Previously, any line typed into a query or channel buffer without an explicit user-command handler (meaning most lines), would be sent twice because a trailing newline (linefeed) would be appended. This has been verified by checking IRCd server logs. IRCds won't return an error upon receiving an empty message, but they also won't forward them to channel subscribers and DM pals. * erc-tests.el: Add test for erc-process-input-line, which also indirectly tests erc-send-input-line. It also tests the command lookup and dispatch facility (bug#50008).
Diffstat (limited to 'lisp')
-rw-r--r--lisp/erc/erc.el21
1 files changed, 9 insertions, 12 deletions
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 88c105040c5..0da837012cc 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -2817,20 +2817,17 @@ present."
2817 (let ((prop-val (erc-get-parsed-vector position))) 2817 (let ((prop-val (erc-get-parsed-vector position)))
2818 (and prop-val (member (erc-response.command prop-val) list)))) 2818 (and prop-val (member (erc-response.command prop-val) list))))
2819 2819
2820(defvar-local erc-send-input-line-function 'erc-send-input-line) 2820(defvar-local erc-send-input-line-function 'erc-send-input-line
2821 "Function for sending lines lacking a leading user command.
2822When a line typed into a buffer contains an explicit command, like /msg,
2823a corresponding handler (here, erc-cmd-MSG) is called. But lines typed
2824into a channel or query buffer already have an implicit target and
2825command (PRIVMSG). This function is called on such occasions and also
2826for special purposes (see erc-dcc.el).")
2821 2827
2822(defun erc-send-input-line (target line &optional force) 2828(defun erc-send-input-line (target line &optional force)
2823 "Send LINE to TARGET. 2829 "Send LINE to TARGET."
2824 2830 (erc-message "PRIVMSG" (concat target " " line) force))
2825See also `erc-server-send'."
2826 (setq line (format "PRIVMSG %s :%s"
2827 target
2828 ;; If the line is empty, we still want to
2829 ;; send it - i.e. an empty pasted line.
2830 (if (string= line "\n")
2831 " \n"
2832 line)))
2833 (erc-server-send line force target))
2834 2831
2835(defun erc-get-arglist (fun) 2832(defun erc-get-arglist (fun)
2836 "Return the argument list of a function without the parens." 2833 "Return the argument list of a function without the parens."