[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Re[2]: How to open dired bookmarks in the same window
From: |
Drew Adams |
Subject: |
RE: Re[2]: How to open dired bookmarks in the same window |
Date: |
Sun, 28 Oct 2012 10:19:36 -0700 |
> I installed bookmark+ and tried bmkp-dired-jump. But it still
> opens the directory in a new buffer.
Of course it does. `dired' always does that. And `bmkp-dired-jump' invokes
`dired'.
Your request was that jumping to the bookmark open the dir in the same _window_.
Is that not what you see with `bmkp-dired-jump'? It works for me.
If you want the opened Dired buffer to replace the _buffer_ that was current
when you asked to jump to the bookmark, then add a function that kills that
buffer to `bookmark-after-jump-hook'.
It's not clear what you want.
Be aware BTW that in Dired, even when you use `find-alternate-file' to visit a
subdir in the listing, that does not change how the command `dired' works.
For example, if you use Dired+ and you choose to reuse Dired buffers, so that
when you hit RET on a subdir name in Dired the new Dired buffer replaces the one
where you hit RET, that simply makes use of `find-alternate-file' - it does not
invoke command `dired'.
That Dired+ config choice does not change the behavior of command `dired'. So
for example, if you use `C-x d some-dir', the Dired buffer for `some-dir' does
_not_ replace the buffer that was current when you did `C-x d'.
With that Dired+ config choice, RET in Dired does replace the current Dired
buffer with the one for the subdir you hit RET on - but that's not the same
thing as invoking `dired' on it.
Do you really want to kill the current buffer - whatever it might be - when you
jump to a Dired bookmark? If so, then try doing what I suggested above: use
`bookmark-after-jump-hook'.
For example, try this command (with Bookmark+):
(defun foo (bookmark)
(interactive
(let ((alist (bmkp-dired-alist-only)))
(list (bookmark-get-bookmark
(bmkp-read-bookmark-for-type
"Dired" alist nil nil 'bmkp-dired-history)))))
(let ((this-buf (current-buffer)))
(add-hook 'bookmark-after-jump-hook
`(lambda () (kill-buffer ,this-buf)))
(bmkp-jump-1 bookmark 'switch-to-buffer nil)
(remove-hook 'bookmark-after-jump-hook
`(lambda () (kill-buffer ,this-buf)))))
HTH. I expect that you have enough info now to come up with whatever it is you
really want. If not, look in bookmark+-1.el (and perhaps dired+.el) for more
info.