4

I am following this wiki suggestion to set up Emacs so that, i can move forward and backwards in dired mode without creating new buffers.

Using the a key together with the (put 'dired-find-alternate-file 'disabled nil) setting allows me to move into directories without new buffers.

But the hook for the ^ key mentioned in the wiki is not working for me. Going to previous directory with ^ still opens new buffers.

Here are the settings I am using in my .emacs.d/init.el

; dired settings
(require 'dired-x)
(setq dired-omit-files "^\\.?#\\|^\\.$\\|^\\.\\.$\\|^\\.")
(add-hook 'dired-mode-hook (lambda ()
                             (dired-omit-mode 1)))
(setq dired-listing-switches "-aBhl --group-directories-first")
(put 'dired-find-alternate-file 'disabled nil)
(add-hook 'dired-mode-hook
 (lambda ()
  (define-key dired-mode-map (kbd "^")
    (lambda () (interactive) (find-alternate-file "..")))))
Drew
  • 2,144
z33m
  • 183

1 Answers1

3

Just use Dired+. Use C-M-R to toggle whether to reuse Dired buffers. Put this in your init file if you want to reuse by default:

 (diredp-make-find-file-keys-reuse-dirs)

This also takes care of ^. In sum, no need to code anything - just load Dired+.

Drew
  • 2,144