aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorF. Jason Park2023-09-18 03:39:57 -0700
committerF. Jason Park2023-11-12 20:37:48 -0800
commit4ed6ba90e7c4d2148a7bb1d2ff1027ebc765f606 (patch)
tree28789729c05cad76d1cf645c7613c459736df2c0
parent174b3dd9bd78c662ce9fff78404dcfa02259d21b (diff)
downloademacs-4ed6ba90e7c4d2148a7bb1d2ff1027ebc765f606.tar.gz
emacs-4ed6ba90e7c4d2148a7bb1d2ff1027ebc765f606.zip
Allow opting out of empty message padding in ERC
* lisp/erc/erc.el (erc--allow-empty-outgoing-lines-p): New internal variable. (erc-send-input-line, erc--run-send-hooks): Don't pad output when `erc--allow-empty-outgoing-lines-p' is non-nil. (Bug#67031)
-rw-r--r--lisp/erc/erc.el15
1 files changed, 11 insertions, 4 deletions
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index c9c24f2642f..6d7251f0677 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -3684,6 +3684,11 @@ This is for special cases in which a \"slash\" command needs
3684details about the input it's handling or needs to detect whether 3684details about the input it's handling or needs to detect whether
3685it's been dispatched by `erc-send-current-line'.") 3685it's been dispatched by `erc-send-current-line'.")
3686 3686
3687(defvar erc--allow-empty-outgoing-lines-p nil
3688 "Flag to opt out of last-minute padding of empty lines.
3689Useful to extensions, like `multiline', and for interop with
3690IRC-adjacent protocols.")
3691
3687(defvar-local erc-send-input-line-function #'erc-send-input-line 3692(defvar-local erc-send-input-line-function #'erc-send-input-line
3688 "Function for sending lines lacking a leading \"slash\" command. 3693 "Function for sending lines lacking a leading \"slash\" command.
3689When prompt input starts with a \"slash\" command, like \"/MSG\", 3694When prompt input starts with a \"slash\" command, like \"/MSG\",
@@ -3697,7 +3702,7 @@ for other purposes.")
3697 3702
3698(defun erc-send-input-line (target line &optional force) 3703(defun erc-send-input-line (target line &optional force)
3699 "Send LINE to TARGET." 3704 "Send LINE to TARGET."
3700 (when (string= line "\n") 3705 (when (and (not erc--allow-empty-outgoing-lines-p) (string= line "\n"))
3701 (setq line " \n")) 3706 (setq line " \n"))
3702 (erc-message "PRIVMSG" (concat target " " line) force)) 3707 (erc-message "PRIVMSG" (concat target " " line) force))
3703 3708
@@ -7033,9 +7038,11 @@ queue. Expect LINES-OBJ to be an `erc--input-split' object."
7033 (erc--input-split-insertp lines-obj) (erc-input-insertp state) 7038 (erc--input-split-insertp lines-obj) (erc-input-insertp state)
7034 ;; See note in test of same name re trailing newlines. 7039 ;; See note in test of same name re trailing newlines.
7035 (erc--input-split-lines lines-obj) 7040 (erc--input-split-lines lines-obj)
7036 (cl-nsubst " " "" (split-string (erc-input-string state) 7041 (let ((lines (split-string (erc-input-string state)
7037 erc--input-line-delim-regexp) 7042 erc--input-line-delim-regexp)))
7038 :test #'equal)) 7043 (if erc--allow-empty-outgoing-lines-p
7044 lines
7045 (cl-nsubst " " "" lines :test #'equal))))
7039 (when (erc-input-refoldp state) 7046 (when (erc-input-refoldp state)
7040 (erc--split-lines lines-obj))))) 7047 (erc--split-lines lines-obj)))))
7041 (when (and (erc--input-split-cmdp lines-obj) 7048 (when (and (erc--input-split-cmdp lines-obj)