summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorF. Jason Park <jp@neverwas.me>2022-12-09 22:00:59 -0800
committerF. Jason Park <jp@neverwas.me>2023-04-08 14:23:51 -0700
commite7992d2adbc50ba8a3b0fb18b9afe22a2a539b1d (patch)
treee61cf2ee00dd7d568326a366e81ac1f0a00ea903 /test
parentba7fe88b782ad516b4cbb5e99fb108f57a9235e2 (diff)
downloademacs-e7992d2adbc50ba8a3b0fb18b9afe22a2a539b1d.tar.gz
Add option to show visual erc-keep-place indicator
* lisp/erc/erc-goodies.el (erc-keep-place-indicator-style, erc-keep-place-indicator-buffer-type, erc-keep-place-indicator-follow): New options for anchoring kept place visually. (erc-keep-place-indicator-line, erc-keep-place-indicator-arrow): New faces. (erc--keep-place-indicator-overlay): New internal variable. (erc--keep-place-indicator-on-window-configuration-change): New function to subscribe to `window-configuration-change-hook' and maybe update kept-place indicator. (erc--keep-place-indicator-setup): New function to initialize buffer for local module `keep-place-indicator'. (erc-keep-place-indicator-mode, erc-keep-place-indicator-enable, erc-keep-place-indicator-disable): New local ERC module. Depends on "parent" module `keep-place'. Like `fill-wrap', this is (for now) also deliberately left out of the widget menu for `erc-modules'. (erc-keep-place-move, erc-keep-place-goto): Add new commands for manually updating and jumping to keep-place indicator. (erc-keep-place): Move `erc--keep-place-overlay' when applicable. * test/lisp/erc/erc-goodies-tests.el (erc-keep-place-indicator-mode): Add test. (Bug#59943.)
Diffstat (limited to 'test')
-rw-r--r--test/lisp/erc/erc-goodies-tests.el81
1 files changed, 81 insertions, 0 deletions
diff --git a/test/lisp/erc/erc-goodies-tests.el b/test/lisp/erc/erc-goodies-tests.el
index 46fcf82401b..a1f53c5bf88 100644
--- a/test/lisp/erc/erc-goodies-tests.el
+++ b/test/lisp/erc/erc-goodies-tests.el
@@ -250,4 +250,85 @@
(when noninteractive
(kill-buffer)))))
+
+;; Among other things, this test also asserts that a local module's
+;; minor-mode toggle is allowed to disable its mode variable as
+;; needed.
+
+(ert-deftest erc-keep-place-indicator-mode ()
+ ;; FIXME remove after adding
+ (unless (fboundp 'erc--initialize-markers)
+ (ert-skip "Missing required function"))
+ (with-current-buffer (get-buffer-create "*erc-keep-place-indicator-mode*")
+ (erc-mode)
+ (erc--initialize-markers (point) nil)
+ (let ((assert-off
+ (lambda ()
+ (should-not erc-keep-place-indicator-mode)
+ (should-not (local-variable-p 'window-configuration-change-hook))
+ (should-not erc--keep-place-indicator-overlay)))
+ (assert-on
+ (lambda ()
+ (should erc--keep-place-indicator-overlay)
+ (should (local-variable-p 'window-configuration-change-hook))
+ (should window-configuration-change-hook)
+ (should erc-keep-place-mode)))
+ ;;
+ erc-insert-pre-hook
+ erc-modules)
+
+ (funcall assert-off)
+
+ (ert-info ("Value t")
+ (should (eq erc-keep-place-indicator-buffer-type t))
+ (erc-keep-place-indicator-mode +1)
+ (funcall assert-on)
+ (goto-char (point-min))
+ (should (search-forward "Enabling" nil t))
+ (should (memq 'keep-place erc-modules)))
+
+ (erc-keep-place-indicator-mode -1)
+ (funcall assert-off)
+
+ (ert-info ("Value `target'")
+ (let ((erc-keep-place-indicator-buffer-type 'target))
+ (erc-keep-place-indicator-mode +1)
+ (funcall assert-off)
+ (setq erc--target (erc--target-from-string "#chan"))
+ (erc-keep-place-indicator-mode +1)
+ (funcall assert-on)))
+
+ (erc-keep-place-indicator-mode -1)
+ (funcall assert-off)
+
+ (ert-info ("Value `server'")
+ (let ((erc-keep-place-indicator-buffer-type 'server))
+ (erc-keep-place-indicator-mode +1)
+ (funcall assert-off)
+ (setq erc--target nil)
+ (erc-keep-place-indicator-mode +1)
+ (funcall assert-on)))
+
+ ;; Populate buffer
+ (erc-display-message nil 'notice (current-buffer)
+ "This buffer is for text that is not saved")
+ (erc-display-message nil 'notice (current-buffer)
+ "and for lisp evaluation")
+ (should (search-forward "saved" nil t))
+ (erc-keep-place-move nil)
+ (goto-char erc-input-marker)
+
+ (ert-info ("Indicator survives reconnect")
+ (let ((erc--server-reconnecting (buffer-local-variables)))
+ (cl-letf (((symbol-function 'erc-server-connect) #'ignore))
+ (erc-open "localhost" 6667 "tester" "Tester" 'connect
+ nil nil nil nil nil "tester" nil)))
+ (funcall assert-on)
+ (should (= (point) erc-input-marker))
+ (goto-char (overlay-start erc--keep-place-indicator-overlay))
+ (should (looking-at (rx "*** This buffer is for text")))))
+
+ (when noninteractive
+ (kill-buffer))))
+
;;; erc-goodies-tests.el ends here