Subject: bug#34221: [PATCH] Make project-files work with remote files

From: Felicián Németh <[email-masked]>
Date: Mon, 28 Jan 2019 09:10:25 +0100

> Why that? `shell-command-to-string' works also on remote hosts.

That wasn't clear from the documentation and I haven't tried it out :(
Anyway, I've attached a new, simplified version.
However, now I wonder whether project--remote-file-name would be more
useful if it would derive the remote-id from default-directory.  Or
should I simply eliminate this helper function altogether?

Thanks,
Felicián
From 13554a3b61fb87a3f0d97881d0555049280d42e0 Mon Sep 17 00:00:00 2001
From: Felician Nemeth <[email-masked]>
Date: Mon, 28 Jan 2019 08:57:52 +0100
Subject: [PATCH] Make project-files work with remote files

* lisp/progmodes/project.el (project--file-remote-name): New function.
(project--files-in-directory): Use it to support remote files.
---
 lisp/progmodes/project.el | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 3603e751fe..3635223e30 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -186,12 +186,22 @@ project--find-in-directory
                                   (project--dir-ignores project dir)))
    (or dirs (project-roots project))))
 
+(defun project--file-remote-name (remote-file local-files)
+  "Return LOCAL-FILES as if they were on the system of REMOTE-FILE."
+  (let ((remote-id (file-remote-p remote-file)))
+    (if (not remote-id)
+        local-files
+      (mapcar (lambda (file)
+                (concat remote-id file))
+              local-files))))
+
 (defun project--files-in-directory (dir ignores &optional files)
   (require 'find-dired)
   (defvar find-name-arg)
-  (let ((command (format "%s %s %s -type f %s -print0"
+  (let ((default-directory dir)
+        (command (format "%s %s %s -type f %s -print0"
                          find-program
-                         dir
+                         (file-local-name dir)
                          (xref--find-ignores-arguments
                           ignores
                           (expand-file-name dir))
@@ -205,7 +215,9 @@ project--files-in-directory
                                      " "
                                      (shell-quote-argument ")"))"")
                          )))
-    (split-string (shell-command-to-string command) "\0" t)))
+    (project--file-remote-name
+     dir
+     (split-string (shell-command-to-string command) "\0" t))))
 
 (defgroup project-vc nil
   "Project implementation using the VC package."
-- 
2.11.0