Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs: how to open dired bookmarks in the same window

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?

like image 291
user4035 Avatar asked Oct 06 '22 04:10

user4035


1 Answers

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.

like image 131
Pedro Romano Avatar answered Oct 13 '22 07:10

Pedro Romano