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)
This commit is contained in:
parent
bcebda5eec
commit
8cf66ab1e5
7 changed files with 42 additions and 24 deletions
|
@ -276,11 +276,11 @@ The current buffer is given by BUFFER."
|
|||
|
||||
(defun erc-log-all-but-server-buffers (buffer)
|
||||
"Return t if logging should be enabled in BUFFER.
|
||||
Returns nil if `erc-server-buffer-p' returns t."
|
||||
Return nil if BUFFER is a server buffer."
|
||||
(save-excursion
|
||||
(save-window-excursion
|
||||
(set-buffer buffer)
|
||||
(not (erc-server-buffer-p)))))
|
||||
(not (erc--server-buffer-p)))))
|
||||
|
||||
(defun erc-save-query-buffers (process)
|
||||
"Save all buffers of the given PROCESS."
|
||||
|
|
|
@ -491,7 +491,9 @@ Use this defun with `erc-insert-modify-hook'."
|
|||
(message (buffer-substring message-beg (point-max))))
|
||||
(when (and vector
|
||||
(not (and erc-match-exclude-server-buffer
|
||||
(erc-server-buffer-p))))
|
||||
;; FIXME replace with `erc--server-buffer-p'
|
||||
;; or explain why that's unwise.
|
||||
(erc-server-or-unjoined-channel-buffer-p))))
|
||||
(mapc
|
||||
(lambda (match-type)
|
||||
(goto-char (point-min))
|
||||
|
|
|
@ -218,7 +218,9 @@ with args, toggle notify status of people."
|
|||
;; from your notify list.
|
||||
(dolist (buf (erc-buffer-list))
|
||||
(with-current-buffer buf
|
||||
(if (erc-server-buffer-p)
|
||||
;; FIXME replace with `erc--server-buffer-p' or
|
||||
;; explain why that's unwise.
|
||||
(if (erc-server-or-unjoined-channel-buffer-p)
|
||||
(setq erc-last-ison (delete (car args) erc-last-ison))))))
|
||||
(setq erc-notify-list (cons (erc-string-no-properties (car args))
|
||||
erc-notify-list)))
|
||||
|
|
|
@ -135,7 +135,7 @@ This will add a speedbar major display mode."
|
|||
(erase-buffer)
|
||||
(let (serverp chanp queryp)
|
||||
(with-current-buffer buffer
|
||||
(setq serverp (erc-server-buffer-p))
|
||||
(setq serverp (erc--server-buffer-p))
|
||||
(setq chanp (erc-channel-p (erc-default-target)))
|
||||
(setq queryp (erc-query-buffer-p)))
|
||||
(cond (serverp
|
||||
|
|
|
@ -795,7 +795,9 @@ the current buffer is in `erc-mode'."
|
|||
(if (and (not (erc-buffer-visible (current-buffer)))
|
||||
(not (member this-channel erc-track-exclude))
|
||||
(not (and erc-track-exclude-server-buffer
|
||||
(erc-server-buffer-p)))
|
||||
;; FIXME either use `erc--server-buffer-p' or
|
||||
;; explain why that's unwise.
|
||||
(erc-server-or-unjoined-channel-buffer-p)))
|
||||
(not (erc-message-type-member
|
||||
(or (erc-find-parsed-property)
|
||||
(point-min))
|
||||
|
|
|
@ -1417,7 +1417,7 @@ Please be sure to use this function in server-buffers. In
|
|||
channel-buffers it may not work at all, as it uses the LOCAL
|
||||
argument of `add-hook' and `remove-hook' to ensure multiserver
|
||||
capabilities."
|
||||
(unless (erc-server-buffer-p)
|
||||
(unless (erc--server-buffer-p)
|
||||
(error
|
||||
"You should only run `erc-once-with-server-event' in a server buffer"))
|
||||
(let ((fun (make-symbol "fun"))
|
||||
|
@ -1474,19 +1474,30 @@ the process buffer."
|
|||
(and (processp erc-server-process)
|
||||
(buffer-live-p (process-buffer erc-server-process))))
|
||||
|
||||
(defun erc-server-buffer-p (&optional buffer)
|
||||
(define-obsolete-function-alias
|
||||
'erc-server-buffer-p 'erc-server-or-unjoined-channel-buffer-p "30.1")
|
||||
(defun erc-server-or-unjoined-channel-buffer-p (&optional buffer)
|
||||
"Return non-nil if argument BUFFER is an ERC server buffer.
|
||||
|
||||
If BUFFER is nil, the current buffer is used."
|
||||
If BUFFER is nil, use the current buffer. For historical
|
||||
reasons, also return non-nil for channel buffers the client has
|
||||
parted or from which it's been kicked."
|
||||
(with-current-buffer (or buffer (current-buffer))
|
||||
(and (eq major-mode 'erc-mode)
|
||||
(null (erc-default-target)))))
|
||||
|
||||
(defun erc--server-buffer-p (&optional buffer)
|
||||
"Return non-nil if BUFFER is an ERC server buffer.
|
||||
Without BUFFER, use the current buffer."
|
||||
(if buffer
|
||||
(with-current-buffer buffer
|
||||
(and (eq major-mode 'erc-mode) (null erc--target)))
|
||||
(and (eq major-mode 'erc-mode) (null erc--target))))
|
||||
|
||||
(defun erc-open-server-buffer-p (&optional buffer)
|
||||
"Return non-nil if BUFFER is an ERC server buffer with an open IRC process.
|
||||
|
||||
If BUFFER is nil, the current buffer is used."
|
||||
(and (erc-server-buffer-p buffer)
|
||||
(and (erc--server-buffer-p buffer)
|
||||
(erc-server-process-alive buffer)))
|
||||
|
||||
(defun erc-query-buffer-p (&optional buffer)
|
||||
|
@ -1858,7 +1869,10 @@ All strings are compared according to IRC protocol case rules, see
|
|||
|
||||
(defun erc-get-buffer (target &optional proc)
|
||||
"Return the buffer matching TARGET in the process PROC.
|
||||
If PROC is not supplied, all processes are searched."
|
||||
Without PROC, search all ERC buffers. For historical reasons,
|
||||
skip buffers for channels the client has \"PART\"ed or from which
|
||||
it's been \"KICK\"ed. Expect users to use a different function
|
||||
for finding targets independent of \"JOIN\"edness."
|
||||
(let ((downcased-target (erc-downcase target)))
|
||||
(catch 'buffer
|
||||
(erc-buffer-filter
|
||||
|
@ -4632,10 +4646,7 @@ the message given by REASON."
|
|||
;; kill them
|
||||
(run-at-time
|
||||
4 nil
|
||||
(lambda ()
|
||||
(dolist (buffer (erc-buffer-list (lambda (buf)
|
||||
(not (erc-server-buffer-p buf)))))
|
||||
(kill-buffer buffer)))))
|
||||
#'erc-buffer-do (lambda () (when erc--target (kill-buffer)))))
|
||||
t)
|
||||
|
||||
(defalias 'erc-cmd-GQ #'erc-cmd-GQUIT)
|
||||
|
@ -7075,7 +7086,9 @@ See also `erc-downcase'."
|
|||
;; continue to use `erc-default-target'.
|
||||
|
||||
(defun erc-default-target ()
|
||||
"Return the current default target (as a character string) or nil if none."
|
||||
"Return the current channel or query target, if any.
|
||||
For historical reasons, return nil in channel buffers if not
|
||||
currently joined."
|
||||
(let ((tgt (car erc-default-recipients)))
|
||||
(cond
|
||||
((not tgt) nil)
|
||||
|
@ -7637,15 +7650,14 @@ If it doesn't exist, create it."
|
|||
(unless (file-attributes dir) (make-directory dir))
|
||||
(or (file-accessible-directory-p dir) (error "Cannot access %s" dir)))
|
||||
|
||||
;; FIXME make function obsolete or alias to something less confusing.
|
||||
(defun erc-kill-query-buffers (process)
|
||||
"Kill all buffers of PROCESS.
|
||||
Does nothing if PROCESS is not a process object."
|
||||
"Kill all target buffers of PROCESS, including channel buffers.
|
||||
Do nothing if PROCESS is not a process object."
|
||||
;; here, we only want to match the channel buffers, to avoid
|
||||
;; "selecting killed buffers" b0rkage.
|
||||
(when (processp process)
|
||||
(erc-with-all-buffers-of-server process
|
||||
(lambda ()
|
||||
(not (erc-server-buffer-p)))
|
||||
(erc-with-all-buffers-of-server process (lambda () erc--target)
|
||||
(kill-buffer (current-buffer)))))
|
||||
|
||||
(defun erc-nick-at-point ()
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
;; -*- mode: lisp-data; -*-
|
||||
((pass 10 "PASS :foonet:changeme"))
|
||||
((nick 1 "NICK tester"))
|
||||
((nick 10 "NICK tester"))
|
||||
|
||||
((user 1 "USER user 0 * :tester")
|
||||
((user 10 "USER user 0 * :tester")
|
||||
(0 ":irc.foonet.org 001 tester :Welcome to the foonet IRC Network tester")
|
||||
(0 ":irc.foonet.org 002 tester :Your host is irc.foonet.org, running version oragono-2.6.0-7481bf0385b95b16")
|
||||
(0 ":irc.foonet.org 003 tester :This server was created Mon, 10 May 2021 00:58:22 UTC")
|
||||
|
|
Loading…
Add table
Reference in a new issue