To prevent creation of a buffer every single time I enter a directory in dired I use this:

(put 'dired-find-alternate-file 'disabled nil)

My problem now is that when I visit a file from dired pressing RET and then kill it, dired buffer is killed too.

Would it be possible to reuse dired buffer only for directories?


Load library Dired+ (dired+.el). Then use C-M-R (aka C-M-S-r) to toggle whether Dired should reuse dired buffers.

If you want to turn this reuse on by default, do this in your init file:

(diredp-toggle-find-file-reuse-dir 1)

If you get used to the fact that a replaces the current (dired) buffer with the selected file/directory, then you're not limited by a default approach; you just use the option you want at the time.


The solution (accepted answer) by Drew of using Dired+ didn't work for me (it was messing with my dired buffers so that only folders/file names appeared, but not all the other info normally in dired buffer. It could be to do with one of my customisations).

I then found another that worked way using dired-simple.el . After downloading the linked file and placing it in your load path, include this in your init file

      (require 'dired-single)

      (defun my-dired-init ()
        "Bunch of stuff to run for dired, either immediately or when it's
        ;; <add other stuff here>
        (define-key dired-mode-map [return] 'dired-single-buffer)
        (define-key dired-mode-map [mouse-1] 'dired-single-buffer-mouse) 
        (define-key dired-mode-map "^"
         (lambda nil (interactive) (dired-single-buffer "..")))))

      ;; if dired's already loaded, then the keymap will be bound
      (if (boundp 'dired-mode-map)
        ;; we're good to go; just add our bindings
        ;; it's not loaded yet, so add our bindings to the load-hook
        (add-hook 'dired-load-hook 'my-dired-init))
  • To resolve the problem you mentioned with dired+, try setting the following: (customize-set-variable 'diredp-hide-details-initially-flag nil) – nispio May 10 '16 at 21:45

I found dired+ solution doesn't work for me, because I use to have multiple windows displaying the same buffer, and when I go folder up or down on any of them the buffer is closed for all the windows. This is why I implemented my own solution.

When changing the buffer for parent or sub buffer, if the buffer is displayed in other windows than don't delete it, otherwise delete it. In other words, when you go from one folder to another it will keep deleting previous buffer that is not used by any window, period.

(defun farynaio/dired-go-up-reuse (&optional dir)
  (let ((new-dir (if dir (expand-file-name dir) (dired-get-file-for-visit)))
              (lambda (w) (and (not (eq w (selected-window))) (eq (current-buffer) (window-buffer w))))
    (if buffer
      (find-file new-dir)
      (find-alternate-file new-dir))))

I bind it in the following way:

(define-key dired-mode-map (kbd "<backspace>") (lambda () (interactive) (farynaio/dired-go-up-reuse "..")))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.