diff options
| author | F. Jason Park | 2024-05-22 22:59:54 -0700 |
|---|---|---|
| committer | F. Jason Park | 2024-05-27 16:46:40 -0700 |
| commit | 6888bbbe832e14c3aaaa2c9750ed27e577e0983d (patch) | |
| tree | 890d80927ef23f1b7d330ca6aa9a1ebd265fe963 /test | |
| parent | 5f84213c9802181b4d800615915e3c8dded7b94f (diff) | |
| download | emacs-6888bbbe832e14c3aaaa2c9750ed27e577e0983d.tar.gz emacs-6888bbbe832e14c3aaaa2c9750ed27e577e0983d.zip | |
Add ERC module querypoll as monitor placeholder
* doc/misc/erc.texi: Add module `querypoll' to list of built-in
modules'.
* etc/ERC-NEWS: Mention new module `querypoll', and explain new
default behavior for deriving query membership from that of channels.
* lisp/erc/erc-goodies.el (erc--querypoll-ring)
(erc--querypoll-timer): New variables.
(erc-querypoll-exclude-regexp): New option.
(erc-querypoll-mode, erc-querypoll-enable, erc-querypoll-disable): New
module for polling with "WHO" requests for the presence of otherwise
"untracked" query targets.
(erc-querypoll-period-params): New variable.
(erc--querypoll-compute-period)
(erc--querypoll-target-in-chan-p)
(erc--querypoll-get-length)
(erc--querypoll-get-next)
(erc--querypoll-subscribe)
(erc--querypoll-on-352)
(erc--querypoll-send): New functions.
* lisp/erc/erc-speedbar.el (erc-speedbar-buttons): Dispatch queries as
if they were channels when `erc--queries-current-p' returns non-nil.
That is, show head counts alongside query targets as users come and
go.
(erc-speedbar-insert-target): Defer to `erc--queries-current-p' to
know whether to show a query in the style of a channel. This affects
both the plain speedbar integration as well as the `nickbar' module
added for bug#63595. Also, use question marks rather than the empty
string for query bullets, so that query and channel items are aligned
vertically.
* lisp/erc/erc.el (erc--queries-current-p): New function.
* test/lisp/erc/erc-goodies-tests.el
(erc--querypoll-compute-period)
(erc--querypoll-target-in-chan-p)
(erc--querypoll-get-length)
(erc--querypoll-get-next): New tests. (Bug#70928)
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/erc/erc-goodies-tests.el | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/lisp/erc/erc-goodies-tests.el b/test/lisp/erc/erc-goodies-tests.el index 7cbaa39d3f7..ead0bf5a979 100644 --- a/test/lisp/erc/erc-goodies-tests.el +++ b/test/lisp/erc/erc-goodies-tests.el | |||
| @@ -609,4 +609,61 @@ | |||
| 609 | (should (equal '(3 . 11) (erc--get-inserted-msg-bounds arg)))))) | 609 | (should (equal '(3 . 11) (erc--get-inserted-msg-bounds arg)))))) |
| 610 | 610 | ||
| 611 | 611 | ||
| 612 | ;;;; querypoll | ||
| 613 | |||
| 614 | (ert-deftest erc--querypoll-compute-period () | ||
| 615 | (should (equal (mapcar (lambda (i) | ||
| 616 | (/ (round (* 100 (erc--querypoll-compute-period i))) | ||
| 617 | 100.0)) | ||
| 618 | (number-sequence 0 10)) | ||
| 619 | '(11.0 10.05 9.19 8.41 7.7 7.07 6.49 5.97 5.49 5.07 4.68)))) | ||
| 620 | |||
| 621 | (declare-function ring-insert "ring" (ring item)) | ||
| 622 | |||
| 623 | (ert-deftest erc--querypoll-target-in-chan-p () | ||
| 624 | (erc-tests-common-make-server-buf) | ||
| 625 | (with-current-buffer (erc--open-target "#chan") | ||
| 626 | (erc-update-current-channel-member "bob" "bob" 'addp)) | ||
| 627 | |||
| 628 | (with-current-buffer (erc--open-target "bob") | ||
| 629 | (should (erc--querypoll-target-in-chan-p (current-buffer)))) | ||
| 630 | |||
| 631 | (with-current-buffer (erc--open-target "alice") | ||
| 632 | (should-not (erc--querypoll-target-in-chan-p (current-buffer)))) | ||
| 633 | |||
| 634 | (when noninteractive | ||
| 635 | (erc-tests-common-kill-buffers))) | ||
| 636 | |||
| 637 | (ert-deftest erc--querypoll-get-length () | ||
| 638 | (erc-tests-common-make-server-buf) | ||
| 639 | (with-current-buffer (erc--open-target "#chan") | ||
| 640 | (erc-update-current-channel-member "bob" "bob" 'addp)) | ||
| 641 | |||
| 642 | (let ((ring (make-ring 5))) | ||
| 643 | (ring-insert ring (with-current-buffer (erc--open-target "bob"))) | ||
| 644 | (should (= 0 (erc--querypoll-get-length ring))) | ||
| 645 | (ring-insert ring (with-current-buffer (erc--open-target "alice"))) | ||
| 646 | (should (= 1 (erc--querypoll-get-length ring)))) | ||
| 647 | |||
| 648 | (when noninteractive | ||
| 649 | (erc-tests-common-kill-buffers))) | ||
| 650 | |||
| 651 | (ert-deftest erc--querypoll-get-next () | ||
| 652 | (erc-tests-common-make-server-buf) | ||
| 653 | (with-current-buffer (erc--open-target "#chan") | ||
| 654 | (erc-update-current-channel-member "bob" "bob" 'addp) | ||
| 655 | (erc-update-current-channel-member "alice" "alice" 'addp)) | ||
| 656 | |||
| 657 | (let ((ring (make-ring 5))) | ||
| 658 | (ring-insert ring (with-current-buffer (erc--open-target "bob"))) | ||
| 659 | (ring-insert ring (with-current-buffer (erc--open-target "dummy"))) | ||
| 660 | (ring-insert ring (with-current-buffer (erc--open-target "alice"))) | ||
| 661 | (ring-insert ring (with-current-buffer (erc--open-target "tester"))) | ||
| 662 | (kill-buffer (get-buffer "dummy")) | ||
| 663 | |||
| 664 | (should (eq (get-buffer "tester") (erc--querypoll-get-next ring)))) | ||
| 665 | |||
| 666 | (when noninteractive | ||
| 667 | (erc-tests-common-kill-buffers))) | ||
| 668 | |||
| 612 | ;;; erc-goodies-tests.el ends here | 669 | ;;; erc-goodies-tests.el ends here |