9

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?

5

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

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.

0

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
         loaded."
        ;; <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 "^"
        (function
         (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
        (my-dired-init)
        ;; 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

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.