diff options
author | Basil L. Contovounesios <contovob@tcd.ie> | 2023-01-11 16:34:07 +0000 |
---|---|---|
committer | Basil L. Contovounesios <contovob@tcd.ie> | 2023-01-17 10:38:22 +0000 |
commit | bd094207c76c500f8a3bffe8231d8c6ae0fd0778 (patch) | |
tree | 715c592a1fbd3f8f3f15672fb895d93668956b94 /test/src/buffer-tests.el | |
parent | 9e7a5d58eea664b55e11f2ea5dc7da9ba26d500f (diff) | |
download | emacs-bd094207c76c500f8a3bffe8231d8c6ae0fd0778.tar.gz |
Fix buffer-list-update-hook for indirect buffers
Fmake_indirect_buffer can be told whether to run buffer hooks since
bug#49160, but until now it ran buffer-list-update-hook irrespective
of this.
* src/buffer.c (Fmake_indirect_buffer): Don't run
buffer-list-update-hook when called with a non-nil
INHIBIT-BUFFER-HOOKS argument.
(run_buffer_list_update_hook): Don't special-case NULL argument, as
no such callers remain.
* test/src/buffer-tests.el
(buffer-tests-inhibit-buffer-hooks-indirect): Test whether indirect
buffer hooks are run regardless of whether base buffer hooks are
inhibited. Check that all three buffer hooks, not just
kill-buffer-query-functions, are inhibited.
Diffstat (limited to 'test/src/buffer-tests.el')
-rw-r--r-- | test/src/buffer-tests.el | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el index e5de8f3464a..9d4bbf3e040 100644 --- a/test/src/buffer-tests.el +++ b/test/src/buffer-tests.el @@ -8315,29 +8315,35 @@ dicta sunt, explicabo. ")) (remove-hook 'buffer-list-update-hook bluh)))) (ert-deftest buffer-tests-inhibit-buffer-hooks-indirect () - "Indirect buffers do not call `get-buffer-create'." - (dolist (inhibit '(nil t)) - (let ((base (get-buffer-create "foo" inhibit))) + "Test `make-indirect-buffer' argument INHIBIT-BUFFER-HOOKS." + (let* ( base run-bluh run-kbh run-kbqf + (bluh (lambda () (setq run-bluh t))) + (kbh (lambda () (setq run-kbh t))) + (kbqf (lambda () (setq run-kbqf t)))) + (dolist (inhibit-base '(nil t)) (unwind-protect - (dotimes (_i 11) - (let* (flag* - (flag (lambda () (prog1 t (setq flag* t)))) - (indirect (make-indirect-buffer base "foo[indirect]" nil - inhibit))) - (unwind-protect - (progn - (with-current-buffer indirect - (add-hook 'kill-buffer-query-functions flag nil t)) - (kill-buffer indirect) - (if inhibit - (should-not flag*) - (should flag*))) - (let (kill-buffer-query-functions) + (let (indirect) + (setq base (generate-new-buffer " base" inhibit-base)) + (dolist (inhibit-indirect '(nil t)) + (dotimes (_ 11) + (unwind-protect + (let ((name (generate-new-buffer-name " indirect"))) + (setq run-bluh nil run-kbh nil run-kbqf nil) + (add-hook 'buffer-list-update-hook bluh) + (with-current-buffer + (setq indirect (make-indirect-buffer + base name nil inhibit-indirect)) + (add-hook 'kill-buffer-hook kbh nil t) + (add-hook 'kill-buffer-query-functions kbqf nil t) + (kill-buffer)) + (should (xor inhibit-indirect run-bluh)) + (should (xor inhibit-indirect run-kbh)) + (should (xor inhibit-indirect run-kbqf))) + (remove-hook 'buffer-list-update-hook bluh) (when (buffer-live-p indirect) (kill-buffer indirect)))))) - (let (kill-buffer-query-functions) - (when (buffer-live-p base) - (kill-buffer base))))))) + (when (buffer-live-p base) + (kill-buffer base)))))) (ert-deftest zero-length-overlays-and-not () (with-temp-buffer |