return Qnil;
}
-/* Run buffer-list-update-hook if Vrun_hooks is non-nil, and BUF is NULL
- or does not have buffer hooks inhibited. BUF is NULL when called by
- make-indirect-buffer, since it does not inhibit buffer hooks. */
+/* Run buffer-list-update-hook if Vrun_hooks is non-nil and BUF does
+ not have buffer hooks inhibited. */
static void
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);
}
set_buffer_internal_1 (old_b);
}
- run_buffer_list_update_hook (NULL);
+ run_buffer_list_update_hook (b);
return buf;
}
(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)))
+ "Test `make-indirect-buffer' argument INHIBIT-BUFFER-HOOKS."
+ (let* ( base run-bluh run-kbh run-kbqf
+ (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
- (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)
+ (let (indirect)
+ (setq base (generate-new-buffer " base" inhibit-base))
+ (dolist (inhibit-indirect '(nil t))
+ (dotimes (_ 11)
+ (unwind-protect
+ (let ((name (generate-new-buffer-name " indirect")))
+ (setq run-bluh nil run-kbh nil run-kbqf nil)
+ (add-hook 'buffer-list-update-hook bluh)
+ (with-current-buffer
+ (setq indirect (make-indirect-buffer
+ base name nil inhibit-indirect))
+ (add-hook 'kill-buffer-hook kbh nil t)
+ (add-hook 'kill-buffer-query-functions kbqf nil t)
+ (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)
(kill-buffer indirect))))))
- (let (kill-buffer-query-functions)
- (when (buffer-live-p base)
- (kill-buffer base)))))))
+ (when (buffer-live-p base)
+ (kill-buffer base))))))
(ert-deftest zero-length-overlays-and-not ()
(with-temp-buffer