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)?
问题:
回答1:
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)))
回答2:
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?