我已经使用 emacs 多年,并且习惯于让 emacs 在执行 dired 的同一窗口中打开选定的文件。在最近的修订中,当打开 2 个窗口时执行 dired 时,选定的文件将显示在来自 dired 的备用窗口。如何设置 emacs 使用相同的窗口来显示已死亡的文件(允许我同时查看两个文件 - emacs 过去的工作方式)?
最佳答案
根据上面的评论,在 Dired 中检查 C-hkRET 来查看 RET 绑定(bind)了什么到(或者如果您使用其他 key 则类似)。
dired-find-file
使用 switch-to-buffer
这可能会导致缓冲区在另一个窗口中打开:
If the selected window is the minibuffer window or dedicated to its buffer, use `pop-to-buffer' for displaying the buffer.
不过,这似乎不太可能成为问题。
编辑:啊,你正在使用鼠标。在有关 Emacs 的问题中明确说明这一点通常是件好事,因为大多数 Emacs 用户很少触摸鼠标。
但是,同样的答案也适用:在 dired 中,键入 C-hk,然后键入您正在使用的“键”绑定(bind)(在本例中单击鼠标按钮 1) ,这告诉我们:
----------------- up-event (short click) ----------------
<mouse-1> at that spot is remapped to <mouse-2>, which runs the command dired-mouse-find-file-other-window, which is an interactive compiled Lisp function in `dired.el'.
(dired-mouse-find-file-other-window EVENT)
In Dired, visit the file or directory name you click on.
由于某种原因,没有默认的 dired-mouse-find-file
函数,但以下代码会伪造它:
(add-hook 'dired-mode-hook 'my-dired-mode-hook)
(defun my-dired-mode-hook ()
(local-set-key (kbd "<mouse-2>") 'dired-mouse-find-file))
(defun dired-mouse-find-file (event)
"In Dired, visit the file or directory name you click on."
(interactive "e")
(require 'cl)
(flet ((find-file-other-window
(filename &optional wildcards)
(find-file filename wildcards)))
(dired-mouse-find-file-other-window event)))
关于Emacs 可怕的行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5180496/