mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Use function-valued variable for ERC query predicate
* lisp/erc/erc-notify.el (erc-querypoll-mode, erc-querypoll-enable) (erc-querypoll-disable): Override `erc-query-table-synced-predicate' when mode is active. (erc--queries-current-p): Remove method. (erc--querypoll-active-p): New function. * lisp/erc/erc-speedbar.el (erc-speedbar-buttons) (erc-speedbar-insert-target): Call function-valued variable `erc--query-table-synced-predicate' instead of its now default value `erc--queries-current-p' directly. * lisp/erc/erc.el (erc--query-table-synced-predicate): New variable. (erc--queries-current-p, erc--query-participant-present-p): Convert former from method to normal function and rename to latter. Original was added as part of bug#70928.
This commit is contained in:
parent
db8f469bd4
commit
00a3ec9d53
3 changed files with 21 additions and 6 deletions
|
|
@ -300,7 +300,9 @@ Once ERC implements the `monitor' extension, this module will serve as
|
|||
an optional fallback for keeping query-participant rolls up to date on
|
||||
servers that lack support or are stingy with their allotments. Until
|
||||
such time, this module should be considered experimental and only really
|
||||
useful for bots and other non-interactive Lisp programs.
|
||||
useful for bots and other non-interactive Lisp programs. Please note
|
||||
that reporting is unreliable for short periods while a query participant
|
||||
is parting, joining, quitting, or logging in.
|
||||
|
||||
This is a local ERC module, so selectively polling only a subset of
|
||||
query targets is possible but cumbersome. To do so, ensure
|
||||
|
|
@ -316,6 +318,8 @@ at least the server buffer."
|
|||
(erc-with-server-buffer
|
||||
(unless erc-querypoll-mode
|
||||
(erc-querypoll-mode +1)))
|
||||
(add-function :override (local 'erc--query-table-synced-predicate)
|
||||
#'erc--querypoll-active-p)
|
||||
(erc--querypoll-subscribe (current-buffer)))
|
||||
(erc-querypoll-mode -1))
|
||||
(cl-assert (not erc--decouple-query-and-channel-membership-p))
|
||||
|
|
@ -331,6 +335,8 @@ at least the server buffer."
|
|||
(index (ring-member ring (current-buffer)))
|
||||
((not (erc--querypoll-target-in-chan-p (current-buffer)))))
|
||||
(ring-remove ring index)
|
||||
(remove-function (local 'erc--query-table-synced-predicate)
|
||||
#'erc--querypoll-active-p)
|
||||
(unless (erc-current-nick-p (erc-target))
|
||||
(erc-remove-current-channel-member (erc-target))))
|
||||
(erc-with-all-buffers-of-server erc-server-process #'erc-query-buffer-p
|
||||
|
|
@ -339,7 +345,9 @@ at least the server buffer."
|
|||
(kill-local-variable 'erc--querypoll-timer))
|
||||
localp)
|
||||
|
||||
(cl-defmethod erc--queries-current-p (&context (erc-querypoll-mode (eql t))) t)
|
||||
(defun erc--querypoll-active-p ()
|
||||
"Return non-nil if `erc-querypoll-mode' is active in the current buffer."
|
||||
erc-querypoll-mode)
|
||||
|
||||
(defvar erc-querypoll-period-params '(10 10 1)
|
||||
"Parameters affecting the delay with respect to the number of buffers.
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ This will add a speedbar major display mode."
|
|||
(setq serverp (erc--server-buffer-p))
|
||||
(setq chanp (erc-channel-p (erc-default-target)))
|
||||
(setq queryp (erc-query-buffer-p)
|
||||
queries-current-p (erc--queries-current-p)))
|
||||
queries-current-p (funcall erc--query-table-synced-predicate)))
|
||||
(defvar erc-nickbar-mode)
|
||||
(cond ((and erc-nickbar-mode (null (get-buffer-window speedbar-buffer)))
|
||||
(run-at-time 0 nil #'erc-nickbar-mode -1))
|
||||
|
|
@ -207,7 +207,8 @@ This will add a speedbar major display mode."
|
|||
|
||||
(defun erc-speedbar-insert-target (buffer depth)
|
||||
(if (with-current-buffer buffer
|
||||
(or (erc--target-channel-p erc--target) (erc--queries-current-p)))
|
||||
(or (erc--target-channel-p erc--target)
|
||||
(funcall erc--query-table-synced-predicate)))
|
||||
(progn
|
||||
(speedbar-make-tag-line
|
||||
'bracket ?+ 'erc-speedbar-expand-channel buffer
|
||||
|
|
|
|||
|
|
@ -559,8 +559,14 @@ user from `erc-server-users'. Note that enabling this compatibility
|
|||
flag degrades the user experience and isn't guaranteed to correctly
|
||||
restore the described historical behavior.")
|
||||
|
||||
(cl-defmethod erc--queries-current-p ()
|
||||
"Return non-nil if ERC actively updates query manifests."
|
||||
(defvar erc--query-table-synced-predicate #'erc--query-participant-present-p
|
||||
"Predicate for whether a query buffer's member table dynamically updates.
|
||||
By default, ERC flies half blind by managing membership based on shared
|
||||
channels. This rules out false positives but accepts the chance of
|
||||
participants being on the server but absent from local tables.")
|
||||
|
||||
(defun erc--query-participant-present-p ()
|
||||
"Return non-nil if the query participant is present in the member table."
|
||||
(and (not erc--decouple-query-and-channel-membership-p)
|
||||
(erc-query-buffer-p) (erc-get-channel-member (erc-target))))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue