diff options
| author | F. Jason Park | 2022-12-09 22:00:59 -0800 |
|---|---|---|
| committer | F. Jason Park | 2023-04-08 14:23:51 -0700 |
| commit | e7992d2adbc50ba8a3b0fb18b9afe22a2a539b1d (patch) | |
| tree | e61cf2ee00dd7d568326a366e81ac1f0a00ea903 /test | |
| parent | ba7fe88b782ad516b4cbb5e99fb108f57a9235e2 (diff) | |
| download | emacs-e7992d2adbc50ba8a3b0fb18b9afe22a2a539b1d.tar.gz emacs-e7992d2adbc50ba8a3b0fb18b9afe22a2a539b1d.zip | |
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.el | 81 |
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 @@ | |||
| 250 | (when noninteractive | 250 | (when noninteractive |
| 251 | (kill-buffer))))) | 251 | (kill-buffer))))) |
| 252 | 252 | ||
| 253 | |||
| 254 | ;; Among other things, this test also asserts that a local module's | ||
| 255 | ;; minor-mode toggle is allowed to disable its mode variable as | ||
| 256 | ;; needed. | ||
| 257 | |||
| 258 | (ert-deftest erc-keep-place-indicator-mode () | ||
| 259 | ;; FIXME remove after adding | ||
| 260 | (unless (fboundp 'erc--initialize-markers) | ||
| 261 | (ert-skip "Missing required function")) | ||
| 262 | (with-current-buffer (get-buffer-create "*erc-keep-place-indicator-mode*") | ||
| 263 | (erc-mode) | ||
| 264 | (erc--initialize-markers (point) nil) | ||
| 265 | (let ((assert-off | ||
| 266 | (lambda () | ||
| 267 | (should-not erc-keep-place-indicator-mode) | ||
| 268 | (should-not (local-variable-p 'window-configuration-change-hook)) | ||
| 269 | (should-not erc--keep-place-indicator-overlay))) | ||
| 270 | (assert-on | ||
| 271 | (lambda () | ||
| 272 | (should erc--keep-place-indicator-overlay) | ||
| 273 | (should (local-variable-p 'window-configuration-change-hook)) | ||
| 274 | (should window-configuration-change-hook) | ||
| 275 | (should erc-keep-place-mode))) | ||
| 276 | ;; | ||
| 277 | erc-insert-pre-hook | ||
| 278 | erc-modules) | ||
| 279 | |||
| 280 | (funcall assert-off) | ||
| 281 | |||
| 282 | (ert-info ("Value t") | ||
| 283 | (should (eq erc-keep-place-indicator-buffer-type t)) | ||
| 284 | (erc-keep-place-indicator-mode +1) | ||
| 285 | (funcall assert-on) | ||
| 286 | (goto-char (point-min)) | ||
| 287 | (should (search-forward "Enabling" nil t)) | ||
| 288 | (should (memq 'keep-place erc-modules))) | ||
| 289 | |||
| 290 | (erc-keep-place-indicator-mode -1) | ||
| 291 | (funcall assert-off) | ||
| 292 | |||
| 293 | (ert-info ("Value `target'") | ||
| 294 | (let ((erc-keep-place-indicator-buffer-type 'target)) | ||
| 295 | (erc-keep-place-indicator-mode +1) | ||
| 296 | (funcall assert-off) | ||
| 297 | (setq erc--target (erc--target-from-string "#chan")) | ||
| 298 | (erc-keep-place-indicator-mode +1) | ||
| 299 | (funcall assert-on))) | ||
| 300 | |||
| 301 | (erc-keep-place-indicator-mode -1) | ||
| 302 | (funcall assert-off) | ||
| 303 | |||
| 304 | (ert-info ("Value `server'") | ||
| 305 | (let ((erc-keep-place-indicator-buffer-type 'server)) | ||
| 306 | (erc-keep-place-indicator-mode +1) | ||
| 307 | (funcall assert-off) | ||
| 308 | (setq erc--target nil) | ||
| 309 | (erc-keep-place-indicator-mode +1) | ||
| 310 | (funcall assert-on))) | ||
| 311 | |||
| 312 | ;; Populate buffer | ||
| 313 | (erc-display-message nil 'notice (current-buffer) | ||
| 314 | "This buffer is for text that is not saved") | ||
| 315 | (erc-display-message nil 'notice (current-buffer) | ||
| 316 | "and for lisp evaluation") | ||
| 317 | (should (search-forward "saved" nil t)) | ||
| 318 | (erc-keep-place-move nil) | ||
| 319 | (goto-char erc-input-marker) | ||
| 320 | |||
| 321 | (ert-info ("Indicator survives reconnect") | ||
| 322 | (let ((erc--server-reconnecting (buffer-local-variables))) | ||
| 323 | (cl-letf (((symbol-function 'erc-server-connect) #'ignore)) | ||
| 324 | (erc-open "localhost" 6667 "tester" "Tester" 'connect | ||
| 325 | nil nil nil nil nil "tester" nil))) | ||
| 326 | (funcall assert-on) | ||
| 327 | (should (= (point) erc-input-marker)) | ||
| 328 | (goto-char (overlay-start erc--keep-place-indicator-overlay)) | ||
| 329 | (should (looking-at (rx "*** This buffer is for text"))))) | ||
| 330 | |||
| 331 | (when noninteractive | ||
| 332 | (kill-buffer)))) | ||
| 333 | |||
| 253 | ;;; erc-goodies-tests.el ends here | 334 | ;;; erc-goodies-tests.el ends here |