diff options
| author | Lars Ingebrigtsen | 2019-06-14 14:05:24 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-06-14 14:05:30 +0200 |
| commit | 07df91d45a950d7bef323b57dc7e46b34997143f (patch) | |
| tree | ae54e3513cc8ce7537c41f3dd83983b6890acd3d /lisp/erc | |
| parent | a983bf0c4997c59f813e90be17537548909a1052 (diff) | |
| download | emacs-07df91d45a950d7bef323b57dc7e46b34997143f.tar.gz emacs-07df91d45a950d7bef323b57dc7e46b34997143f.zip | |
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.
Diffstat (limited to 'lisp/erc')
| -rw-r--r-- | lisp/erc/erc.el | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index ddfa7a3e15c..82360a66f98 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 | |||
| 1051 | anyway." | 1051 | anyway." |
| 1052 | :group 'erc-hooks | 1052 | :group 'erc-hooks |
| 1053 | :type 'hook) | 1053 | :type 'hook) |
| 1054 | (make-obsolete-variable 'erc-send-pre-hook 'erc-pre-send-function "27.1") | ||
| 1055 | |||
| 1056 | (defcustom erc-pre-send-function nil | ||
| 1057 | "Function called to possibly alter the string that is sent. | ||
| 1058 | It's called with one argument, the string, and should return a | ||
| 1059 | string. | ||
| 1060 | |||
| 1061 | To suppress the string completely, return nil." | ||
| 1062 | :group 'erc | ||
| 1063 | :type 'function | ||
| 1064 | :version "27.1") | ||
| 1054 | 1065 | ||
| 1055 | (defvar erc-insert-this t | 1066 | (defvar erc-insert-this t |
| 1056 | "Insert the text into the target buffer or not. | 1067 | "Insert the text into the target buffer or not. |
| @@ -1061,6 +1072,7 @@ if they wish to avoid insertion of a particular string.") | |||
| 1061 | "Send the text to the target or not. | 1072 | "Send the text to the target or not. |
| 1062 | Functions on `erc-send-pre-hook' can set this variable to nil | 1073 | Functions on `erc-send-pre-hook' can set this variable to nil |
| 1063 | if they wish to avoid sending of a particular string.") | 1074 | if they wish to avoid sending of a particular string.") |
| 1075 | (make-obsolete-variable 'erc-send-pre-hook 'erc-pre-send-function "27.1") | ||
| 1064 | 1076 | ||
| 1065 | (defcustom erc-insert-modify-hook () | 1077 | (defcustom erc-insert-modify-hook () |
| 1066 | "Insertion hook for functions that will change the text's appearance. | 1078 | "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 | (beep)) | 5451 | (beep)) |
| 5440 | nil) | 5452 | nil) |
| 5441 | (t | 5453 | (t |
| 5442 | (defvar str) ;; FIXME: Make it obey the "erc-" prefix convention. | 5454 | ;; This dynamic variable is used by `erc-send-pre-hook'. It's |
| 5455 | ;; obsolete, and when it's finally removed, this binding should | ||
| 5456 | ;; also be removed. | ||
| 5457 | (with-suppressed-warnings ((lexical str)) | ||
| 5458 | (defvar str)) | ||
| 5443 | (let ((str input) | 5459 | (let ((str input) |
| 5444 | (erc-insert-this t)) | 5460 | (erc-insert-this t)) |
| 5445 | (setq erc-send-this t) | 5461 | (setq erc-send-this t) |
| 5446 | ;; The calling convention of `erc-send-pre-hook' is that it | 5462 | ;; The calling convention of `erc-send-pre-hook' is that it |
| 5447 | ;; should change the dynamic variable `str'. | 5463 | ;; should change the dynamic variable `str' or set |
| 5464 | ;; `erc-send-this' to nil. This has now been deprecated: | ||
| 5465 | ;; Instead `erc-pre-send-function' is used as a filter to do | ||
| 5466 | ;; allow both changing and suppressing the string. | ||
| 5448 | (run-hook-with-args 'erc-send-pre-hook input) | 5467 | (run-hook-with-args 'erc-send-pre-hook input) |
| 5449 | (when erc-send-this | 5468 | (when erc-pre-send-function |
| 5469 | (setq str (funcall erc-pre-send-function str))) | ||
| 5470 | (when (and erc-send-this | ||
| 5471 | str) | ||
| 5450 | (if (or (string-match "\n" str) | 5472 | (if (or (string-match "\n" str) |
| 5451 | (not (string-match erc-command-regexp str))) | 5473 | (not (string-match erc-command-regexp str))) |
| 5452 | (mapc | 5474 | (mapc |