emacs-diffs
[Top][All Lists]
Advanced

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

master db039399ccc 2/2: Fix project-find-regexp in remote projects


From: Dmitry Gutov
Subject: master db039399ccc 2/2: Fix project-find-regexp in remote projects
Date: Fri, 17 May 2024 20:41:00 -0400 (EDT)

branch: master
commit db039399cccd38b767bf6a30ba6c5da593eb69cf
Author: Dmitry Gutov <dmitry@gutov.dev>
Commit: Dmitry Gutov <dmitry@gutov.dev>

    Fix project-find-regexp in remote projects
    
    * lisp/progmodes/xref.el (xref--hits-file-prefix):
    New variable.  Something to prepend to each file name (bug#69233).
    (xref--convert-hits): Use it to also store the "default directory"
    part of the filename conditionally on whether it's remote.
    (xref--collect-matches): Use the new variable here.
---
 lisp/progmodes/xref.el | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 25693d9cbef..534bd930e13 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -2082,15 +2082,17 @@ Such as the current syntax table and the applied syntax 
properties."
 (defvar xref--last-file-buffer nil)
 (defvar xref--temp-buffer-file-name nil)
 (defvar xref--hits-remote-id nil)
+(defvar xref--hits-file-prefix nil)
 
 (defun xref--convert-hits (hits regexp)
-  (let (xref--last-file-buffer
-        (tmp-buffer (generate-new-buffer " *xref-temp*"))
-        (xref--hits-remote-id (if (file-name-absolute-p (cadar hits))
-                                  ;; TODO: Add some test for this.
-                                  (file-remote-p default-directory)
-                                default-directory))
-        (syntax-needed (xref--regexp-syntax-dependent-p regexp)))
+  (let* (xref--last-file-buffer
+         (tmp-buffer (generate-new-buffer " *xref-temp*"))
+         (xref--hits-remote-id (file-remote-p default-directory))
+         (xref--hits-file-prefix (if (and hits (file-name-absolute-p (cadar 
hits)))
+                                     ;; TODO: Add some test for this.
+                                     xref--hits-remote-id
+                                   (expand-file-name default-directory)))
+         (syntax-needed (xref--regexp-syntax-dependent-p regexp)))
     (unwind-protect
         (mapcan (lambda (hit)
                   (xref--collect-matches hit regexp tmp-buffer syntax-needed))
@@ -2099,7 +2101,7 @@ Such as the current syntax table and the applied syntax 
properties."
 
 (defun xref--collect-matches (hit regexp tmp-buffer syntax-needed)
   (pcase-let* ((`(,line ,file ,text) hit)
-               (file (and file (concat xref--hits-remote-id file)))
+               (file (and file (concat xref--hits-file-prefix file)))
                (buf (xref--find-file-buffer file)))
     (if buf
         (with-current-buffer buf



reply via email to

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