Commit 95e31a1a authored by dickmao's avatar dickmao Committed by Lars Ingebrigtsen
Browse files

Make make-indirect-buffer inherit inhibit-buffer-hook from base buffer

* src/buffer.c (Fmake_indirect_buffer):
Match base buffer's inhibit-buffer-hooks.
* test/src/buffer-tests.el (buffer-tests-inhibit-buffer-hooks-indirect):
Add a test (bug#49160).
parent dd70012d
......@@ -834,6 +834,7 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
b->pt_byte = b->base_buffer->pt_byte;
b->begv_byte = b->base_buffer->begv_byte;
b->zv_byte = b->base_buffer->zv_byte;
b->inhibit_buffer_hooks = b->base_buffer->inhibit_buffer_hooks;
b->newline_cache = 0;
b->width_run_cache = 0;
......
......@@ -1361,4 +1361,28 @@ with parameters from the *Messages* buffer modification."
(should run-kbqf))
(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)))
(unwind-protect
(dotimes (_i 11)
(let* (flag*
(flag (lambda () (prog1 t (setq flag* t))))
(indirect (make-indirect-buffer base "foo[indirect]")))
(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)
(when (buffer-live-p indirect)
(kill-buffer indirect))))))
(let (kill-buffer-query-functions)
(when (buffer-live-p base)
(kill-buffer base)))))))
;;; buffer-tests.el ends here
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment