9

I use the following code in .emacs:

(require 'dired+)
(toggle-diredp-find-file-reuse-dir 1)

So it won't create a buffer for every dir I visit. Then I decided to add some ergonomics:

(add-hook 'dired-mode-hook
          (lambda ()
            (define-key dired-mode-map (kbd "C-<up>") 'dired-up-directory)))

So when I click Ctrl-<up> it will move to the parent directory. But it opens the parent dir in a new buffer.

How to make it open in the same buffer?

marcospereira
  • 12,045
  • 3
  • 46
  • 52
user4035
  • 22,508
  • 11
  • 59
  • 94
  • btw there is a typo, the function is toggle-diredp-find-file-reuse-dir, – PuercoPop Jun 21 '13 at 15:05
  • @PuercoPop Where is the typo? `toggle-dired-find-file-reuse-dir` function exists and works, while your function with p doesn't exist in my Emacs. – user4035 Jun 21 '13 at 15:23
  • it doesn't exist in mine and it immediately corrects it to the p variant. What version are you running? pretty weird – PuercoPop Jun 21 '13 at 16:04
  • @PuercoPop GNU Emacs 24.1.1 (i386-mingw-nt5.1.2600) of 2012-06-10 on MARVIN. Here is the Help for this function: toggle-dired-find-file-reuse-dir is an interactive compiled Lisp function in `dired+.el'. (toggle-dired-find-file-reuse-dir FORCE-P) Toggle whether Dired `find-file' commands use alternate file. Non-nil prefix arg FORCE-P => Use alternate file iff FORCE-P >= 0. – user4035 Jun 21 '13 at 16:18
  • 2
    **Note/update:** Since at least 2011 the name of the command has been `toggle-dired-find-file-reuse-dir`, with a **`p`** in `diredp`. There is no such command without the `p`. A typo (no `p`) remained for a while, but it was fixed on 2011/07/01. – Drew Mar 05 '15 at 18:20
  • i did an edit to the post with to add the `p` to it. i wasted a good chunk of time with the cut-and-paste of it for a while before reading the comments. – Martin Serrano Jan 12 '16 at 00:50
  • Possible duplicate of [How do I stop emacs dired mode from opening so many buffers?](http://stackoverflow.com/questions/1839313/how-do-i-stop-emacs-dired-mode-from-opening-so-many-buffers) – lawlist Jan 12 '16 at 03:33

1 Answers1

6

The solution can be found there:

(add-hook 'dired-mode-hook
 (lambda ()
  (define-key dired-mode-map (kbd "C-<up>")
    (lambda () (interactive) (find-alternate-file "..")))
  ; was dired-up-directory
 ))
Sébastien Le Callonnec
  • 26,254
  • 8
  • 67
  • 80