Emacs Dired行为 [英] Emacs Dired Behavior

查看:171
本文介绍了Emacs Dired行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用了emacs多年,并且习惯于在同一个窗口中打开一个选定的文件,直到被执行。在最近的修订中,当被执行时,打开2个窗口,所选的文件将显示在替代窗口从dired。如何设置emacs使用相同的窗口来显示文件是死的(允许我同时查看两个文件 - emacs的工作方式)?

解决方案

根据上述评论,请检查 Ch k RET > RET 被绑定(或类似地,如果你使用另一个键)。



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


如果所选窗口是minibuffer窗口或专用于
其缓冲区,请使用pop-to-buffer显示缓冲区。


虽然这似乎不太可能成为问题。



编辑:啊,你使用的是鼠标。在Emacs的问题中明确表示,通常很好,因为大多数Emacs用户很少会碰到鼠标。



但是,同样的答案适用于:从dired,键入 Ch k ,然后是您正在使用的键绑定(在这种情况下,单击鼠标按钮1),这告诉我们:


----------------- up-event(短命)----------------



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



(dired-mouse-find-file-other-window EVENT )



在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)
在Dired中,访问您点击的文件或目录名。
(interactivee)
(require'cl )
(flet((find-file-other-window
(filename&可选通配符)
(find-file filename通配符)))
(dired-mouse-find -file-other-window事件)))


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)?

解决方案

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

这篇关于Emacs Dired行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆