unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to open dired bookmarks in the same window
@ 2012-10-28  9:25 Ivanov Dmitry
  2012-10-28 14:52 ` Drew Adams
  0 siblings, 1 reply; 4+ messages in thread
From: Ivanov Dmitry @ 2012-10-28  9:25 UTC (permalink / raw)
  To: help-gnu-emacs

I asked a question, that nobody knows the answer:

http://stackoverflow.com/questions/13090190/emacs-how-to-open-dired-bookmarks-in-the-same-window

After inspecting the code of bookmark.el I came to conclusion, that every bookmark has a handler function, that is taken in bookmark-get-handler. I think, that I need to attach find-alternate-file function as a handler to every bookmark-directory. So it will be opened in the same buffer.

But I don't know, how to do it. Any ideas?




^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: How to open dired bookmarks in the same window
  2012-10-28  9:25 How to open dired bookmarks in the same window Ivanov Dmitry
@ 2012-10-28 14:52 ` Drew Adams
  2012-10-28 16:10   ` Re[2]: " Ivanov Dmitry
  0 siblings, 1 reply; 4+ messages in thread
From: Drew Adams @ 2012-10-28 14:52 UTC (permalink / raw)
  To: 'Ivanov Dmitry', help-gnu-emacs

> http://stackoverflow.com/questions/13090190/emacs-how-to-open-
> dired-bookmarks-in-the-same-window
> 
> After inspecting the code of bookmark.el I came to 
> conclusion, that every bookmark has a handler function, that 
> is taken in bookmark-get-handler. I think, that I need to 
> attach find-alternate-file function as a handler to every 
> bookmark-directory. So it will be opened in the same buffer.
> 
> But I don't know, how to do it. Any ideas?

Use Bookmark+.  You do not need to fiddle with the code of the bookmarks
themselves (e.g. the handler function).  It is the bookmark _jump_ command that
says whether to use the same or another window when moving to the bookmark
location.

In Bookmark+:
C-x j d   is `bmkp-dired-jump
C-x 4 j d is `bmkp-dired-jump-other-window'

You apparently want to use `C-x j d'.

(You can of course bind it to another key.  By default, all Bookmark+ jump
commands are on prefix keys `C-x j' and `C-x 4 j'.)

http://www.emacswiki.org/BookmarkPlus




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re[2]: How to open dired bookmarks in the same window
  2012-10-28 14:52 ` Drew Adams
@ 2012-10-28 16:10   ` Ivanov Dmitry
  2012-10-28 17:19     ` Drew Adams
  0 siblings, 1 reply; 4+ messages in thread
From: Ivanov Dmitry @ 2012-10-28 16:10 UTC (permalink / raw)
  To: Drew Adams; +Cc: help-gnu-emacs

I installed bookmark+ and tried bmkp-dired-jump. But it still opens the directory in a new buffer.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Re[2]: How to open dired bookmarks in the same window
  2012-10-28 16:10   ` Re[2]: " Ivanov Dmitry
@ 2012-10-28 17:19     ` Drew Adams
  0 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2012-10-28 17:19 UTC (permalink / raw)
  To: 'Ivanov Dmitry'; +Cc: help-gnu-emacs

> 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.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-10-28 17:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-28  9:25 How to open dired bookmarks in the same window Ivanov Dmitry
2012-10-28 14:52 ` Drew Adams
2012-10-28 16:10   ` Re[2]: " Ivanov Dmitry
2012-10-28 17:19     ` Drew Adams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).