]> git.eshelyaron.com Git - emacs.git/commitdiff
Make make-indirect-buffer inherit inhibit-buffer-hook from base buffer
authordickmao <none>
Mon, 19 Jul 2021 16:12:17 +0000 (18:12 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 19 Jul 2021 16:23:11 +0000 (18:23 +0200)
* 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).

src/buffer.c
test/src/buffer-tests.el

index 02ca23eb2dd39fd42207846e7da7307756be5514..a574de16723ee6e48ad0141c75540e7f12508249 100644 (file)
@@ -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;
index 123f2e8eabb4784d131095e5b446ddc8ae2174f1..0161927419cb0805bfecbc82719aa26ddc2de3cc 100644 (file)
@@ -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