emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 07df91d 2/2: Obsolete erc-send-pre-hook and add new


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master 07df91d 2/2: Obsolete erc-send-pre-hook and add new erc-pre-send-function
Date: Fri, 14 Jun 2019 08:05:38 -0400 (EDT)

branch: master
commit 07df91d45a950d7bef323b57dc7e46b34997143f
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Obsolete erc-send-pre-hook and add new erc-pre-send-function
    
    * lisp/erc/erc.el (erc-send-pre-hook): Make obsolete.
    (erc-send-input): Ditto.
    (erc-pre-send-function): New function.
    (erc-send-input): Use the new function, and silence byte
    compilation warning about the dynamic variable `str' used by the
    now-obsolete hook.
---
 etc/NEWS        |  5 +++++
 lisp/erc/erc.el | 28 +++++++++++++++++++++++++---
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 95d7e08..0439077 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -882,6 +882,11 @@ This option controls whether and how to use Gnus search 
groups as
 *** 'erc-button-google-url' has been renamed to 'erc-button-search-url'
 and its value has been changed to Duck Duck Go.
 
+---
+*** `erc-send-pre-hook' and `erc-send-this' have been obsoleted.  The
+variable to use instead to alter text to be sent is now
+`erc-pre-send-function'.
+
 ** EUDC
 
 *** XEmacs support has been removed.
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index ddfa7a3..82360a6 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -1051,6 +1051,17 @@ Note that it's useless to set `erc-send-this' to nil and
 anyway."
   :group 'erc-hooks
   :type 'hook)
+(make-obsolete-variable 'erc-send-pre-hook 'erc-pre-send-function "27.1")
+
+(defcustom erc-pre-send-function nil
+  "Function called to possibly alter the string that is sent.
+It's called with one argument, the string, and should return a
+string.
+
+To suppress the string completely, return nil."
+  :group 'erc
+  :type 'function
+  :version "27.1")
 
 (defvar erc-insert-this t
   "Insert the text into the target buffer or not.
@@ -1061,6 +1072,7 @@ if they wish to avoid insertion of a particular string.")
   "Send the text to the target or not.
 Functions on `erc-send-pre-hook' can set this variable to nil
 if they wish to avoid sending of a particular string.")
+(make-obsolete-variable 'erc-send-pre-hook 'erc-pre-send-function "27.1")
 
 (defcustom erc-insert-modify-hook ()
   "Insertion hook for functions that will change the text's appearance.
@@ -5439,14 +5451,24 @@ This returns non-nil only if we actually send anything."
       (beep))
     nil)
    (t
-    (defvar str) ;; FIXME: Make it obey the "erc-" prefix convention.
+    ;; This dynamic variable is used by `erc-send-pre-hook'.  It's
+    ;; obsolete, and when it's finally removed, this binding should
+    ;; also be removed.
+    (with-suppressed-warnings ((lexical str))
+      (defvar str))
     (let ((str input)
           (erc-insert-this t))
       (setq erc-send-this t)
       ;; The calling convention of `erc-send-pre-hook' is that it
-      ;; should change the dynamic variable `str'.
+      ;; should change the dynamic variable `str' or set
+      ;; `erc-send-this' to nil.  This has now been deprecated:
+      ;; Instead `erc-pre-send-function' is used as a filter to do
+      ;; allow both changing and suppressing the string.
       (run-hook-with-args 'erc-send-pre-hook input)
-      (when erc-send-this
+      (when erc-pre-send-function
+       (setq str (funcall erc-pre-send-function str)))
+      (when (and erc-send-this
+                str)
         (if (or (string-match "\n" str)
                 (not (string-match erc-command-regexp str)))
             (mapc



reply via email to

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