Subject: bug#34221: closed (Re: bug#34221: [PATCH] Make project-files work with remote files)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 02 Feb 2019 12:28:01 +0000

Your bug report

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

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
34221: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=34221
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#34221: [PATCH] Make project-files work with remote files
From: Michael Albinus <[email-masked]>
To: Felicián Németh <[email-masked]>
Cc: [email-masked], Dmitry Gutov <[email-masked]>
Date: Sat, 02 Feb 2019 13:26:51 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Felicián Németh <[email-masked]> writes:

> Hi Michael,

Hi Felicián,

> Originally, I wanted to avoid this approach, because mapcar iterates
> over the result even if remote-id is nil, but I guess the overhead is
> negligible. I've attached the simplified patch.

Thanks, I've pushed it to the master branch. Closing the bug.

> Thanks,
> Felicián

Best regards, Michael.

Subject: [PATCH] Make project-files work with remote files
From: Felicián Németh <[email-masked]>
To: [email-masked]
Date: Sun, 27 Jan 2019 13:21:04 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

I'd like project-files to work even if the project is located on a
remote system.  The patch attached is my attempt to achieve that.
This is my first contribution to Emacs, so any feedback is welcomed.

Thanks,
Felicián
From c2c2322b31a42eb674fa72e48de0c8f1a850710f Mon Sep 17 00:00:00 2001
From: Felician Nemeth <[email-masked]>
Date: Sun, 27 Jan 2019 13:02:10 +0100
Subject: [PATCH] Make project-files work with remote files

* lisp/progmodes/project.el (project--file-remote-name)
(project--command-to-string): New functions.
(project--files-in-directory): Use them to support remote files.
---
 lisp/progmodes/project.el | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 3603e751fe..89fec2a805 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -186,12 +186,30 @@ 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--command-to-string (command)
+  "Execute shell command COMMAND and return its output as a string.
+Similar to `shell-command-to-string', but calls
+`process-file-shell-command'."
+  (with-temp-buffer
+    (process-file-shell-command command nil t)
+    (buffer-string)))
+
 (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 +223,9 @@ project--files-in-directory
                                      " "
                                      (shell-quote-argument ")"))"")
                          )))
-    (split-string (shell-command-to-string command) "\0" t)))
+    (project--file-remote-name
+     dir
+     (split-string (project--command-to-string command) "\0" t))))
 
 (defgroup project-vc nil
   "Project implementation using the VC package."
-- 
2.11.0