Emacs Dired Behavior

空扰寡人 提交于 2019-12-04 11:59:40

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

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?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!