Id like to use a diff on my repository to quickly navigate changes, without keeping the buffer open.
Is it possible to make a function that runs 'Jump to source', and deletes the diff buffer?
(Am looking to make a key-binding, but expect this will involve writing a function)
(delete-window)
or(kill-buffer)
? Both of those functions take arguments so that it is not necessary to be in the target while closing the window or killing the buffer. Look at the tail end of your Jump to source function and see if there is a hook, if so, consider using it. [You can useM-x find-function
to locate the source code.] If not, consider creating a new function incorporating either or both of the above-mentioned functions.diff-goto-source
you will see(pop-to-buffer buf)
, which is the source of your pain. Consider changing that toswitch-to-buffer
orset-window-buffer
. See the doc-strings for each function to see what arguments are applicable.my-diff-goto-source
and rebind the keyboard shortcut to your new function. Or, you could do something like(require 'diff-mode) (defun diff-goto-source (&optional other-file event) ....)
and redefine it in your init.el. If you want to save a split second loading Emacs, consider usingeval-after-load
to redefine the function. If you want to get really fancy, perhaps you could play with advice. Or, you could usecl-letf
to redefinepop-to-buffer
temporarily. Or, you could modifying the behavior ofpop-to-buffer
.