diff options
| author | F. Jason Park | 2023-09-10 22:55:16 -0700 |
|---|---|---|
| committer | F. Jason Park | 2023-09-17 16:06:49 -0700 |
| commit | ef4a3c2a6d8ef854bed066ce25b31ff73e1d7664 (patch) | |
| tree | fe980929b57df1f281618a7535614ba3033d7934 | |
| parent | 7d2870dc856790de343a876611837b38ad6adcff (diff) | |
| download | emacs-ef4a3c2a6d8ef854bed066ce25b31ff73e1d7664.tar.gz emacs-ef4a3c2a6d8ef854bed066ce25b31ff73e1d7664.zip | |
; Fix example in display-buffer section of ERC manual
* doc/misc/erc.texi: Fix `display-buffer-alist' example and mention
that it's only meant for users of Emacs 29 and above.
* test/lisp/erc/erc-tests.el (erc-setup-buffer--custom-action): Add
simplistic test case for example in manual.
| -rw-r--r-- | doc/misc/erc.texi | 11 | ||||
| -rw-r--r-- | test/lisp/erc/erc-tests.el | 30 |
2 files changed, 36 insertions, 5 deletions
diff --git a/doc/misc/erc.texi b/doc/misc/erc.texi index 6d7785a9b54..3297d8b17f0 100644 --- a/doc/misc/erc.texi +++ b/doc/misc/erc.texi | |||
| @@ -1803,10 +1803,11 @@ Observe that ERC supplies the names of buffer-display options as | |||
| 1803 | the symbols @samp{erc-tls} or @samp{url}, the full lineup of which are | 1803 | the symbols @samp{erc-tls} or @samp{url}, the full lineup of which are |
| 1804 | listed below. | 1804 | listed below. |
| 1805 | 1805 | ||
| 1806 | In this second example, the user writes three predicates that somewhat | 1806 | In this second example, for Emacs 29 and above, the user writes three |
| 1807 | resemble the ``@code{display-buffer}-like'' function above. These too | 1807 | predicates that somewhat resemble the ``@code{display-buffer}-like'' |
| 1808 | look for @var{action} alist keys sharing the names of buffer-display | 1808 | function above. These too look for @var{action} alist keys sharing |
| 1809 | options (and, in one case, a module's minor mode). | 1809 | the names of ERC's buffer-display options (and, in one case, a |
| 1810 | module's minor mode). | ||
| 1810 | 1811 | ||
| 1811 | @lisp | 1812 | @lisp |
| 1812 | (defun my-erc-disp-entry-p (_ action) | 1813 | (defun my-erc-disp-entry-p (_ action) |
| @@ -1821,7 +1822,7 @@ options (and, in one case, a module's minor mode). | |||
| 1821 | 1822 | ||
| 1822 | (defun my-erc-disp-chan-p (_ action) | 1823 | (defun my-erc-disp-chan-p (_ action) |
| 1823 | (or (assq 'erc-autojoin-mode action) | 1824 | (or (assq 'erc-autojoin-mode action) |
| 1824 | (and (memq (cdr (assq 'erc-buffer-display alist)) 'JOIN) | 1825 | (and (eq (cdr (assq 'erc-buffer-display action)) 'JOIN) |
| 1825 | (member (erc-default-target) '("#emacs" "#fsf"))))) | 1826 | (member (erc-default-target) '("#emacs" "#fsf"))))) |
| 1826 | @end lisp | 1827 | @end lisp |
| 1827 | 1828 | ||
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 3b278959dc1..05d45b2d027 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el | |||
| @@ -560,6 +560,36 @@ | |||
| 560 | (pop calls))) | 560 | (pop calls))) |
| 561 | (should-not calls))) | 561 | (should-not calls))) |
| 562 | 562 | ||
| 563 | ;; Mimic simplistic version of example in "(erc) display-buffer". | ||
| 564 | (when (>= emacs-major-version 29) | ||
| 565 | (let ((proc erc-server-process)) | ||
| 566 | (with-temp-buffer | ||
| 567 | (should-not (eq (window-buffer) (current-buffer))) | ||
| 568 | (erc-mode) | ||
| 569 | (setq erc-server-process proc) | ||
| 570 | |||
| 571 | (cl-letf (((symbol-function 'erc--test-fun-p) | ||
| 572 | (lambda (buf action) | ||
| 573 | (should (eql 1 (alist-get 'erc-buffer-display action))) | ||
| 574 | (push (cons 'erc--test-fun-p buf) calls))) | ||
| 575 | ((symbol-function 'action-fn) | ||
| 576 | (lambda (buf action) | ||
| 577 | (should (eql 1 (alist-get 'erc-buffer-display action))) | ||
| 578 | (should (eql 42 (alist-get 'foo action))) | ||
| 579 | (push (cons 'action-fn buf) calls) | ||
| 580 | (selected-window)))) | ||
| 581 | |||
| 582 | (let ((erc--display-context '((erc-buffer-display . 1))) | ||
| 583 | (display-buffer-alist | ||
| 584 | `(((and (major-mode . erc-mode) erc--test-fun-p) | ||
| 585 | action-fn (foo . 42)))) | ||
| 586 | (erc-buffer-display 'display-buffer)) | ||
| 587 | |||
| 588 | (erc-setup-buffer (current-buffer)) | ||
| 589 | (should (equal 'action-fn (car (pop calls)))) | ||
| 590 | (should (equal 'erc--test-fun-p (car (pop calls)))) | ||
| 591 | (should-not calls)))))) | ||
| 592 | |||
| 563 | (should (eq owin (selected-window))) | 593 | (should (eq owin (selected-window))) |
| 564 | (should (eq obuf (window-buffer))))) | 594 | (should (eq obuf (window-buffer))))) |
| 565 | 595 | ||