diff --git a/lisp/erc/erc-notify.el b/lisp/erc/erc-notify.el index 1e04c90177e..38ed0f8fb69 100644 --- a/lisp/erc/erc-notify.el +++ b/lisp/erc/erc-notify.el @@ -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. diff --git a/lisp/erc/erc-speedbar.el b/lisp/erc/erc-speedbar.el index 0ae5ebb1641..720b5cd5d11 100644 --- a/lisp/erc/erc-speedbar.el +++ b/lisp/erc/erc-speedbar.el @@ -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 diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index d377839733b..af7dc428e3f 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -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))))