unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Felicián Németh" <felician.nemeth@gmail.com>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 34343@debbugs.gnu.org
Subject: bug#34343: [PATCH] Make project--find-regexp-in-files work with remote files
Date: Fri, 15 Feb 2019 19:53:13 +0100	[thread overview]
Message-ID: <CAGLaV2aNHU0oogayM2HOHCk_Oa8BMtXMRuXK+QS--AHTufU7AA@mail.gmail.com> (raw)
In-Reply-To: <9d65284f-7a64-5e9c-ab02-fbbd1be41689@yandex.ru>

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

On Thu, Feb 14, 2019 at 2:17 AM Dmitry Gutov <dgutov@yandex.ru> wrote:
>
> First of all, I think we might reasonably expect that either all files
> are remote (and on the same host), or none of them are.

OK.  I've attached a new patch following that assumption.
Thanks again.

[-- Attachment #2: 0001-Make-project-find-regexp-in-files-work-with-remote-f.patch --]
[-- Type: text/x-patch, Size: 2084 bytes --]

From 9deb42823fd043b80c8a5e8f8e28d94dd41d7b00 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felici=C3=A1n=20N=C3=A9meth?= <felician.nemeth@gmail.com>
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


  reply	other threads:[~2019-02-15 18:53 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-06  8:18 bug#34343: [PATCH] Make project--find-regexp-in-files work with remote files Felicián Németh
2019-02-14  1:17 ` Dmitry Gutov
2019-02-15 18:53   ` Felicián Németh [this message]
     [not found]     ` <a54e7498-4ead-dd6f-6a2e-3919ab035b23@yandex.ru>
2019-02-27  9:15       ` Michael Albinus
2019-03-06  7:47         ` Felicián Németh
2019-03-06 14:33           ` Dmitry Gutov
2019-03-06 14:44             ` Dmitry Gutov
2019-03-08  8:28               ` Felicián Németh
2019-12-26 14:04                 ` Dmitry Gutov
2019-12-27  8:24                   ` Michael Albinus
2019-12-27 14:18                     ` Dmitry Gutov
2019-12-27 17:57                       ` Michael Albinus
2019-12-28 10:21                         ` Michael Albinus
2019-12-28 14:48                           ` Dmitry Gutov
2019-12-28 18:56                             ` Michael Albinus
2019-12-28 14:46                         ` Dmitry Gutov
2019-12-28 18:46                           ` Michael Albinus
2019-12-29  0:15                             ` Dmitry Gutov
2019-12-29 12:34                               ` Michael Albinus
2019-12-29 13:14                                 ` Dmitry Gutov
2020-01-01 12:29                                   ` Michael Albinus
2020-01-02  1:22                                     ` Dmitry Gutov
2020-01-02 10:48                                       ` Michael Albinus
2020-01-03  0:52                                         ` Dmitry Gutov
2020-01-03  9:28                                           ` Michael Albinus
2020-01-06 14:33                                             ` Dmitry Gutov
2020-01-06 18:48                                               ` Michael Albinus
2020-01-07  3:23                                                 ` Dmitry Gutov
2020-01-07  9:19                                                   ` Michael Albinus
2020-01-07 13:40                                                     ` Dmitry Gutov
2020-01-07 14:29                                                       ` Michael Albinus
2020-01-07 14:34                                                         ` Dmitry Gutov
2021-07-22 13:00                                                           ` Lars Ingebrigtsen
2021-07-24 19:42                                                             ` Dmitry Gutov
2021-07-25  6:41                                                               ` Lars Ingebrigtsen
2020-01-03  0:57                                         ` Dmitry Gutov
2020-01-06 17:29                     ` Felician Nemeth
2020-01-07  3:23                       ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGLaV2aNHU0oogayM2HOHCk_Oa8BMtXMRuXK+QS--AHTufU7AA@mail.gmail.com \
    --to=felician.nemeth@gmail.com \
    --cc=34343@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).