diff options
| author | Dmitry Gutov | 2019-12-26 15:38:53 +0200 |
|---|---|---|
| committer | Dmitry Gutov | 2019-12-26 16:00:06 +0200 |
| commit | be38e39fccab7c2f8e86c59ffb9c022d3d5b9382 (patch) | |
| tree | 4371b36810863d16aef11a9ace82a614da34efa3 | |
| parent | 21c3020fcec0a32122d2680a391864a75393031b (diff) | |
| download | emacs-be38e39fccab7c2f8e86c59ffb9c022d3d5b9382.tar.gz emacs-be38e39fccab7c2f8e86c59ffb9c022d3d5b9382.zip | |
project--find-regexp-in-files: Support remote files
* lisp/progmodes/project.el (project--find-regexp-in-files):
Support remote files (bug#34343).
| -rw-r--r-- | lisp/progmodes/project.el | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index e45cb5db127..d5920d10fcf 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el | |||
| @@ -450,6 +450,9 @@ pattern to search for." | |||
| 450 | (status nil) | 450 | (status nil) |
| 451 | (hits nil) | 451 | (hits nil) |
| 452 | (xrefs nil) | 452 | (xrefs nil) |
| 453 | ;; Support for remote files. | ||
| 454 | (dir (file-name-directory (car files))) | ||
| 455 | (remote-id (file-remote-p dir)) | ||
| 453 | ;; 'git ls-files' can output broken symlinks. | 456 | ;; 'git ls-files' can output broken symlinks. |
| 454 | (command (format "xargs -0 grep %s -snHE -e %s" | 457 | (command (format "xargs -0 grep %s -snHE -e %s" |
| 455 | (if (and case-fold-search | 458 | (if (and case-fold-search |
| @@ -457,10 +460,13 @@ pattern to search for." | |||
| 457 | "-i" | 460 | "-i" |
| 458 | "") | 461 | "") |
| 459 | (shell-quote-argument (xref--regexp-to-extended regexp))))) | 462 | (shell-quote-argument (xref--regexp-to-extended regexp))))) |
| 463 | (when remote-id | ||
| 464 | (setq files (mapcar #'file-local-name files))) | ||
| 460 | (with-current-buffer output | 465 | (with-current-buffer output |
| 461 | (erase-buffer) | 466 | (erase-buffer) |
| 462 | (with-temp-buffer | 467 | (with-temp-buffer |
| 463 | (insert (mapconcat #'identity files "\0")) | 468 | (insert (mapconcat #'identity files "\0")) |
| 469 | (setq default-directory dir) | ||
| 464 | (setq status | 470 | (setq status |
| 465 | (project--process-file-region (point-min) | 471 | (project--process-file-region (point-min) |
| 466 | (point-max) | 472 | (point-max) |
| @@ -478,7 +484,7 @@ pattern to search for." | |||
| 478 | (buffer-substring (point-min) (line-end-position)))) | 484 | (buffer-substring (point-min) (line-end-position)))) |
| 479 | (while (re-search-forward grep-re nil t) | 485 | (while (re-search-forward grep-re nil t) |
| 480 | (push (list (string-to-number (match-string line-group)) | 486 | (push (list (string-to-number (match-string line-group)) |
| 481 | (match-string file-group) | 487 | (concat remote-id (match-string file-group)) |
| 482 | (buffer-substring-no-properties (point) (line-end-position))) | 488 | (buffer-substring-no-properties (point) (line-end-position))) |
| 483 | hits))) | 489 | hits))) |
| 484 | (setq xrefs (xref--convert-hits (nreverse hits) regexp)) | 490 | (setq xrefs (xref--convert-hits (nreverse hits) regexp)) |