Commit 514398c6 authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen
Browse files

Add inhibit-buffer-hooks to `make-indirect-buffer'

* doc/lispref/buffers.texi (Indirect Buffers): Document it (bug#49160).

* src/buffer.c (Fmake_indirect_buffer): Allow controlling whether
to inhibit buffer hooks.
parent 95e31a1a
...@@ -1183,7 +1183,7 @@ buffer. ...@@ -1183,7 +1183,7 @@ buffer.
the base buffer effectively kills the indirect buffer in that it cannot the base buffer effectively kills the indirect buffer in that it cannot
ever again be the current buffer. 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 This creates and returns an indirect buffer named @var{name} whose
base buffer is @var{base-buffer}. The argument @var{base-buffer} may 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 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 ...@@ -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 the base for the new buffer. If, in addition, @var{clone} is
non-@code{nil}, the initial state is copied from the actual base non-@code{nil}, the initial state is copied from the actual base
buffer, not from @var{base-buffer}. buffer, not from @var{base-buffer}.
@xref{Creating Buffers} for the meaning of @var{inhibit-buffer-hooks}.
@end deffn @end deffn
@deffn Command clone-indirect-buffer newname display-flag &optional norecord @deffn Command clone-indirect-buffer newname display-flag &optional norecord
......
...@@ -781,15 +781,22 @@ fetch_buffer_markers (struct buffer *b) ...@@ -781,15 +781,22 @@ fetch_buffer_markers (struct buffer *b)
DEFUN ("make-indirect-buffer", Fmake_indirect_buffer, Smake_indirect_buffer, DEFUN ("make-indirect-buffer", Fmake_indirect_buffer, Smake_indirect_buffer,
2, 3, 2, 4,
"bMake indirect buffer (to buffer): \nBName of indirect buffer: ", "bMake indirect buffer (to buffer): \nBName of indirect buffer: ",
doc: /* Create and return an indirect buffer for buffer BASE-BUFFER, named NAME. 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. 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. 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, Optional argument CLONE non-nil means preserve BASE-BUFFER's state,
such as major and minor modes, in the indirect buffer. 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; Lisp_Object buf, tem;
struct buffer *b; struct buffer *b;
...@@ -834,7 +841,7 @@ CLONE nil means the indirect buffer's state is reset to default values. */) ...@@ -834,7 +841,7 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
b->pt_byte = b->base_buffer->pt_byte; b->pt_byte = b->base_buffer->pt_byte;
b->begv_byte = b->base_buffer->begv_byte; b->begv_byte = b->base_buffer->begv_byte;
b->zv_byte = b->base_buffer->zv_byte; b->zv_byte = b->base_buffer->zv_byte;
b->inhibit_buffer_hooks = b->base_buffer->inhibit_buffer_hooks; b->inhibit_buffer_hooks = inhibit_buffer_hooks;
b->newline_cache = 0; b->newline_cache = 0;
b->width_run_cache = 0; b->width_run_cache = 0;
......
...@@ -1369,7 +1369,8 @@ with parameters from the *Messages* buffer modification." ...@@ -1369,7 +1369,8 @@ with parameters from the *Messages* buffer modification."
(dotimes (_i 11) (dotimes (_i 11)
(let* (flag* (let* (flag*
(flag (lambda () (prog1 t (setq flag* t)))) (flag (lambda () (prog1 t (setq flag* t))))
(indirect (make-indirect-buffer base "foo[indirect]"))) (indirect (make-indirect-buffer base "foo[indirect]" nil
inhibit)))
(unwind-protect (unwind-protect
(progn (progn
(with-current-buffer indirect (with-current-buffer indirect
......
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