I have a personal elisp function that performs an multi-directory grep. It uses compilation-start
, which creates a compilation-mode buffer with the results, in which I can press RET
(bound to compile-goto-error
) to jump to the corresponding location.
However, compile-goto-error
always visits the location in another window, leaving the compilation buffer up. Half the time I am just searching for one particular location, so what I would like to do is bind some other key (say C-RET
) to also visit the corresponding location in a buffer, but stay in the current window, replacing the compilation buffer with the location's buffer.
I've traced the relevant execution from compile-goto-error
to next-error-internal
to next-error-function
to compilation-next-error-function
to compilation-find-file
, but can't find a nice place to hook in my differing behavior. Is there a simple way (or, failing that, a complicated one) to create a compile-goto-error
variant that switches to the new buffer in-place in the window that held the compilation buffer?