aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorF. Jason Park2025-07-20 18:56:03 -0700
committerF. Jason Park2025-07-27 19:57:28 -0700
commit00a3ec9d53c6dbe00c48678f68a510b70e859d89 (patch)
tree4ec1d067ee935c10071b1628c751e98ceccbdc15
parentdb8f469bd403dc837333e0f06b9c9431a68d65c4 (diff)
downloademacs-00a3ec9d53c6dbe00c48678f68a510b70e859d89.tar.gz
emacs-00a3ec9d53c6dbe00c48678f68a510b70e859d89.zip
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.
-rw-r--r--lisp/erc/erc-notify.el12
-rw-r--r--lisp/erc/erc-speedbar.el5
-rw-r--r--lisp/erc/erc.el10
3 files changed, 21 insertions, 6 deletions
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
300an optional fallback for keeping query-participant rolls up to date on 300an optional fallback for keeping query-participant rolls up to date on
301servers that lack support or are stingy with their allotments. Until 301servers that lack support or are stingy with their allotments. Until
302such time, this module should be considered experimental and only really 302such time, this module should be considered experimental and only really
303useful for bots and other non-interactive Lisp programs. 303useful for bots and other non-interactive Lisp programs. Please note
304that reporting is unreliable for short periods while a query participant
305is parting, joining, quitting, or logging in.
304 306
305This is a local ERC module, so selectively polling only a subset of 307This is a local ERC module, so selectively polling only a subset of
306query targets is possible but cumbersome. To do so, ensure 308query targets is possible but cumbersome. To do so, ensure
@@ -316,6 +318,8 @@ at least the server buffer."
316 (erc-with-server-buffer 318 (erc-with-server-buffer
317 (unless erc-querypoll-mode 319 (unless erc-querypoll-mode
318 (erc-querypoll-mode +1))) 320 (erc-querypoll-mode +1)))
321 (add-function :override (local 'erc--query-table-synced-predicate)
322 #'erc--querypoll-active-p)
319 (erc--querypoll-subscribe (current-buffer))) 323 (erc--querypoll-subscribe (current-buffer)))
320 (erc-querypoll-mode -1)) 324 (erc-querypoll-mode -1))
321 (cl-assert (not erc--decouple-query-and-channel-membership-p)) 325 (cl-assert (not erc--decouple-query-and-channel-membership-p))
@@ -331,6 +335,8 @@ at least the server buffer."
331 (index (ring-member ring (current-buffer))) 335 (index (ring-member ring (current-buffer)))
332 ((not (erc--querypoll-target-in-chan-p (current-buffer))))) 336 ((not (erc--querypoll-target-in-chan-p (current-buffer)))))
333 (ring-remove ring index) 337 (ring-remove ring index)
338 (remove-function (local 'erc--query-table-synced-predicate)
339 #'erc--querypoll-active-p)
334 (unless (erc-current-nick-p (erc-target)) 340 (unless (erc-current-nick-p (erc-target))
335 (erc-remove-current-channel-member (erc-target)))) 341 (erc-remove-current-channel-member (erc-target))))
336 (erc-with-all-buffers-of-server erc-server-process #'erc-query-buffer-p 342 (erc-with-all-buffers-of-server erc-server-process #'erc-query-buffer-p
@@ -339,7 +345,9 @@ at least the server buffer."
339 (kill-local-variable 'erc--querypoll-timer)) 345 (kill-local-variable 'erc--querypoll-timer))
340 localp) 346 localp)
341 347
342(cl-defmethod erc--queries-current-p (&context (erc-querypoll-mode (eql t))) t) 348(defun erc--querypoll-active-p ()
349 "Return non-nil if `erc-querypoll-mode' is active in the current buffer."
350 erc-querypoll-mode)
343 351
344(defvar erc-querypoll-period-params '(10 10 1) 352(defvar erc-querypoll-period-params '(10 10 1)
345 "Parameters affecting the delay with respect to the number of buffers. 353 "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."
146 (setq serverp (erc--server-buffer-p)) 146 (setq serverp (erc--server-buffer-p))
147 (setq chanp (erc-channel-p (erc-default-target))) 147 (setq chanp (erc-channel-p (erc-default-target)))
148 (setq queryp (erc-query-buffer-p) 148 (setq queryp (erc-query-buffer-p)
149 queries-current-p (erc--queries-current-p))) 149 queries-current-p (funcall erc--query-table-synced-predicate)))
150 (defvar erc-nickbar-mode) 150 (defvar erc-nickbar-mode)
151 (cond ((and erc-nickbar-mode (null (get-buffer-window speedbar-buffer))) 151 (cond ((and erc-nickbar-mode (null (get-buffer-window speedbar-buffer)))
152 (run-at-time 0 nil #'erc-nickbar-mode -1)) 152 (run-at-time 0 nil #'erc-nickbar-mode -1))
@@ -207,7 +207,8 @@ This will add a speedbar major display mode."
207 207
208(defun erc-speedbar-insert-target (buffer depth) 208(defun erc-speedbar-insert-target (buffer depth)
209 (if (with-current-buffer buffer 209 (if (with-current-buffer buffer
210 (or (erc--target-channel-p erc--target) (erc--queries-current-p))) 210 (or (erc--target-channel-p erc--target)
211 (funcall erc--query-table-synced-predicate)))
211 (progn 212 (progn
212 (speedbar-make-tag-line 213 (speedbar-make-tag-line
213 'bracket ?+ 'erc-speedbar-expand-channel buffer 214 '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
559flag degrades the user experience and isn't guaranteed to correctly 559flag degrades the user experience and isn't guaranteed to correctly
560restore the described historical behavior.") 560restore the described historical behavior.")
561 561
562(cl-defmethod erc--queries-current-p () 562(defvar erc--query-table-synced-predicate #'erc--query-participant-present-p
563 "Return non-nil if ERC actively updates query manifests." 563 "Predicate for whether a query buffer's member table dynamically updates.
564By default, ERC flies half blind by managing membership based on shared
565channels. This rules out false positives but accepts the chance of
566participants being on the server but absent from local tables.")
567
568(defun erc--query-participant-present-p ()
569 "Return non-nil if the query participant is present in the member table."
564 (and (not erc--decouple-query-and-channel-membership-p) 570 (and (not erc--decouple-query-and-channel-membership-p)
565 (erc-query-buffer-p) (erc-get-channel-member (erc-target)))) 571 (erc-query-buffer-p) (erc-get-channel-member (erc-target))))
566 572