Commit 07df91d4 authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen

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.
parent a983bf0c
Pipeline #2051 failed with stage
in 66 minutes and 55 seconds
...@@ -882,6 +882,11 @@ This option controls whether and how to use Gnus search groups as ...@@ -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' *** 'erc-button-google-url' has been renamed to 'erc-button-search-url'
and its value has been changed to Duck Duck Go. 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 ** EUDC
*** XEmacs support has been removed. *** XEmacs support has been removed.
......
...@@ -1051,6 +1051,17 @@ Note that it's useless to set `erc-send-this' to nil and ...@@ -1051,6 +1051,17 @@ Note that it's useless to set `erc-send-this' to nil and
anyway." anyway."
:group 'erc-hooks :group 'erc-hooks
:type 'hook) :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 (defvar erc-insert-this t
"Insert the text into the target buffer or not. "Insert the text into the target buffer or not.
...@@ -1061,6 +1072,7 @@ if they wish to avoid insertion of a particular string.") ...@@ -1061,6 +1072,7 @@ if they wish to avoid insertion of a particular string.")
"Send the text to the target or not. "Send the text to the target or not.
Functions on `erc-send-pre-hook' can set this variable to nil Functions on `erc-send-pre-hook' can set this variable to nil
if they wish to avoid sending of a particular string.") 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 () (defcustom erc-insert-modify-hook ()
"Insertion hook for functions that will change the text's appearance. "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." ...@@ -5439,14 +5451,24 @@ This returns non-nil only if we actually send anything."
(beep)) (beep))
nil) nil)
(t (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) (let ((str input)
(erc-insert-this t)) (erc-insert-this t))
(setq erc-send-this t) (setq erc-send-this t)
;; The calling convention of `erc-send-pre-hook' is that it ;; 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) (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) (if (or (string-match "\n" str)
(not (string-match erc-command-regexp str))) (not (string-match erc-command-regexp str)))
(mapc (mapc
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment