From 9deb42823fd043b80c8a5e8f8e28d94dd41d7b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felici=C3=A1n=20N=C3=A9meth?= Date: Fri, 15 Feb 2019 19:45:54 +0100 Subject: [PATCH] Make project--find-regexp-in-files work with remote files * project.el (project--find-regexp-in-files): Handle remote files. --- lisp/progmodes/project.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 533e27be7e..3647029f56 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -390,6 +390,12 @@ project--find-regexp-in-files (status nil) (hits nil) (xrefs nil) + ;; Assuming all files are on the same host. + (dir (file-name-directory (car files))) + (remote-id (file-remote-p dir)) + (local-files (if remote-id + (mapcar #'file-local-name files) + files)) (command (format "xargs -0 grep %s -nHe %s" (if (and case-fold-search (isearch-no-upper-case-p regexp t)) @@ -399,7 +405,8 @@ project--find-regexp-in-files (with-current-buffer output (erase-buffer) (with-temp-buffer - (insert (mapconcat #'identity files "\0")) + (insert (mapconcat #'identity local-files "\0")) + (setq default-directory dir) (setq status (project--process-file-region (point-min) (point-max) @@ -417,7 +424,7 @@ project--find-regexp-in-files (buffer-substring (point-min) (line-end-position)))) (while (re-search-forward grep-re nil t) (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))) hits))) (setq xrefs (xref--convert-hits (nreverse hits) regexp)) -- 2.11.0