"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
(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)))
"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.
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
"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.
;; 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)