unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#34221: [PATCH] Make project-files work with remote files
@ 2019-01-27 12:21 Felicián Németh
  2019-01-28  7:12 ` Michael Albinus
  0 siblings, 1 reply; 17+ messages in thread
From: Felicián Németh @ 2019-01-27 12:21 UTC (permalink / raw)
  To: 34221

[-- Attachment #1: Type: text/plain, Size: 234 bytes --]

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

[-- Attachment #2: 0001-Make-project-files-work-with-remote-files.patch --]
[-- Type: text/x-patch, Size: 2422 bytes --]

From c2c2322b31a42eb674fa72e48de0c8f1a850710f Mon Sep 17 00:00:00 2001
From: Felician Nemeth <felician.nemeth@gmail.com>
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


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2019-02-07 11:14 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-27 12:21 bug#34221: [PATCH] Make project-files work with remote files Felicián Németh
2019-01-28  7:12 ` Michael Albinus
2019-01-28  8:10   ` Felicián Németh
2019-01-28  8:29     ` Michael Albinus
2019-01-30  8:15       ` Felicián Németh
2019-01-30  8:34         ` Michael Albinus
2019-02-01  3:16           ` Dmitry Gutov
2019-02-01  8:14             ` Michael Albinus
2019-02-02  0:10               ` Dmitry Gutov
2019-02-02  8:36                 ` Felicián Németh
2019-02-02  9:18                   ` Michael Albinus
2019-02-02 10:16                     ` Felicián Németh
2019-02-02 11:59                       ` Dmitry Gutov
2019-02-02 12:13                         ` Michael Albinus
2019-02-07 11:05                           ` Dmitry Gutov
2019-02-07 11:14                             ` Michael Albinus
2019-02-02 12:26                       ` Michael Albinus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).