diff options
| author | Basil L. Contovounesios | 2023-01-11 16:34:07 +0000 |
|---|---|---|
| committer | Basil L. Contovounesios | 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 emacs-bd094207c76c500f8a3bffe8231d8c6ae0fd0778.zip | |
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. ")) | |||
| 8315 | (remove-hook 'buffer-list-update-hook bluh)))) | 8315 | (remove-hook 'buffer-list-update-hook bluh)))) |
| 8316 | 8316 | ||
| 8317 | (ert-deftest buffer-tests-inhibit-buffer-hooks-indirect () | 8317 | (ert-deftest buffer-tests-inhibit-buffer-hooks-indirect () |
| 8318 | "Indirect buffers do not call `get-buffer-create'." | 8318 | "Test `make-indirect-buffer' argument INHIBIT-BUFFER-HOOKS." |
| 8319 | (dolist (inhibit '(nil t)) | 8319 | (let* ( base run-bluh run-kbh run-kbqf |
| 8320 | (let ((base (get-buffer-create "foo" inhibit))) | 8320 | (bluh (lambda () (setq run-bluh t))) |
| 8321 | (kbh (lambda () (setq run-kbh t))) | ||
| 8322 | (kbqf (lambda () (setq run-kbqf t)))) | ||
| 8323 | (dolist (inhibit-base '(nil t)) | ||
| 8321 | (unwind-protect | 8324 | (unwind-protect |
| 8322 | (dotimes (_i 11) | 8325 | (let (indirect) |
| 8323 | (let* (flag* | 8326 | (setq base (generate-new-buffer " base" inhibit-base)) |
| 8324 | (flag (lambda () (prog1 t (setq flag* t)))) | 8327 | (dolist (inhibit-indirect '(nil t)) |
| 8325 | (indirect (make-indirect-buffer base "foo[indirect]" nil | 8328 | (dotimes (_ 11) |
| 8326 | inhibit))) | 8329 | (unwind-protect |
| 8327 | (unwind-protect | 8330 | (let ((name (generate-new-buffer-name " indirect"))) |
| 8328 | (progn | 8331 | (setq run-bluh nil run-kbh nil run-kbqf nil) |
| 8329 | (with-current-buffer indirect | 8332 | (add-hook 'buffer-list-update-hook bluh) |
| 8330 | (add-hook 'kill-buffer-query-functions flag nil t)) | 8333 | (with-current-buffer |
| 8331 | (kill-buffer indirect) | 8334 | (setq indirect (make-indirect-buffer |
| 8332 | (if inhibit | 8335 | base name nil inhibit-indirect)) |
| 8333 | (should-not flag*) | 8336 | (add-hook 'kill-buffer-hook kbh nil t) |
| 8334 | (should flag*))) | 8337 | (add-hook 'kill-buffer-query-functions kbqf nil t) |
| 8335 | (let (kill-buffer-query-functions) | 8338 | (kill-buffer)) |
| 8339 | (should (xor inhibit-indirect run-bluh)) | ||
| 8340 | (should (xor inhibit-indirect run-kbh)) | ||
| 8341 | (should (xor inhibit-indirect run-kbqf))) | ||
| 8342 | (remove-hook 'buffer-list-update-hook bluh) | ||
| 8336 | (when (buffer-live-p indirect) | 8343 | (when (buffer-live-p indirect) |
| 8337 | (kill-buffer indirect)))))) | 8344 | (kill-buffer indirect)))))) |
| 8338 | (let (kill-buffer-query-functions) | 8345 | (when (buffer-live-p base) |
| 8339 | (when (buffer-live-p base) | 8346 | (kill-buffer base)))))) |
| 8340 | (kill-buffer base))))))) | ||
| 8341 | 8347 | ||
| 8342 | (ert-deftest zero-length-overlays-and-not () | 8348 | (ert-deftest zero-length-overlays-and-not () |
| 8343 | (with-temp-buffer | 8349 | (with-temp-buffer |