emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 4ed6ba90e7c 6/9: Allow opting out of empty message padding in ERC


From: F. Jason Park
Subject: master 4ed6ba90e7c 6/9: Allow opting out of empty message padding in ERC
Date: Sun, 12 Nov 2023 23:56:29 -0500 (EST)

branch: master
commit 4ed6ba90e7c4d2148a7bb1d2ff1027ebc765f606
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>

    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)
---
 lisp/erc/erc.el | 15 +++++++++++----
 1 file 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
 details about the input it's handling or needs to detect whether
 it's been dispatched by `erc-send-current-line'.")
 
+(defvar erc--allow-empty-outgoing-lines-p nil
+  "Flag to opt out of last-minute padding of empty lines.
+Useful to extensions, like `multiline', and for interop with
+IRC-adjacent protocols.")
+
 (defvar-local erc-send-input-line-function #'erc-send-input-line
   "Function for sending lines lacking a leading \"slash\" command.
 When prompt input starts with a \"slash\" command, like \"/MSG\",
@@ -3697,7 +3702,7 @@ for other purposes.")
 
 (defun erc-send-input-line (target line &optional force)
   "Send LINE to TARGET."
-  (when (string= line "\n")
+  (when (and (not erc--allow-empty-outgoing-lines-p) (string= line "\n"))
     (setq line " \n"))
   (erc-message "PRIVMSG" (concat target " " line) force))
 
@@ -7033,9 +7038,11 @@ queue.  Expect LINES-OBJ to be an `erc--input-split' 
object."
               (erc--input-split-insertp lines-obj) (erc-input-insertp state)
               ;; See note in test of same name re trailing newlines.
               (erc--input-split-lines lines-obj)
-              (cl-nsubst " " "" (split-string (erc-input-string state)
-                                              erc--input-line-delim-regexp)
-                         :test #'equal))
+              (let ((lines (split-string (erc-input-string state)
+                                         erc--input-line-delim-regexp)))
+                (if erc--allow-empty-outgoing-lines-p
+                    lines
+                  (cl-nsubst " " "" lines :test #'equal))))
         (when (erc-input-refoldp state)
           (erc--split-lines lines-obj)))))
   (when (and (erc--input-split-cmdp lines-obj)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]