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.
This commit is contained in:
parent
9e7a5d58ee
commit
bd094207c7
2 changed files with 31 additions and 25 deletions
10
src/buffer.c
10
src/buffer.c
|
@ -525,14 +525,14 @@ get_truename_buffer (register Lisp_Object filename)
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Run buffer-list-update-hook if Vrun_hooks is non-nil, and BUF is NULL
|
/* Run buffer-list-update-hook if Vrun_hooks is non-nil and BUF does
|
||||||
or does not have buffer hooks inhibited. BUF is NULL when called by
|
not have buffer hooks inhibited. */
|
||||||
make-indirect-buffer, since it does not inhibit buffer hooks. */
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
run_buffer_list_update_hook (struct buffer *buf)
|
run_buffer_list_update_hook (struct buffer *buf)
|
||||||
{
|
{
|
||||||
if (! (NILP (Vrun_hooks) || (buf && buf->inhibit_buffer_hooks)))
|
eassert (buf);
|
||||||
|
if (! (NILP (Vrun_hooks) || buf->inhibit_buffer_hooks))
|
||||||
call1 (Vrun_hooks, Qbuffer_list_update_hook);
|
call1 (Vrun_hooks, Qbuffer_list_update_hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -907,7 +907,7 @@ does not run the hooks `kill-buffer-hook',
|
||||||
set_buffer_internal_1 (old_b);
|
set_buffer_internal_1 (old_b);
|
||||||
}
|
}
|
||||||
|
|
||||||
run_buffer_list_update_hook (NULL);
|
run_buffer_list_update_hook (b);
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8315,29 +8315,35 @@ dicta sunt, explicabo. "))
|
||||||
(remove-hook 'buffer-list-update-hook bluh))))
|
(remove-hook 'buffer-list-update-hook bluh))))
|
||||||
|
|
||||||
(ert-deftest buffer-tests-inhibit-buffer-hooks-indirect ()
|
(ert-deftest buffer-tests-inhibit-buffer-hooks-indirect ()
|
||||||
"Indirect buffers do not call `get-buffer-create'."
|
"Test `make-indirect-buffer' argument INHIBIT-BUFFER-HOOKS."
|
||||||
(dolist (inhibit '(nil t))
|
(let* ( base run-bluh run-kbh run-kbqf
|
||||||
(let ((base (get-buffer-create "foo" inhibit)))
|
(bluh (lambda () (setq run-bluh t)))
|
||||||
|
(kbh (lambda () (setq run-kbh t)))
|
||||||
|
(kbqf (lambda () (setq run-kbqf t))))
|
||||||
|
(dolist (inhibit-base '(nil t))
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(dotimes (_i 11)
|
(let (indirect)
|
||||||
(let* (flag*
|
(setq base (generate-new-buffer " base" inhibit-base))
|
||||||
(flag (lambda () (prog1 t (setq flag* t))))
|
(dolist (inhibit-indirect '(nil t))
|
||||||
(indirect (make-indirect-buffer base "foo[indirect]" nil
|
(dotimes (_ 11)
|
||||||
inhibit)))
|
(unwind-protect
|
||||||
(unwind-protect
|
(let ((name (generate-new-buffer-name " indirect")))
|
||||||
(progn
|
(setq run-bluh nil run-kbh nil run-kbqf nil)
|
||||||
(with-current-buffer indirect
|
(add-hook 'buffer-list-update-hook bluh)
|
||||||
(add-hook 'kill-buffer-query-functions flag nil t))
|
(with-current-buffer
|
||||||
(kill-buffer indirect)
|
(setq indirect (make-indirect-buffer
|
||||||
(if inhibit
|
base name nil inhibit-indirect))
|
||||||
(should-not flag*)
|
(add-hook 'kill-buffer-hook kbh nil t)
|
||||||
(should flag*)))
|
(add-hook 'kill-buffer-query-functions kbqf nil t)
|
||||||
(let (kill-buffer-query-functions)
|
(kill-buffer))
|
||||||
|
(should (xor inhibit-indirect run-bluh))
|
||||||
|
(should (xor inhibit-indirect run-kbh))
|
||||||
|
(should (xor inhibit-indirect run-kbqf)))
|
||||||
|
(remove-hook 'buffer-list-update-hook bluh)
|
||||||
(when (buffer-live-p indirect)
|
(when (buffer-live-p indirect)
|
||||||
(kill-buffer indirect))))))
|
(kill-buffer indirect))))))
|
||||||
(let (kill-buffer-query-functions)
|
(when (buffer-live-p base)
|
||||||
(when (buffer-live-p base)
|
(kill-buffer base))))))
|
||||||
(kill-buffer base)))))))
|
|
||||||
|
|
||||||
(ert-deftest zero-length-overlays-and-not ()
|
(ert-deftest zero-length-overlays-and-not ()
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
|
|
Loading…
Add table
Reference in a new issue