diff options
| author | F. Jason Park | 2023-09-18 03:39:57 -0700 |
|---|---|---|
| committer | F. Jason Park | 2023-11-12 20:37:48 -0800 |
| commit | 4ed6ba90e7c4d2148a7bb1d2ff1027ebc765f606 (patch) | |
| tree | 28789729c05cad76d1cf645c7613c459736df2c0 | |
| parent | 174b3dd9bd78c662ce9fff78404dcfa02259d21b (diff) | |
| download | emacs-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.el | 15 |
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 | |||
| 3684 | details about the input it's handling or needs to detect whether | 3684 | details about the input it's handling or needs to detect whether |
| 3685 | it's been dispatched by `erc-send-current-line'.") | 3685 | it'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. | ||
| 3689 | Useful to extensions, like `multiline', and for interop with | ||
| 3690 | IRC-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. |
| 3689 | When prompt input starts with a \"slash\" command, like \"/MSG\", | 3694 | When 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) |