diff options
| -rw-r--r-- | lisp/progmodes/xref.el | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 12f32b1cdf6..6a0bcda466f 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el | |||
| @@ -1278,11 +1278,11 @@ Such as the current syntax table and the applied syntax properties." | |||
| 1278 | (in ?b ?B ?< ?> ?w ?W ?_ ?s ?S)) | 1278 | (in ?b ?B ?< ?> ?w ?W ?_ ?s ?S)) |
| 1279 | str))) | 1279 | str))) |
| 1280 | 1280 | ||
| 1281 | (defvar xref--last-visiting-buffer nil) | 1281 | (defvar xref--last-file-buffer nil) |
| 1282 | (defvar xref--temp-buffer-file-name nil) | 1282 | (defvar xref--temp-buffer-file-name nil) |
| 1283 | 1283 | ||
| 1284 | (defun xref--convert-hits (hits regexp) | 1284 | (defun xref--convert-hits (hits regexp) |
| 1285 | (let (xref--last-visiting-buffer | 1285 | (let (xref--last-file-buffer |
| 1286 | (tmp-buffer (generate-new-buffer " *xref-temp*"))) | 1286 | (tmp-buffer (generate-new-buffer " *xref-temp*"))) |
| 1287 | (unwind-protect | 1287 | (unwind-protect |
| 1288 | (cl-mapcan (lambda (hit) (xref--collect-matches hit regexp tmp-buffer)) | 1288 | (cl-mapcan (lambda (hit) (xref--collect-matches hit regexp tmp-buffer)) |
| @@ -1293,7 +1293,7 @@ Such as the current syntax table and the applied syntax properties." | |||
| 1293 | (pcase-let* ((`(,line ,file ,text) hit) | 1293 | (pcase-let* ((`(,line ,file ,text) hit) |
| 1294 | (remote-id (file-remote-p default-directory)) | 1294 | (remote-id (file-remote-p default-directory)) |
| 1295 | (file (and file (concat remote-id file))) | 1295 | (file (and file (concat remote-id file))) |
| 1296 | (buf (xref--find-buffer-visiting file)) | 1296 | (buf (xref--find-file-buffer file)) |
| 1297 | (syntax-needed (xref--regexp-syntax-dependent-p regexp))) | 1297 | (syntax-needed (xref--regexp-syntax-dependent-p regexp))) |
| 1298 | (if buf | 1298 | (if buf |
| 1299 | (with-current-buffer buf | 1299 | (with-current-buffer buf |
| @@ -1349,11 +1349,13 @@ Such as the current syntax table and the applied syntax properties." | |||
| 1349 | matches))) | 1349 | matches))) |
| 1350 | (nreverse matches))) | 1350 | (nreverse matches))) |
| 1351 | 1351 | ||
| 1352 | (defun xref--find-buffer-visiting (file) | 1352 | (defun xref--find-file-buffer (file) |
| 1353 | (unless (equal (car xref--last-visiting-buffer) file) | 1353 | (unless (equal (car xref--last-file-buffer) file) |
| 1354 | (setq xref--last-visiting-buffer | 1354 | (setq xref--last-file-buffer |
| 1355 | ;; `find-buffer-visiting' is considerably slower, | ||
| 1356 | ;; especially on remote files. | ||
| 1355 | (cons file (get-file-buffer file)))) | 1357 | (cons file (get-file-buffer file)))) |
| 1356 | (cdr xref--last-visiting-buffer)) | 1358 | (cdr xref--last-file-buffer)) |
| 1357 | 1359 | ||
| 1358 | (provide 'xref) | 1360 | (provide 'xref) |
| 1359 | 1361 | ||