diff options
| author | Dmitry Gutov | 2024-05-18 03:24:56 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2024-05-18 03:39:50 +0300 |
| commit | db039399cccd38b767bf6a30ba6c5da593eb69cf (patch) | |
| tree | 8b9c019afa26257ab7a2c42421e8d752a3520460 | |
| parent | 646b8da4a5ec8b4b4a8e461683ff0786a95d1f85 (diff) | |
| download | emacs-db039399cccd38b767bf6a30ba6c5da593eb69cf.tar.gz emacs-db039399cccd38b767bf6a30ba6c5da593eb69cf.zip | |
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.
| -rw-r--r-- | lisp/progmodes/xref.el | 18 |
1 files 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." | |||
| 2082 | (defvar xref--last-file-buffer nil) | 2082 | (defvar xref--last-file-buffer nil) |
| 2083 | (defvar xref--temp-buffer-file-name nil) | 2083 | (defvar xref--temp-buffer-file-name nil) |
| 2084 | (defvar xref--hits-remote-id nil) | 2084 | (defvar xref--hits-remote-id nil) |
| 2085 | (defvar xref--hits-file-prefix nil) | ||
| 2085 | 2086 | ||
| 2086 | (defun xref--convert-hits (hits regexp) | 2087 | (defun xref--convert-hits (hits regexp) |
| 2087 | (let (xref--last-file-buffer | 2088 | (let* (xref--last-file-buffer |
| 2088 | (tmp-buffer (generate-new-buffer " *xref-temp*")) | 2089 | (tmp-buffer (generate-new-buffer " *xref-temp*")) |
| 2089 | (xref--hits-remote-id (if (file-name-absolute-p (cadar hits)) | 2090 | (xref--hits-remote-id (file-remote-p default-directory)) |
| 2090 | ;; TODO: Add some test for this. | 2091 | (xref--hits-file-prefix (if (and hits (file-name-absolute-p (cadar hits))) |
| 2091 | (file-remote-p default-directory) | 2092 | ;; TODO: Add some test for this. |
| 2092 | default-directory)) | 2093 | xref--hits-remote-id |
| 2093 | (syntax-needed (xref--regexp-syntax-dependent-p regexp))) | 2094 | (expand-file-name default-directory))) |
| 2095 | (syntax-needed (xref--regexp-syntax-dependent-p regexp))) | ||
| 2094 | (unwind-protect | 2096 | (unwind-protect |
| 2095 | (mapcan (lambda (hit) | 2097 | (mapcan (lambda (hit) |
| 2096 | (xref--collect-matches hit regexp tmp-buffer syntax-needed)) | 2098 | (xref--collect-matches hit regexp tmp-buffer syntax-needed)) |
| @@ -2099,7 +2101,7 @@ Such as the current syntax table and the applied syntax properties." | |||
| 2099 | 2101 | ||
| 2100 | (defun xref--collect-matches (hit regexp tmp-buffer syntax-needed) | 2102 | (defun xref--collect-matches (hit regexp tmp-buffer syntax-needed) |
| 2101 | (pcase-let* ((`(,line ,file ,text) hit) | 2103 | (pcase-let* ((`(,line ,file ,text) hit) |
| 2102 | (file (and file (concat xref--hits-remote-id file))) | 2104 | (file (and file (concat xref--hits-file-prefix file))) |
| 2103 | (buf (xref--find-file-buffer file))) | 2105 | (buf (xref--find-file-buffer file))) |
| 2104 | (if buf | 2106 | (if buf |
| 2105 | (with-current-buffer buf | 2107 | (with-current-buffer buf |