[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 37a6105 1/2: Adjust erc functions after previous er
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] master 37a6105 1/2: Adjust erc functions after previous erc-pre-send-function change |
Date: |
Fri, 14 Jun 2019 08:56:39 -0400 (EDT) |
branch: master
commit 37a61055ffdfcd3b00bc9e972556e8c18262d781
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
Adjust erc functions after previous erc-pre-send-function change
* lisp/erc/erc-goodies.el (noncommands): Use
erc-pre-send-functions instead of the hook.
(erc-send-distinguish-noncommands): Adjust function to new interface.
* lisp/erc/erc-ring.el (ring): Ditto.
(erc-add-to-input-ring): Ditto.
* lisp/erc/erc.el (erc-send-this): Really make obsolete.
(erc-pre-send-functions): Change to a list of functions to allow
erc-goodies and erc-ring to work as before.
---
lisp/erc/erc-goodies.el | 15 +++++++++------
lisp/erc/erc-ring.el | 8 +++++---
lisp/erc/erc.el | 25 ++++++++++++++-----------
3 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el
index 884c594..4108382 100644
--- a/lisp/erc/erc-goodies.el
+++ b/lisp/erc/erc-goodies.el
@@ -177,18 +177,21 @@ does not appear in the ERC buffer after the user presses
ENTER.")
"This mode distinguishes non-commands.
Commands listed in `erc-insert-this' know how to display
themselves."
- ((add-hook 'erc-send-pre-hook 'erc-send-distinguish-noncommands))
- ((remove-hook 'erc-send-pre-hook 'erc-send-distinguish-noncommands)))
+ ((push 'erc-send-distinguish-noncommands erc-pre-send-functions))
+ ((setq erc-pre-send-functions (delq 'erc-send-distinguish-noncommands
+ erc-pre-send-functions))))
(defun erc-send-distinguish-noncommands (str)
"If STR is an ERC non-command, set `erc-insert-this' to nil."
(let* ((command (erc-extract-command-from-line str))
(cmd-fun (and command
(car command))))
- (when (and cmd-fun
- (not (string-match "\n.+$" str))
- (memq cmd-fun erc-noncommands-list))
- (setq erc-insert-this nil))))
+ (if (and cmd-fun
+ (not (string-match "\n.+$" str))
+ (memq cmd-fun erc-noncommands-list))
+ ;; Inhibit sending this string.
+ nil
+ str)))
;;; IRC control character processing.
(defgroup erc-control-characters nil
diff --git a/lisp/erc/erc-ring.el b/lisp/erc/erc-ring.el
index 5459d8b..2ee78f4 100644
--- a/lisp/erc/erc-ring.el
+++ b/lisp/erc/erc-ring.el
@@ -46,10 +46,11 @@
(define-erc-module ring nil
"Stores input in a ring so that previous commands and messages can
be recalled using M-p and M-n."
- ((add-hook 'erc-send-pre-hook 'erc-add-to-input-ring)
+ ((push 'erc-add-to-input-ring erc-pre-send-functions)
(define-key erc-mode-map "\M-p" 'erc-previous-command)
(define-key erc-mode-map "\M-n" 'erc-next-command))
- ((remove-hook 'erc-send-pre-hook 'erc-add-to-input-ring)
+ ((setq erc-pre-send-functions (delq 'erc-add-to-input-ring
+ erc-pre-send-functions))
(define-key erc-mode-map "\M-p" 'undefined)
(define-key erc-mode-map "\M-n" 'undefined)))
@@ -75,7 +76,8 @@ Call this function when setting up the mode."
"Add string S to the input ring and reset history position."
(unless erc-input-ring (erc-input-ring-setup))
(ring-insert erc-input-ring s)
- (setq erc-input-ring-index nil))
+ (setq erc-input-ring-index nil)
+ s)
(defun erc-clear-input-ring ()
"Remove all entries from the input ring, then call garbage-collect.
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 82360a6..0165f2c 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -1051,16 +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")
+(make-obsolete-variable 'erc-send-pre-hook 'erc-pre-send-functions "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.
+(defcustom erc-pre-send-functions nil
+ "List of functions called to possibly alter the string that is sent.
+The functions are called with one argument, the string, and
+should return a string.
-To suppress the string completely, return nil."
+To suppress the string completely, one of the functions should
+return nil."
:group 'erc
- :type 'function
+ :type '(repeat function)
:version "27.1")
(defvar erc-insert-this t
@@ -1072,7 +1073,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")
+(make-obsolete-variable 'erc-insert-this 'erc-pre-send-functions "27.1")
(defcustom erc-insert-modify-hook ()
"Insertion hook for functions that will change the text's appearance.
@@ -5462,11 +5463,13 @@ This returns non-nil only if we actually send anything."
;; The calling convention of `erc-send-pre-hook' is that it
;; 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
+ ;; Instead `erc-pre-send-functions' 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-pre-send-function
- (setq str (funcall erc-pre-send-function str)))
+ (dolist (func erc-pre-send-functions)
+ ;; The functions can return nil to inhibit sending.
+ (when str
+ (setq str (funcall func str))))
(when (and erc-send-this
str)
(if (or (string-match "\n" str)