如何在同一窗口中执行emacs grep find link?

如何在同一窗口中执行emacs grep find link?,emacs,dot-emacs,Emacs,Dot Emacs,当我使用grep-find时,它会打开另一个窗口(框架中的区域),其中包含我可以选择的结果列表。当我选择一个时,它会在与grep-find不同的窗口中打开目标文件 如何使目标文件在与grep结果相同的窗口中打开(用我实际查找的内容替换grep结果窗口) 如何防止grep find打开单独的窗口(让它在当前窗口中打开)。我的目标是在同一个窗口内寻找,找到,走向。我想将它添加到我的.emacs文件中。似乎没有任何方法可以配置编译包来执行您要求的操作。而且没有简单的方法来调整行为。我认为您必须求助于编

当我使用
grep
-
find
时,它会打开另一个窗口(框架中的区域),其中包含我可以选择的结果列表。当我选择一个时,它会在与
grep
-
find
不同的窗口中打开目标文件

如何使目标文件在与
grep
结果相同的窗口中打开(用我实际查找的内容替换
grep
结果窗口)


如何防止grep find打开单独的窗口(让它在当前窗口中打开)。我的目标是在同一个窗口内寻找,找到,走向。我想将它添加到我的
.emacs
文件中。

似乎没有任何方法可以配置
编译
包来执行您要求的操作。而且没有简单的方法来调整行为。我认为您必须求助于编辑实际跳转到错误的函数,您可以在.emacs中添加以下内容(在emacs 23.1中测试):

加载后评估部分仅确保在Emacs定义后重新定义,以便您的更改生效。

您可以添加绑定(例如Alt-m)并执行以下操作

(define-key grep-mode-map "\M-m" (lambda() 
                                   (interactive) 
                                   (compile-goto-error)
                                   (delete-other-windows)
                                   (kill-buffer "*grep*")))

我没有找到一种方法来用自定义函数替换标准的“回车”/“鼠标点击绑定”

还有另一种方法:

(defun eab/compile-goto-error ()
  (interactive)
  (let ((cwc (current-window-configuration)))
    (funcall
     `(lambda ()
        (defun eab/compile-goto-error-internal ()
          (let ((cb (current-buffer))
                (p (point)))
            (set-window-configuration ,cwc)
            (switch-to-buffer cb)
            (goto-char p ))))))
  (compile-goto-error)
  (run-with-timer 0.01 nil 'eab/compile-goto-error-internal))

我有同样的问题,在emacs.stackexchange上找到了这个答案

*grep*
缓冲区中按
o
,将在同一帧中打开位置和文件


我发现这是一个优雅的解决方案,无需删除框架或太多lisp代码,只需挂接到编译模式hook

标准的enter/鼠标单击绑定是缓冲区子字符串的文本属性,您可以编辑该属性,或更改compile添加该属性的方式非常感谢您,Trey!你救了我一天。Trey,有没有可能调整你的功能,让Shift鼠标单击在同一个缓冲区中打开,而不是让相同的鼠标单击行为在单独的窗口中打开?@Ammari不平凡。hack方法是为Shift-mouse提供一个新绑定,以便本地设置变量
(let((使用相同的窗口t))…
,然后发出命令跳转到错误,并在上面的函数中选择所需的行为。
(defun eab/compile-goto-error ()
  (interactive)
  (let ((cwc (current-window-configuration)))
    (funcall
     `(lambda ()
        (defun eab/compile-goto-error-internal ()
          (let ((cb (current-buffer))
                (p (point)))
            (set-window-configuration ,cwc)
            (switch-to-buffer cb)
            (goto-char p ))))))
  (compile-goto-error)
  (run-with-timer 0.01 nil 'eab/compile-goto-error-internal))
(defun my-compile-goto-error-same-window ()
  (interactive)
  (let ((display-buffer-overriding-action
         '((display-buffer-reuse-window
            display-buffer-same-window)
           (inhibit-same-window . nil))))
    (call-interactively #'compile-goto-error)))

(defun my-compilation-mode-hook ()
  (local-set-key (kbd "o") #'my-compile-goto-error-same-window))

(add-hook 'compilation-mode-hook #'my-compilation-mode-hook)