all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Sean Whitton <spwhitton@spwhitton.name>,
	sbaugh@catern.com, 53626@debbugs.gnu.org
Subject: bug#53626: 28.0.91; project-find-regexp (C-x p g) twice results in searching different projects
Date: Mon, 21 Feb 2022 03:55:54 +0200	[thread overview]
Message-ID: <bda7eb38-d892-0910-60b6-272a0bef5812@yandex.ru> (raw)
In-Reply-To: <1b884678-ed62-0b11-7fa9-88393a60d26d@yandex.ru>

On 07.02.2022 05:12, Dmitry Gutov wrote:
>> Maybe we could rename the old buffer to a temp name, then create and
>> fill the new one, then set the old buffer's window's buffer to the new
>> one, and finally kill the old one.  But this is not nice at all.
> 
> Right.

We can also try a lighter-weight hack like below. WDYT?

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 784c745477..082d64aaeb 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -1107,6 +1107,13 @@ xref--analyze
               (cdr pair)))
       alist)))

+(defun xref--ensure-default-directory (dd buffer)
+  ;; We might be in a let-binding which will restore the current value
+  ;; to a previous one (bug#53626).  So do this later.
+  (run-with-timer
+   0 nil
+   (lambda () (with-current-buffer buffer (setq default-directory dd)))))
+
  (defun xref--show-xref-buffer (fetcher alist)
    (cl-assert (functionp fetcher))
    (let* ((xrefs
@@ -1117,7 +1124,7 @@ xref--show-xref-buffer
           (dd default-directory)
           buf)
      (with-current-buffer (get-buffer-create xref-buffer-name)
-      (setq default-directory dd)
+      (xref--ensure-default-directory dd (current-buffer))
        (xref--xref-buffer-mode)
        (xref--show-common-initialize xref-alist fetcher alist)
        (pop-to-buffer (current-buffer))
@@ -1216,7 +1223,7 @@ xref-show-definitions-buffer-at-bottom
                              (assoc-default 'display-action alist)))
       (t
        (with-current-buffer (get-buffer-create xref-buffer-name)
-        (setq default-directory dd)
+        (xref--ensure-default-directory dd (current-buffer))
          (xref--transient-buffer-mode)
          (xref--show-common-initialize (xref--analyze xrefs) fetcher alist)
          (pop-to-buffer (current-buffer)





  reply	other threads:[~2022-02-21  1:55 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-29 19:11 bug#53626: 28.0.91; project-find-regexp (C-x p g) twice results in searching different projects sbaugh
2022-01-30  6:28 ` Sean Whitton
2022-02-03 14:00   ` Dmitry Gutov
2022-02-03 15:19     ` Sean Whitton
2022-02-03 15:41       ` Dmitry Gutov
2022-02-03 23:16         ` Sean Whitton
2022-02-04  2:07           ` Dmitry Gutov
2022-02-04  2:32   ` Dmitry Gutov
2022-02-04  5:32     ` Sean Whitton
2022-02-07  3:12       ` Dmitry Gutov
2022-02-21  1:55         ` Dmitry Gutov [this message]
2022-02-21 23:00           ` Sean Whitton
2022-02-21 23:14             ` Dmitry Gutov
2022-02-22 23:09               ` Sean Whitton
2022-02-23  1:45                 ` Dmitry Gutov
2022-02-23  1:55           ` Dmitry Gutov
2022-02-23  5:36             ` Sean Whitton
2022-02-23 11:41               ` Dmitry Gutov
2022-02-03  3:15 ` Dmitry Gutov
2022-02-03 13:28   ` Spencer Baugh
2022-02-03 13:58     ` Dmitry Gutov

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

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

  git send-email \
    --in-reply-to=bda7eb38-d892-0910-60b6-272a0bef5812@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=53626@debbugs.gnu.org \
    --cc=sbaugh@catern.com \
    --cc=spwhitton@spwhitton.name \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.