Subject: bug#10469: 24.0.92; find-name-dired quotes characters in output

From: Glenn Morris <[email-masked]>
Date: Thu, 12 Jan 2012 04:09:46 -0500

Michael Heerdegen wrote:

> I create a directory "~/test a".
>
> Now I run
>
>    (find-name-dired "~" "*test*")
>
> In the produced dired buffer, this directory is listed as "test\ a" (with
> the space character quoted).
>
> If I try to visit or find it from dired, I get this error:
>
>   dired-get-file-for-visit: File no longer exists; type `g' to update dired buffer
[...]
> This problem seems to be related to #10262.

I don't think so (I don't think 10262 is a bug; see my comments there).
I think there are a couple of issues here:

1) C-h v dired-listing-switches says "may contain even ... `b'", yet
dired does not seem to handle the -b option of ls:

mkdir /tmp/foo
cd /tmp/foo
mkdir "a b"
emacs -Q --eval '(setq dired-listing-switches "-alb")'
C-x d RET

gives a dired buffer containing "a\ b", which cannot be visited by dired
as you say above. So it seems dired does NOT understand -b, despite what
the doc says.

2) You might think you can do better with find-dired by not using the
default `find -ls', which is equivalent to "ls -dilsb", but by using:

emacs -Q --eval '(setq find-ls-option (cons "-exec ls -dla --dired {} +" "-al"))'

However, this produces a buffer that contains:

  /tmp/foo/:
  find . -exec ls -dla --dired \{\} +
    drwxr-xr-x   3 gm gm       60 Jan 12 00:44 .
    drwxr-xr-x   2 gm gm       40 Jan 12 00:44 a b
  //DIRED//  37 38 76       81
  //DIRED-OPTIONS// --quoting-style=literal
  
  find finished at Thu Jan 12 01:05:36

Ie, it now recognizes the "a b" file correctly, but the buffer contains
extra /DIRED/ guff at the end (because insert-directory normally deals
with that, not dired-mode, and the former has not been called in this
case). That would be easy to remove though.

Also, if you haven't called dired yet in the session, dired-use-ls-dired
will still have the value `unspecified' at this point (maybe this does
not matter).