1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-07 08:00:48 -08:00

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.
This commit is contained in:
Dmitry Gutov 2024-05-18 03:24:56 +03:00
parent 646b8da4a5
commit db039399cc

View file

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