Subject: Re: 25.0.93; dired-do-find-regexp does not work on Windows even after installing GNU find and grep

From: Kaushal Modi <[email-masked]>
Date: Wed, 04 May 2016 21:14:35 +0000

I have verified the below patch to solve this issue:
Can you please review/fix/commit as needed?

>From a20c0f42dbbecb356b286875b684f01fd25c6ebb Mon Sep 17 00:00:00 2001
From: Kaushal Modi <[email-masked]>
Date: Wed, 4 May 2016 17:06:44 -0400
Subject: [PATCH] Shell escape arguments for find cmd used by xref

* lisp/progmodes/xref.el (xref-collect-matches): When the dir has
  characters like spaces (e.g. /tmp/some dir/), those need to be escaped
  before passing it as an argument to the shell command like `find'.
  The escaping is done using `shell-quote-argument' (bug#23453).
---
 lisp/progmodes/xref.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 62cef23..ff87bc3 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -890,7 +890,7 @@ xref-collect-matches
          (grep-highlight-matches nil)
          (command (xref--rgrep-command (xref--regexp-to-extended regexp)
                                        files
-                                       (expand-file-name dir)
+                                       (shell-quote-argument
(expand-file-name dir))
                                        ignores))
          (buf (get-buffer-create " *xref-grep*"))
          (grep-re (caar grep-regexp-alist))
-- 
2.6.0.rc0.24.gec371ff

On Wed, May 4, 2016 at 4:24 PM Kaushal Modi <[email-masked]> wrote:

> Oh, as it turns out, the bug is there but not related to not finding
> find/grep.
>
> It IS actually finding the find.exe and grep.exe correctly using the
> exec-path and/or (setenv "PATH" ..) hacks.
>
> The problem was that the file was in a path with spaces in it:
>
> C:\Users\kmodi\Desktop\_keep this folder empty\NEWS.txt
>
> When I try using `A' in dired with above file marked and search for
> "Emacs", I get "No matches for: Emacs". Note the spaces in the directory
> name: "_keep this folder empty"
>
> But when I copied NEWS.txt to C:\Users\kmodi\Desktop\NEWS.txt and then
> did the same "Emacs" search using `A' in dired, it worked!
>
> I can recreate this bug in RHEL too!
>
> (1) mkdir -p /tmp/some\ dir
> (2) Download http://git.savannah.gnu.org/cgit/emacs.git/plain/etc/NEWS as
> /tmp/some\ dir/NEWS.txt
> (3) In emacs -Q, use C-x d to open dired in /tmp/some\ dir/
> (4) Mark NEWS.txt using `m' key
> (5) Then I do `A' and search for "Emacs" (or probably anything else too)
> (6) You should get "No matches for: Emacs"
>
> Can you please rename the bug title to "25.0.93; dired-do-find-regexp
> does not work when path contains spaces"?
>
> Blocking bug?
> --
>
> --
> Kaushal Modi
>
-- 

-- 
Kaushal Modi