aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp
diff options
context:
space:
mode:
authorF. Jason Park2023-09-10 22:55:16 -0700
committerF. Jason Park2023-09-17 16:06:49 -0700
commitef4a3c2a6d8ef854bed066ce25b31ff73e1d7664 (patch)
treefe980929b57df1f281618a7535614ba3033d7934 /test/lisp
parent7d2870dc856790de343a876611837b38ad6adcff (diff)
downloademacs-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.
Diffstat (limited to 'test/lisp')
-rw-r--r--test/lisp/erc/erc-tests.el30
1 files changed, 30 insertions, 0 deletions
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