Question

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!

Was it helpful?

Solution

I reduce the dired-buffer clutter by hitting a (dired-find-alternate-file) on subdirectories, rather than RET; that recycles the current dired window.

OTHER TIPS

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

Dired+ lets you do this optionally, and it lets you toggle it on/off anytime.

See also http://www.emacswiki.org/emacs/DiredReuseDirectoryBuffer.

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top