[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: xref call project-current in correct buffer

From: Dmitry Gutov
Subject: Re: xref call project-current in correct buffer
Date: Tue, 15 Nov 2022 23:55:34 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2

On 15.11.2022 23:48, Dmitry Gutov wrote:
On 15.11.2022 23:37, Stephen Leake wrote:
+      ;; xref--analyze uses (project-current), so it must be done in
+      ;; the original buffer.
+      (setq xrefs (xref--analyze xrefs))

LGTM, thanks!

Maybe change the comment from "uses" to "can use" (or "might"), because that only happens with the currently default value of xref-file-name-display. Or not. That's a very minor detail.

Actually, how about this one?

The difference is slight, but we don't reuse a variable for a value with different structure, and it mirrors the same variable in related/similar functions in this package.

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 0213ab3cc5..3e04291bc3 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -1230,16 +1230,20 @@ xref-show-definitions-buffer-at-bottom
          (max-height (/ (window-height) 2))
          (size-fun (lambda (window)
                      (fit-window-to-buffer window max-height)))
+         xref-alist
      ((not (cdr xrefs))
       (xref-pop-to-location (car xrefs)
                             (assoc-default 'display-action alist)))
+      ;; Call it here because it can call (project-current), and that
+      ;; might depend on individual buffer, not just directory.
+      (setq xref-alist (xref--analyze xrefs))
       (with-current-buffer (get-buffer-create xref-buffer-name)
         (xref--ensure-default-directory dd (current-buffer))
-        (xref--show-common-initialize (xref--analyze xrefs) fetcher alist)
+        (xref--show-common-initialize xref-alist fetcher alist)
         (pop-to-buffer (current-buffer)
`(display-buffer-in-direction . ((direction . below) (window-height . ,size-fun))))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]