is there a way to have dired operate in a single window so that when I traverse through directories I don't have n number of dired buffers for the intermediate directories? However - if I start another dired buffer in a completely separate directory (from the minibuffer rather than hitting [enter] on a subdirectory in an already open dired instance) I'd like to retain the two separate dired buffers... I guess I'm using ido-dired since I have ido-mode on but I don't know that the solution would be different? Thanks much!
Asked
Active
Viewed 2,020 times
8
-
Sorry y'all, I did Google for this beforehand, I promise! Didn't realize the answer was everywhere. But thanks for all the responses! – hatmatrix Mar 03 '10 at 04:35
-
Duplicate question: http://stackoverflow.com/questions/1839313/how-do-i-stop-emacs-dired-mode-from-opening-so-many-buffers/1839493 – scottfrazer Mar 02 '10 at 11:55
5 Answers
11
http://www.emacswiki.org/emacs/dired-single.el
;;; dired-single.el --- Reuse the current dired buffer to visit another directory... ;;; Commentary: ;; ;; This package provides a way to reuse the current dired buffer to visit ;; another directory (rather than creating a new buffer for the new directory). ;; Optionally, it allows the user to specify a name that all such buffers will ;; have, regardless of the directory they point to...

gnat
- 6,213
- 108
- 53
- 73

Ilya Khaprov
- 2,546
- 14
- 23
2
Dired+ lets you do this optionally, and it lets you toggle it on/off anytime.
See also http://www.emacswiki.org/emacs/DiredReuseDirectoryBuffer.

Drew
- 29,895
- 7
- 74
- 104
1
Like this?
(defadvice dired-find-file (around kill-old-buffer activate)
"When navigate from one dired buffer to another, kill the old one."
(let ((old-buffer (current-buffer))
(new-buffer (dired-get-filename)))
ad-do-it
(kill-buffer old-buffer)
(switch-to-buffer new-buffer)
))

Kilian Foth
- 13,904
- 5
- 39
- 57
1
If you mostly want to have each dired buffer work with various subdirs that are all under a single hierarchy (e.g. one dired buffer for each of several ongoing projects), you can use the built-in i
(dired-maybe-insert-subdir) and k
(dired-do-kill-lines on the header of an inserted subdir to remove it from the buffer) commands. They will let you edit multiple directories inside a single dired buffer. You might want a small custom command and to remap RET
if it is too ingrained in your muscle memory though.

Chris Johnsen
- 214,407
- 26
- 209
- 186