diff options
| author | F. Jason Park | 2023-10-15 07:22:31 -0700 |
|---|---|---|
| committer | F. Jason Park | 2023-10-20 15:22:56 -0700 |
| commit | 8cf66ab1e5ff253d72368901490f073634e1ae4b (patch) | |
| tree | 3c806eca5733be44f8cb4f93a36d5be4a2c8222c /lisp/erc | |
| parent | bcebda5eec2166e475579c2aa2ee425aeabbb505 (diff) | |
| download | emacs-8cf66ab1e5ff253d72368901490f073634e1ae4b.tar.gz emacs-8cf66ab1e5ff253d72368901490f073634e1ae4b.zip | |
Rename erc-server-buffer-p
* lisp/erc/erc-log.el (erc-log-all-but-server-buffers): Use
`erc--server-buffer-p' instead of `erc-server-buffer-p'. This
replacement is presumed to be relatively "safe" because this function
is unused in the code base and only appears in the doc string for the
option `erc-enable-logging'.
* lisp/erc/erc-match.el (erc-match-message): Leave comment proposing
that `erc--server-buffer-p' should be preferred to
`erc-server-buffer-p'. Use preferred alias for `erc-server-buffer-p'.
* lisp/erc/erc-notify.el (erc-cmd-NOTIFY): Use preferred alias for
`erc-server-buffer-p', and leave FIXME comment.
* lisp/erc/erc-speedbar.el (erc-speedbar-buttons): Use
`erc--server-buffer-p' instead of `erc-server-buffer-p'. The logic
here seems simple enough to justify a change, however the absence of
related bug reports is perhaps an argument against this.
* lisp/erc/erc-track.el (erc-track-modified-channels): Use preferred
alias for `erc-server-buffer-p' and leave comment noting possible bug.
* lisp/erc/erc.el (erc-once-with-server-event): Use
`erc--server-buffer-p' instead of `erc-server-buffer-p'. This change
seems justified because the function sets local hooks that would
otherwise be ignored outside of a server buffer.
(erc-server-buffer-p, erc-server-or-unjoined-channel-buffer-p): Make
the former an obsolete alias for the latter.
(erc--server-buffer-p): New function to replace `erc-server-buffer-p'
internally in new code. Unlike its predecessor, it returns nil in
parted and kicked channels.
(erc-open-server-buffer-p): Use `erc--server-buffer-p' instead of
`erc-server-buffer-p'. Given the name and the doc string, breaking
the odd misuse of this function in parted buffers seems justified
because this is clearly a bug fix. Also, all uses in-tree conform to
the intended behavior as documented. And a cursory grep of all "erc-"
prefixed packages on MELPA reveals zero instances of this function.
Nor is it used in erbot.
(erc-get-buffer): Mention behavior in doc string regarding parted and
kicked-from channels.
(erc-cmd-GQUIT): Fix wrong-number-of-arguments bug in timer function.
(erc-default-target): Mention behavior regarding unjoined channels.
(erc-kill-query-buffers): Don't use `erc-server-buffer-p'. This
replacement may break third-party code expecting to leave parted
channels behind, but it seems sane when considering only the lone
internal use in `erc-cmd-QUIT'.
; * test/lisp/erc/resources/join/network-id/foonet.eld: Timeouts.
(Bug#66578)
Diffstat (limited to 'lisp/erc')
| -rw-r--r-- | lisp/erc/erc-log.el | 4 | ||||
| -rw-r--r-- | lisp/erc/erc-match.el | 4 | ||||
| -rw-r--r-- | lisp/erc/erc-notify.el | 4 | ||||
| -rw-r--r-- | lisp/erc/erc-speedbar.el | 2 | ||||
| -rw-r--r-- | lisp/erc/erc-track.el | 4 | ||||
| -rw-r--r-- | lisp/erc/erc.el | 44 |
6 files changed, 40 insertions, 22 deletions
diff --git a/lisp/erc/erc-log.el b/lisp/erc/erc-log.el index 472cc1388a4..79fece5779e 100644 --- a/lisp/erc/erc-log.el +++ b/lisp/erc/erc-log.el | |||
| @@ -276,11 +276,11 @@ The current buffer is given by BUFFER." | |||
| 276 | 276 | ||
| 277 | (defun erc-log-all-but-server-buffers (buffer) | 277 | (defun erc-log-all-but-server-buffers (buffer) |
| 278 | "Return t if logging should be enabled in BUFFER. | 278 | "Return t if logging should be enabled in BUFFER. |
| 279 | Returns nil if `erc-server-buffer-p' returns t." | 279 | Return nil if BUFFER is a server buffer." |
| 280 | (save-excursion | 280 | (save-excursion |
| 281 | (save-window-excursion | 281 | (save-window-excursion |
| 282 | (set-buffer buffer) | 282 | (set-buffer buffer) |
| 283 | (not (erc-server-buffer-p))))) | 283 | (not (erc--server-buffer-p))))) |
| 284 | 284 | ||
| 285 | (defun erc-save-query-buffers (process) | 285 | (defun erc-save-query-buffers (process) |
| 286 | "Save all buffers of the given PROCESS." | 286 | "Save all buffers of the given PROCESS." |
diff --git a/lisp/erc/erc-match.el b/lisp/erc/erc-match.el index 186717579d7..8644e61106f 100644 --- a/lisp/erc/erc-match.el +++ b/lisp/erc/erc-match.el | |||
| @@ -491,7 +491,9 @@ Use this defun with `erc-insert-modify-hook'." | |||
| 491 | (message (buffer-substring message-beg (point-max)))) | 491 | (message (buffer-substring message-beg (point-max)))) |
| 492 | (when (and vector | 492 | (when (and vector |
| 493 | (not (and erc-match-exclude-server-buffer | 493 | (not (and erc-match-exclude-server-buffer |
| 494 | (erc-server-buffer-p)))) | 494 | ;; FIXME replace with `erc--server-buffer-p' |
| 495 | ;; or explain why that's unwise. | ||
| 496 | (erc-server-or-unjoined-channel-buffer-p)))) | ||
| 495 | (mapc | 497 | (mapc |
| 496 | (lambda (match-type) | 498 | (lambda (match-type) |
| 497 | (goto-char (point-min)) | 499 | (goto-char (point-min)) |
diff --git a/lisp/erc/erc-notify.el b/lisp/erc/erc-notify.el index 55be8976ada..cf7ffbb40d7 100644 --- a/lisp/erc/erc-notify.el +++ b/lisp/erc/erc-notify.el | |||
| @@ -218,7 +218,9 @@ with args, toggle notify status of people." | |||
| 218 | ;; from your notify list. | 218 | ;; from your notify list. |
| 219 | (dolist (buf (erc-buffer-list)) | 219 | (dolist (buf (erc-buffer-list)) |
| 220 | (with-current-buffer buf | 220 | (with-current-buffer buf |
| 221 | (if (erc-server-buffer-p) | 221 | ;; FIXME replace with `erc--server-buffer-p' or |
| 222 | ;; explain why that's unwise. | ||
| 223 | (if (erc-server-or-unjoined-channel-buffer-p) | ||
| 222 | (setq erc-last-ison (delete (car args) erc-last-ison)))))) | 224 | (setq erc-last-ison (delete (car args) erc-last-ison)))))) |
| 223 | (setq erc-notify-list (cons (erc-string-no-properties (car args)) | 225 | (setq erc-notify-list (cons (erc-string-no-properties (car args)) |
| 224 | erc-notify-list))) | 226 | erc-notify-list))) |
diff --git a/lisp/erc/erc-speedbar.el b/lisp/erc/erc-speedbar.el index 625d59530b0..bb5fad6f52f 100644 --- a/lisp/erc/erc-speedbar.el +++ b/lisp/erc/erc-speedbar.el | |||
| @@ -135,7 +135,7 @@ This will add a speedbar major display mode." | |||
| 135 | (erase-buffer) | 135 | (erase-buffer) |
| 136 | (let (serverp chanp queryp) | 136 | (let (serverp chanp queryp) |
| 137 | (with-current-buffer buffer | 137 | (with-current-buffer buffer |
| 138 | (setq serverp (erc-server-buffer-p)) | 138 | (setq serverp (erc--server-buffer-p)) |
| 139 | (setq chanp (erc-channel-p (erc-default-target))) | 139 | (setq chanp (erc-channel-p (erc-default-target))) |
| 140 | (setq queryp (erc-query-buffer-p))) | 140 | (setq queryp (erc-query-buffer-p))) |
| 141 | (cond (serverp | 141 | (cond (serverp |
diff --git a/lisp/erc/erc-track.el b/lisp/erc/erc-track.el index 64e59a90047..c8f2e04c3eb 100644 --- a/lisp/erc/erc-track.el +++ b/lisp/erc/erc-track.el | |||
| @@ -795,7 +795,9 @@ the current buffer is in `erc-mode'." | |||
| 795 | (if (and (not (erc-buffer-visible (current-buffer))) | 795 | (if (and (not (erc-buffer-visible (current-buffer))) |
| 796 | (not (member this-channel erc-track-exclude)) | 796 | (not (member this-channel erc-track-exclude)) |
| 797 | (not (and erc-track-exclude-server-buffer | 797 | (not (and erc-track-exclude-server-buffer |
| 798 | (erc-server-buffer-p))) | 798 | ;; FIXME either use `erc--server-buffer-p' or |
| 799 | ;; explain why that's unwise. | ||
| 800 | (erc-server-or-unjoined-channel-buffer-p))) | ||
| 799 | (not (erc-message-type-member | 801 | (not (erc-message-type-member |
| 800 | (or (erc-find-parsed-property) | 802 | (or (erc-find-parsed-property) |
| 801 | (point-min)) | 803 | (point-min)) |
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index f2c93d29d5c..877478690af 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el | |||
| @@ -1417,7 +1417,7 @@ Please be sure to use this function in server-buffers. In | |||
| 1417 | channel-buffers it may not work at all, as it uses the LOCAL | 1417 | channel-buffers it may not work at all, as it uses the LOCAL |
| 1418 | argument of `add-hook' and `remove-hook' to ensure multiserver | 1418 | argument of `add-hook' and `remove-hook' to ensure multiserver |
| 1419 | capabilities." | 1419 | capabilities." |
| 1420 | (unless (erc-server-buffer-p) | 1420 | (unless (erc--server-buffer-p) |
| 1421 | (error | 1421 | (error |
| 1422 | "You should only run `erc-once-with-server-event' in a server buffer")) | 1422 | "You should only run `erc-once-with-server-event' in a server buffer")) |
| 1423 | (let ((fun (make-symbol "fun")) | 1423 | (let ((fun (make-symbol "fun")) |
| @@ -1474,19 +1474,30 @@ the process buffer." | |||
| 1474 | (and (processp erc-server-process) | 1474 | (and (processp erc-server-process) |
| 1475 | (buffer-live-p (process-buffer erc-server-process)))) | 1475 | (buffer-live-p (process-buffer erc-server-process)))) |
| 1476 | 1476 | ||
| 1477 | (defun erc-server-buffer-p (&optional buffer) | 1477 | (define-obsolete-function-alias |
| 1478 | 'erc-server-buffer-p 'erc-server-or-unjoined-channel-buffer-p "30.1") | ||
| 1479 | (defun erc-server-or-unjoined-channel-buffer-p (&optional buffer) | ||
| 1478 | "Return non-nil if argument BUFFER is an ERC server buffer. | 1480 | "Return non-nil if argument BUFFER is an ERC server buffer. |
| 1479 | 1481 | If BUFFER is nil, use the current buffer. For historical | |
| 1480 | If BUFFER is nil, the current buffer is used." | 1482 | reasons, also return non-nil for channel buffers the client has |
| 1483 | parted or from which it's been kicked." | ||
| 1481 | (with-current-buffer (or buffer (current-buffer)) | 1484 | (with-current-buffer (or buffer (current-buffer)) |
| 1482 | (and (eq major-mode 'erc-mode) | 1485 | (and (eq major-mode 'erc-mode) |
| 1483 | (null (erc-default-target))))) | 1486 | (null (erc-default-target))))) |
| 1484 | 1487 | ||
| 1488 | (defun erc--server-buffer-p (&optional buffer) | ||
| 1489 | "Return non-nil if BUFFER is an ERC server buffer. | ||
| 1490 | Without BUFFER, use the current buffer." | ||
| 1491 | (if buffer | ||
| 1492 | (with-current-buffer buffer | ||
| 1493 | (and (eq major-mode 'erc-mode) (null erc--target))) | ||
| 1494 | (and (eq major-mode 'erc-mode) (null erc--target)))) | ||
| 1495 | |||
| 1485 | (defun erc-open-server-buffer-p (&optional buffer) | 1496 | (defun erc-open-server-buffer-p (&optional buffer) |
| 1486 | "Return non-nil if BUFFER is an ERC server buffer with an open IRC process. | 1497 | "Return non-nil if BUFFER is an ERC server buffer with an open IRC process. |
| 1487 | 1498 | ||
| 1488 | If BUFFER is nil, the current buffer is used." | 1499 | If BUFFER is nil, the current buffer is used." |
| 1489 | (and (erc-server-buffer-p buffer) | 1500 | (and (erc--server-buffer-p buffer) |
| 1490 | (erc-server-process-alive buffer))) | 1501 | (erc-server-process-alive buffer))) |
| 1491 | 1502 | ||
| 1492 | (defun erc-query-buffer-p (&optional buffer) | 1503 | (defun erc-query-buffer-p (&optional buffer) |
| @@ -1858,7 +1869,10 @@ All strings are compared according to IRC protocol case rules, see | |||
| 1858 | 1869 | ||
| 1859 | (defun erc-get-buffer (target &optional proc) | 1870 | (defun erc-get-buffer (target &optional proc) |
| 1860 | "Return the buffer matching TARGET in the process PROC. | 1871 | "Return the buffer matching TARGET in the process PROC. |
| 1861 | If PROC is not supplied, all processes are searched." | 1872 | Without PROC, search all ERC buffers. For historical reasons, |
| 1873 | skip buffers for channels the client has \"PART\"ed or from which | ||
| 1874 | it's been \"KICK\"ed. Expect users to use a different function | ||
| 1875 | for finding targets independent of \"JOIN\"edness." | ||
| 1862 | (let ((downcased-target (erc-downcase target))) | 1876 | (let ((downcased-target (erc-downcase target))) |
| 1863 | (catch 'buffer | 1877 | (catch 'buffer |
| 1864 | (erc-buffer-filter | 1878 | (erc-buffer-filter |
| @@ -4632,10 +4646,7 @@ the message given by REASON." | |||
| 4632 | ;; kill them | 4646 | ;; kill them |
| 4633 | (run-at-time | 4647 | (run-at-time |
| 4634 | 4 nil | 4648 | 4 nil |
| 4635 | (lambda () | 4649 | #'erc-buffer-do (lambda () (when erc--target (kill-buffer))))) |
| 4636 | (dolist (buffer (erc-buffer-list (lambda (buf) | ||
| 4637 | (not (erc-server-buffer-p buf))))) | ||
| 4638 | (kill-buffer buffer))))) | ||
| 4639 | t) | 4650 | t) |
| 4640 | 4651 | ||
| 4641 | (defalias 'erc-cmd-GQ #'erc-cmd-GQUIT) | 4652 | (defalias 'erc-cmd-GQ #'erc-cmd-GQUIT) |
| @@ -7075,7 +7086,9 @@ See also `erc-downcase'." | |||
| 7075 | ;; continue to use `erc-default-target'. | 7086 | ;; continue to use `erc-default-target'. |
| 7076 | 7087 | ||
| 7077 | (defun erc-default-target () | 7088 | (defun erc-default-target () |
| 7078 | "Return the current default target (as a character string) or nil if none." | 7089 | "Return the current channel or query target, if any. |
| 7090 | For historical reasons, return nil in channel buffers if not | ||
| 7091 | currently joined." | ||
| 7079 | (let ((tgt (car erc-default-recipients))) | 7092 | (let ((tgt (car erc-default-recipients))) |
| 7080 | (cond | 7093 | (cond |
| 7081 | ((not tgt) nil) | 7094 | ((not tgt) nil) |
| @@ -7637,15 +7650,14 @@ If it doesn't exist, create it." | |||
| 7637 | (unless (file-attributes dir) (make-directory dir)) | 7650 | (unless (file-attributes dir) (make-directory dir)) |
| 7638 | (or (file-accessible-directory-p dir) (error "Cannot access %s" dir))) | 7651 | (or (file-accessible-directory-p dir) (error "Cannot access %s" dir))) |
| 7639 | 7652 | ||
| 7653 | ;; FIXME make function obsolete or alias to something less confusing. | ||
| 7640 | (defun erc-kill-query-buffers (process) | 7654 | (defun erc-kill-query-buffers (process) |
| 7641 | "Kill all buffers of PROCESS. | 7655 | "Kill all target buffers of PROCESS, including channel buffers. |
| 7642 | Does nothing if PROCESS is not a process object." | 7656 | Do nothing if PROCESS is not a process object." |
| 7643 | ;; here, we only want to match the channel buffers, to avoid | 7657 | ;; here, we only want to match the channel buffers, to avoid |
| 7644 | ;; "selecting killed buffers" b0rkage. | 7658 | ;; "selecting killed buffers" b0rkage. |
| 7645 | (when (processp process) | 7659 | (when (processp process) |
| 7646 | (erc-with-all-buffers-of-server process | 7660 | (erc-with-all-buffers-of-server process (lambda () erc--target) |
| 7647 | (lambda () | ||
| 7648 | (not (erc-server-buffer-p))) | ||
| 7649 | (kill-buffer (current-buffer))))) | 7661 | (kill-buffer (current-buffer))))) |
| 7650 | 7662 | ||
| 7651 | (defun erc-nick-at-point () | 7663 | (defun erc-nick-at-point () |