Emacs 可怕的行为

发布于 2024-10-20 15:42:58 字数 168 浏览 5 评论 0原文

我已经使用 emacs 多年,并且习惯于让 emacs 在执行 dired 的同一窗口中打开选定的文件。在最近的修订中,当在打开 2 个窗口的情况下执行 dired 时,选定的文件将显示在备用窗口中从迪雷德。如何设置 emacs 使用相同的窗口来显示已死亡的文件(允许我同时查看两个文件 - emacs 过去的工作方式)?

I have used emacs for years and am accustomed to having emacs open a selected file in the same window that dired is executed in. In recent revisions, when dired is executed with say 2 windows open, the file selected will be displayed in the alternate window from dired. How can I set up emacs to use the same window to display the file as died (allowing me to look at two files simultaneously--the way emacs used to work)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

老娘不死你永远是小三 2024-10-27 15:42:58

根据上面的评论,在 dired 中检查 ChkRET 来查看 RET 绑定到什么(或者如果您使用另一个密钥,则类似)。

dired-find-file 使用 switch-to-buffer 这可能会导致缓冲区在另一个窗口中打开:

如果所选窗口是迷你缓冲区窗口或专用于
它的缓冲区,使用“pop-to-buffer”来显示缓冲区。

不过,这似乎不太可能成为问题。

编辑:啊,你正在使用鼠标。在有关 Emacs 的问题中明确说明这一点通常是件好事,因为大多数 Emacs 用户很少接触鼠标。

然而,同样的答案也适用:从 dired 中,输入 Chk ,然后输入您正在使用的“键”绑定(在本例中单击鼠标按钮 1),它告诉我们:

----------------- 向上事件(短按)----------------

<鼠标-1>;在该位置被重新映射到,它运行
命令 dired-mouse-find-file-other-window,这是一个交互式命令
在 `dired.el' 中编译了 Lisp 函数。

(定向鼠标查找文件其他窗口事件)

在 Dired 中,访问您单击的文件或目录名称。

由于某种原因,没有默认的 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)))

As per the comments above, check C-hkRET when in dired to see what RET is bound to (or similarly if you are using another key).

dired-find-file uses switch-to-buffer which could cause the buffer to open in another window:

If the selected window is the minibuffer window or dedicated to
its buffer, use `pop-to-buffer' for displaying the buffer.

That seems less likely to be the issue, though.

edit: Ah, you're using the mouse. It's often good to explicitly say that in questions about Emacs, because most Emacs users rarely touch the mouse.

The same answer applies, however: From dired, type C-hk and then the 'key'-binding you are using (in this case clicking mouse button 1), which tells us:

----------------- 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.

There's no default dired-mouse-find-file function for some reason, but the following will fake it:

(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)))
汹涌人海 2024-10-27 15:42:58

在 dired 中的文件上按 Enter 键会在同一窗口中打开该文件。在 dired 中的文件上按 o 将在其他窗口中打开它。您确定没有在 .emacs 中重新绑定这些键吗?

Pressing Enter key on a file in dired opens the file in the same window. Pressing o on a file in dired opens it in other-window. Are you sure you are not rebinding these keys in your .emacs?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文