5

I managed to make dired work in a single window, when I am navigating through the file system.

Improving ergonomics, I decided to create bookmarks for my most frequent dirs with short names like: 'lwt', 'eve', etc. But every time I open the bookmark, the new dired buffer is created, even if the old one exists.

How to make it open the bookmark in the existing dired buffer?

Drew
  • 29,895
  • 7
  • 74
  • 104
user4035
  • 22,508
  • 11
  • 59
  • 94

3 Answers3

4

Edit:

The original answer was actually a non-answer. I apologise for not having tested it properly. I will leave it here so other potential answerers aren't misled like I was.

I have meanwhile taken a good look at the source code of bookmark.el and the dired+ modifications don't have any effect on it. By default the bookmark-jump function uses the switch-to-buffer function as its display function. bookmark-jump however has an optional display-func argument, so a possible solution (involving a bit of elisp hacking) would be to create a function that reuses the current dired buffer (based on the dired+ source code) and invoking bookmark-jump with it, and if the concept works, then bind that to a keyboard short-cut.

Original answer:

The behaviour you are observing is just a side effect of the general "create a new buffer when navigating" behaviour of dired. This fact makes this question an almost duplicate of How do I stop emacs dired mode from opening so many buffers?.

Of the solutions proposed there and at the Dired Reuse Directory Buffer Emacs Wiki page, probably the simplest one is installing the Dired+ package and toggling directory buffer reuse with:

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

in your .emacs file.

Community
  • 1
  • 1
Pedro Romano
  • 10,973
  • 4
  • 46
  • 50
  • I already have this line in my .emacs file. It works for everything except for bookmarks opening. – user4035 Oct 26 '12 at 20:01
  • 1
    Yes, I came to the same conclusion. I am now experimenting with elisp and will try to post the code here, when it's working. – user4035 Oct 27 '12 at 16:58
0

If this can help - that's what I use to open my bookmarks in the same buffer.

(defun my-bookmarks-list-same-buffer ()
  "Open *Bookmarks* in current buffer."
  (interactive)
  (bookmark-bmenu-list)
  (switch-to-buffer "*Bookmark List*"))
(global-set-key (kbd "s-b") 'my-bookmarks-list-same-buffer)
Sergey
  • 19,487
  • 13
  • 44
  • 68
0

With Bookmark+, at least, bookmark-jump (C-x j j) to a Dired bookmark does reuse the Dired buffer if it already exists.

Drew
  • 29,895
  • 7
  • 74
  • 104