3

M-x debug-on-entry kill-buffer That opens the standard Emacs debugger whenever kill-buffer is invoked. It doesn't matter that it's a built-in (primitive, not coded in Lisp). See the Elisp manual, nodes Function Debugging and Using Debugger.


1

Another approach (depending on your needs) is to use the kill-buffer-query-functions hook to prevent specific buffers from being killed regardless of how kill-buffer is invoked. I use my own small library to prevent certain buffers from being killed but there are various other examples out there. With this approach you can keep your kill-other-buffers ...


1

Per the comments, you can simply delq the "one more buffer" you wish to exclude. You would be deleting it from the list which was returned by the initial delq form: (delq (get-buffer "init.el") (delq (current-buffer) (buffer-list))) You can, of course, generalise this to act on some arbitrary list of exclusions: (...


1

This will not affect the global variable scope (let ((kill-buffer-query-functions nil)) (kill-buffer "*Python*"))


Only top voted, non community-wiki answers of a minimum length are eligible