1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 14:30:50 -08:00

project--find-regexp-in-files: Support remote files

* lisp/progmodes/project.el (project--find-regexp-in-files):
Support remote files (bug#34343).
This commit is contained in:
Dmitry Gutov 2019-12-26 15:38:53 +02:00
parent 21c3020fce
commit be38e39fcc

View file

@ -450,6 +450,9 @@ pattern to search for."
(status nil) (status nil)
(hits nil) (hits nil)
(xrefs nil) (xrefs nil)
;; Support for remote files.
(dir (file-name-directory (car files)))
(remote-id (file-remote-p dir))
;; 'git ls-files' can output broken symlinks. ;; 'git ls-files' can output broken symlinks.
(command (format "xargs -0 grep %s -snHE -e %s" (command (format "xargs -0 grep %s -snHE -e %s"
(if (and case-fold-search (if (and case-fold-search
@ -457,10 +460,13 @@ pattern to search for."
"-i" "-i"
"") "")
(shell-quote-argument (xref--regexp-to-extended regexp))))) (shell-quote-argument (xref--regexp-to-extended regexp)))))
(when remote-id
(setq files (mapcar #'file-local-name files)))
(with-current-buffer output (with-current-buffer output
(erase-buffer) (erase-buffer)
(with-temp-buffer (with-temp-buffer
(insert (mapconcat #'identity files "\0")) (insert (mapconcat #'identity files "\0"))
(setq default-directory dir)
(setq status (setq status
(project--process-file-region (point-min) (project--process-file-region (point-min)
(point-max) (point-max)
@ -478,7 +484,7 @@ pattern to search for."
(buffer-substring (point-min) (line-end-position)))) (buffer-substring (point-min) (line-end-position))))
(while (re-search-forward grep-re nil t) (while (re-search-forward grep-re nil t)
(push (list (string-to-number (match-string line-group)) (push (list (string-to-number (match-string line-group))
(match-string file-group) (concat remote-id (match-string file-group))
(buffer-substring-no-properties (point) (line-end-position))) (buffer-substring-no-properties (point) (line-end-position)))
hits))) hits)))
(setq xrefs (xref--convert-hits (nreverse hits) regexp)) (setq xrefs (xref--convert-hits (nreverse hits) regexp))