emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master f5640a3 2/2: Merge branch 'master' of git.savannah.gnu.org:/srv/g


From: Eli Zaretskii
Subject: master f5640a3 2/2: Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs
Date: Mon, 19 Jul 2021 12:24:52 -0400 (EDT)

branch: master
commit f5640a3bdf33ca6fef749f5e53a26ed749a6d595
Merge: b2925ad 514398c
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs
---
 doc/lispref/buffers.texi |  4 +++-
 src/buffer.c             | 14 +++++++++++---
 test/src/buffer-tests.el | 25 +++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/doc/lispref/buffers.texi b/doc/lispref/buffers.texi
index 0d31b0b..02bbc67 100644
--- a/doc/lispref/buffers.texi
+++ b/doc/lispref/buffers.texi
@@ -1183,7 +1183,7 @@ buffer.
 the base buffer effectively kills the indirect buffer in that it cannot
 ever again be the current buffer.
 
-@deffn Command make-indirect-buffer base-buffer name &optional clone
+@deffn Command make-indirect-buffer base-buffer name &optional clone 
inhibit-buffer-hooks
 This creates and returns an indirect buffer named @var{name} whose
 base buffer is @var{base-buffer}.  The argument @var{base-buffer} may
 be a live buffer or the name (a string) of an existing buffer.  If
@@ -1199,6 +1199,8 @@ If @var{base-buffer} is an indirect buffer, its base 
buffer is used as
 the base for the new buffer.  If, in addition, @var{clone} is
 non-@code{nil}, the initial state is copied from the actual base
 buffer, not from @var{base-buffer}.
+
+@xref{Creating Buffers} for the meaning of @var{inhibit-buffer-hooks}.
 @end deffn
 
 @deffn Command clone-indirect-buffer newname display-flag &optional norecord
diff --git a/src/buffer.c b/src/buffer.c
index 02ca23e..18c4734 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -781,15 +781,22 @@ fetch_buffer_markers (struct buffer *b)
 
 
 DEFUN ("make-indirect-buffer", Fmake_indirect_buffer, Smake_indirect_buffer,
-       2, 3,
+       2, 4,
        "bMake indirect buffer (to buffer): \nBName of indirect buffer: ",
        doc: /* Create and return an indirect buffer for buffer BASE-BUFFER, 
named NAME.
 BASE-BUFFER should be a live buffer, or the name of an existing buffer.
+
 NAME should be a string which is not the name of an existing buffer.
 Optional argument CLONE non-nil means preserve BASE-BUFFER's state,
 such as major and minor modes, in the indirect buffer.
-CLONE nil means the indirect buffer's state is reset to default values.  */)
-  (Lisp_Object base_buffer, Lisp_Object name, Lisp_Object clone)
+
+CLONE nil means the indirect buffer's state is reset to default values.
+
+If optional argument INHIBIT-BUFFER-HOOKS is non-nil, the new buffer
+does not run the hooks `kill-buffer-hook',
+`kill-buffer-query-functions', and `buffer-list-update-hook'.  */)
+  (Lisp_Object base_buffer, Lisp_Object name, Lisp_Object clone,
+   Lisp_Object inhibit_buffer_hooks)
 {
   Lisp_Object buf, tem;
   struct buffer *b;
@@ -834,6 +841,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 = inhibit_buffer_hooks;
 
   b->newline_cache = 0;
   b->width_run_cache = 0;
diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el
index 123f2e8..2adffc0 100644
--- a/test/src/buffer-tests.el
+++ b/test/src/buffer-tests.el
@@ -1361,4 +1361,29 @@ 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]" 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)
+                  (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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]