diff options
| author | F. Jason Park | 2021-11-06 03:09:43 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-11-06 03:09:43 +0100 |
| commit | 4d656ea5ff7ba79315af42e159254867bfd157ad (patch) | |
| tree | 03965e6c5cd08400222cbadbbe6741459d9514df /lisp | |
| parent | 82d0550648969ce10303b67b7a8da51c4e855501 (diff) | |
| download | emacs-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.el | 21 |
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. | ||
| 2822 | When a line typed into a buffer contains an explicit command, like /msg, | ||
| 2823 | a corresponding handler (here, erc-cmd-MSG) is called. But lines typed | ||
| 2824 | into a channel or query buffer already have an implicit target and | ||
| 2825 | command (PRIVMSG). This function is called on such occasions and also | ||
| 2826 | for 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)) | |
| 2825 | See 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." |