unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Matthias Meulien <orontee@gmail.com>
Cc: 39722@debbugs.gnu.org
Subject: bug#39722: Support for bookmark.el in VC directory buffers
Date: Fri, 05 Jun 2020 01:42:09 +0300	[thread overview]
Message-ID: <87img6ihby.fsf@mail.linkov.net> (raw)
In-Reply-To: <4738c0198ff32df9ea59906ef055e68838e921f0.camel@gmail.com> (Matthias Meulien's message of "Fri, 21 Feb 2020 22:19:34 +0100")

> Being able to bookmark VC directory buffers is useful when working on
> multiple projects; The proposed patch implements this on the lines of
> what I read in info.el.

> +(defun vc-dir-bookmark-jump (bmk)
> +  "This implements the `handler' function interface for the record
> +type returned by `vc-dir-bookmark-make-record'."
> +  (let* ((file (bookmark-prop-get bmk 'filename))
> +         (buf (save-window-excursion
> +                 (vc-dir file) (current-buffer))))
> +    (bookmark-default-handler
> +     `("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bmk)))))

While using the new keybinding 'C-x t t' from bug#41691
(instead of adding a new command bookmark-jump-other-tab)
I noticed that vc-dir-bookmark-jump doesn't work with it nicely -
it creates two tabs instead of one new tab.  This is because
'C-x t t' modifies display-buffer-overriding-action
with a function that creates a new tab, but the problem is that
visiting a bookmark with a vc-dir buffer calls display-buffer
*twice*.  A new tab is created for every display-buffer call.

I see that you tried to implement a workaround for this problem
by using (save-window-excursion (vc-dir file) that handles some cases.

Another workaround could fix the tab problem:

diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el
index a86c37c24a..1c5be268f4 100644
--- a/lisp/vc/vc-dir.el
+++ b/lisp/vc/vc-dir.el
@@ -1496,8 +1496,10 @@ vc-dir-bookmark-jump
 This implements the `handler' function interface for the record
 type returned by `vc-dir-bookmark-make-record'."
   (let* ((file (bookmark-prop-get bmk 'filename))
+         (display-buffer-overriding-action '(nil))
          (buf (save-window-excursion
-                 (vc-dir file) (current-buffer))))
+                (vc-dir file)
+                (current-buffer))))
     (bookmark-default-handler
      `("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bmk)))))

But I wonder what could be a proper solution?

The first call of pop-to-buffer is in 'vc-dir':

  (let (pop-up-windows)		      ; based on cvs-examine; bug#6204
    (pop-to-buffer (vc-dir-prepare-status-buffer "*vc-dir*" dir backend)))

(Maybe there should be a separate function 'vc-dir-no-select'
 that doesn't call pop-to-buffer?)

The second call is in bookmark-jump with:

  (bookmark--jump-via bookmark (or display-func 'pop-to-buffer-same-window))

Also in bookmark-bmenu-other-window:

    (bookmark--jump-via bookmark 'switch-to-buffer-other-window)

And in bookmark-bmenu-switch-other-window:

  (let ((bookmark (bookmark-bmenu-bookmark))
	(fun (lambda (b) (display-buffer b t))))
    (bookmark--jump-via bookmark fun))





  parent reply	other threads:[~2020-06-04 22:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-21 21:19 bug#39722: Support for bookmark.el in VC directory buffers Matthias Meulien
2020-05-12 22:46 ` Juri Linkov
2020-05-13  0:35   ` Matthias Meulien
2020-05-20 22:38     ` Juri Linkov
2020-06-04 22:42 ` Juri Linkov [this message]
2020-06-06 23:52   ` Juri Linkov
2020-06-21 23:36     ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87img6ihby.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=39722@debbugs.gnu.org \
    --cc=orontee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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