I added add-to-list 'same-window-buffer-names "*grep*" to my .emacs in order to get output from grep-find to come out in the same buffer I M-x grep find from. But after I get the output of the grep, say:
-*- mode: grep; default-directory: "~/sandbox/" -*-
Grep started at Sat Sep 1 17:01:38
find . -type f -print0 | xargs -0 -e grep -nH -e vector
./main.cpp:4:#include <vector>
./typelist.cpp:2:#include <vector>
./main.cpp.eulerbak:4:#include <vector>
If I hit enter on one of those, say typelist.cpp:2, it will split my buffer horizontally and open it there, switching point to the line in that file with the include..is there a way for it NOT to split my buffer and just open it over the grep buffer? This would make it easy for me to then kill the buffer and fall back on the grep results..
Add this to your init file.
(eval-when-compile (require 'cl))
(defun kill-grep-window ()
(destructuring-bind (window major-mode)
(with-selected-window (next-window (selected-window))
(list (selected-window) major-mode))
(when (eq major-mode 'grep-mode)
(delete-window window))))
(add-hook 'next-error-hook 'kill-grep-window)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With