3

我添加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>

如果我在其中一个上按 Enter 键,比如 typelist.cpp:2,它将水平拆分我的缓冲区并在那里打开它,用包含切换指向该文件中的行..有没有办法让它不拆分我的缓冲区,然后在 grep 缓冲区上打开它?这将使我很容易然后杀死缓冲区并退回到 grep 结果..

4

1 回答 1

2

将此添加到您的初始化文件中。

(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)
于 2012-09-02T05:00:25.940 回答