我已将add-to-list 'same-window-buffer-names "*grep*"
添加到我的.emacs中,以便从grep-find
获取输出来自M-x grep find
的同一缓冲区。但在得到grep的输出后,请说:
-*- 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>
如果我在其中一个上输入,比如说typelist.cpp:2,它将水平分割我的缓冲区并在那里打开它,切换指向该文件中的行与include ..有一种方法不是拆分我的缓冲区,然后在grep缓冲区上打开它?这样我就可以轻松杀死缓冲区并重新回到grep结果上。
答案 0 :(得分:2)
将其添加到您的init文件中。
(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)