GNU bug report logs - #10469
24.0.92; find-name-dired quotes characters in output

Previous Next

Package: emacs;

Reported by: michael_heerdegen <at> web.de

Date: Mon, 9 Jan 2012 21:24:02 UTC

Severity: normal

Merged with 10817

Found in versions 24.0.91, 24.0.92

Fixed in version 24.0.93

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 10469 in the body.
You can then email your comments to 10469 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#10469; Package emacs. (Mon, 09 Jan 2012 21:24:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to michael_heerdegen <at> web.de:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 09 Jan 2012 21:24:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.92; find-name-dired quotes characters in output
Date: Mon, 09 Jan 2012 22:24:31 +0100
Hello,

this is on Debian Linux.

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.


- Michael.


In GNU Emacs 24.0.92.1 (i486-pc-linux-gnu, GTK+ Version 3.2.3)
 of 2012-01-05 on zelenka, modified by Debian
 (emacs-snapshot package, version 1:20120105-1)
Windowing system distributor `The X.Org Foundation', version 11.0.11102902
configured using `configure  '--build' 'i486-linux-gnu' '--host' 'i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/24.0.92/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.0.92/site-lisp:/usr/share/emacs/site-lisp' '--without-compress-info' '--with-crt-dir=/usr/lib/i386-linux-gnu/' '--with-x=yes' '--with-x-toolkit=gtk3' '--with-imagemagick=yes' 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2''

Important settings:
  value of $LC_ALL: de_DE.utf8
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: C
  value of $LANG: de_DE.utf8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10469; Package emacs. (Tue, 10 Jan 2012 04:21:02 GMT) Full text and rfc822 format available.

Message #8 received at 10469 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: 10469 <at> debbugs.gnu.org
Subject: Re: bug#10469: 24.0.92; find-name-dired quotes characters in output
Date: Tue, 10 Jan 2012 05:21:35 +0100
Hello again,

Yes, this is resulting from #10262.

After browsing the sources, `find-dired' seems indeed to fail to handle
(cdr find-ls-option).

The find program call is built like that in `find-dired':

  (concat find-program " . "
          (if (string= args "")
   	   ""
   	 (concat
   	  (shell-quote-argument "(")
   	  " " args " "
   	  (shell-quote-argument ")")
   	  " "))
          (if (string-match "\\`\\(.*\\) {} \\(\\\\;\\|+\\)\\'"
   			 (car find-ls-option))
   	   (format "%s %s %s"
   		   (match-string 1 (car find-ls-option))
   		   (shell-quote-argument "{}")
   		   find-exec-terminator)
   	 (car find-ls-option)))

which doesn't handle (cdr find-ls-option).

Also `find-dired-filter' doesn't handle (cdr find-ls-option) completely.

On the other hand `find-dired' has this call:

  (dired-mode dir (cdr find-ls-option))

but since the buffer content comes from find, giving
(cdr find-ls-option) as an argument has no effect here.


- Michael.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10469; Package emacs. (Thu, 12 Jan 2012 09:11:01 GMT) Full text and rfc822 format available.

Message #11 received at 10469 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: michael_heerdegen <at> web.de
Cc: 10469 <at> debbugs.gnu.org
Subject: Re: bug#10469: 24.0.92; find-name-dired quotes characters in output
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).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10469; Package emacs. (Fri, 13 Jan 2012 15:48:01 GMT) Full text and rfc822 format available.

Message #14 received at 10469 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 10469 <at> debbugs.gnu.org
Subject: Re: bug#10469: 24.0.92; find-name-dired quotes characters in output
Date: Fri, 13 Jan 2012 16:48:19 +0100
Glenn Morris <rgm <at> gnu.org> writes:

> I don't think so (I don't think 10262 is a bug; see my comments there).

Ok, I guess you're right, I'm not very familiar with the dired code.

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

Ah, ok, then it is this to be fixed.


Thanks,

Michael.




Reply sent to Glenn Morris <rgm <at> gnu.org>:
You have taken responsibility. (Fri, 13 Jan 2012 23:13:02 GMT) Full text and rfc822 format available.

Notification sent to michael_heerdegen <at> web.de:
bug acknowledged by developer. (Fri, 13 Jan 2012 23:13:02 GMT) Full text and rfc822 format available.

Message #19 received at 10469-done <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 10469-done <at> debbugs.gnu.org
Subject: Re: bug#10469: 24.0.92; find-name-dired quotes characters in output
Date: Fri, 13 Jan 2012 18:11:50 -0500
Version: 24.0.93

Glenn Morris wrote:

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

This should be fixed now, and hence the original issue.

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

This was not relevant. Dired itself does not process --dired,
insert-directory (which is not called by find-dired) does.
And in any case, --dired will not be useful with find, since there
could be multiple DIRED sections depending on how many files are found.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10469; Package emacs. (Sat, 14 Jan 2012 00:55:01 GMT) Full text and rfc822 format available.

Message #22 received at 10469 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: 10469 <at> debbugs.gnu.org
Cc: rgm <at> gnu.org
Subject: Re: bug#10469: 24.0.92; find-name-dired quotes characters in output
Date: Sat, 14 Jan 2012 01:54:57 +0100
Glenn Morris <rgm <at> gnu.org> writes:

> > 1) C-h v dired-listing-switches says "may contain even ... `b'", yet
> > dired does not seem to handle the -b option of ls:
>
> This should be fixed now, and hence the original issue.

Works generally for me, thanks so far.  There is still a problem with
redisplay, however.  Recipe:

1. I have a directory "~/today/!testdir".  It contains a file "my file".

2. I run (find-name-dired "~/today/" "*my*").  Output looks like that:

     /home/micha/today/:
     find . \( -iname \*my\* \) -ls
     ...
     6324228    4 -rw-r--r--   1 micha    users    4 Jan 14 01:25 !testdir/my\ file
     
     find finished at Sat Jan 14 01:32:17

3. Move to "my\ file".  I can visit it, but if I hit l
(`dired-do-redisplay'), the file's line eventually appears like that:

     6324228    4 -rw-r--r--   1 micha    users    4 Jan 14 01:25 !!testdir/my file

I.e. with two `!' characters on the front (!), and without the backslash
before the space char.  If I now try to visit the file again, I get an error.

Dunno if this is the same issue or a different one.  In any case, with Emacs
23.3 I don't have that problem.


Thanks,

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10469; Package emacs. (Sat, 14 Jan 2012 02:11:02 GMT) Full text and rfc822 format available.

Message #25 received at 10469 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 10469 <at> debbugs.gnu.org
Subject: Re: bug#10469: 24.0.92; find-name-dired quotes characters in output
Date: Fri, 13 Jan 2012 21:10:10 -0500
Michael Heerdegen wrote:

> 1. I have a directory "~/today/!testdir".  It contains a file "my file".

Have you tried not doing that...


Anyway, it is somewhat fixed now. You still get "\ " -> " " on
redisplay, due to the "compensate for a bug in ange-ftp" portion of
dired-add-entry.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10469; Package emacs. (Sat, 14 Jan 2012 16:11:02 GMT) Full text and rfc822 format available.

Message #28 received at 10469 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 10469 <at> debbugs.gnu.org
Subject: Re: bug#10469: 24.0.92; find-name-dired quotes characters in output
Date: Sat, 14 Jan 2012 17:11:28 +0100
Glenn Morris <rgm <at> gnu.org> writes:

> Anyway, it is somewhat fixed now. You still get "\ " -> " " on
> redisplay, due to the "compensate for a bug in ange-ftp" portion of
> dired-add-entry.

Ok, this works now, thanks!

Glenn, if you have some more time...  Now that dired respects the -b
option, I wonder if it would be possible to get file names with newline
characters working?

I.e., set dired-listing-switches to "-abl".  Create a directory "a
b" somewhere.  It gets shown as "a\nb" as expected.  But if I try to
visit it from dired, I get this error:

Debugger entered--Lisp error: (error "No subdir-alist in a")
  signal(error ("No subdir-alist in a"))
  error("No subdir-alist in %s" #<buffer a>)
  (or dired-subdir-alist (error "No subdir-alist in %s" (current-buffer)))
  (let ((here (point)) (alist (or dired-subdir-alist (error "No subdir-alist in %s" (current-buffer)))) elt dir) (while alist (setq elt (car alist) dir (car elt) alist (if (<= (dired-get-subdir-min elt) here) nil (cdr alist)))) (if localp (dired-make-relative dir default-directory) dir))
  dired-current-directory()
  (equal (dired-current-directory) "/")
  (cond ((null file) nil) ((eq localp (quote verbatim)) file) ((and (not no-error-if-not-filep) (member file (quote ("." "..")))) (error "Cannot operate on `.' or `..'")) ((and (eq localp (quote no-dir)) already-absolute) (file-name-nondirectory file)) (already-absolute (let ((handler (find-file-name-handler file nil))) (if (and handler (not (get handler (quote safe-magic)))) (concat "/:" file) file))) ((eq localp (quote no-dir)) file) ((equal (dired-current-directory) "/") (setq file (concat (dired-current-directory localp) file)) (let ((handler (find-file-name-handler file nil))) (if (and handler (not (get handler (quote safe-magic)))) (concat "/:" file) file))) (t (concat (dired-current-directory localp) file)))
  (let (case-fold-search file p1 p2 already-absolute) (save-excursion (if (setq p1 (dired-move-to-filename (not no-error-if-not-filep))) (setq p2 (dired-move-to-end-of-filename no-error-if-not-filep)))) (if (setq file (and p1 p2 (buffer-substring p1 p2))) (progn (set-text-properties 0 (length file) nil file) (while (string-match "\\(?:[^\\]\\|\\`\\)\\(\"\\)" file) (setq file (replace-match "\\\"" nil t file 1))) (if (dired-switches-escape-p dired-actual-switches) (let ((start 0) (rep "") (shift -1)) (if (eq localp (quote verbatim)) (setq rep "\\\\" shift 1)) (while (string-match "\\(\\\\\\) " file start) (setq file (replace-match rep nil t file 1) start (+ shift ...))))) (when (eq system-type (quote windows-nt)) (save-match-data (let ((start 0)) (while (string-match "\\\\" file start) (aset file ... 47) (setq start ...))))) (setq file (read (concat "\"" file "\""))) (if (and enable-multibyte-characters (not (multibyte-string-p file))) (setq file (string-to-multibyte file))))) (and file (file-name-absolute-p file) (not (eq (aref file 0) 126)) (setq already-absolute t)) (cond ((null file) nil) ((eq localp (quote verbatim)) file) ((and (not no-error-if-not-filep) (member file (quote ("." "..")))) (error "Cannot operate on `.' or `..'")) ((and (eq localp (quote no-dir)) already-absolute) (file-name-nondirectory file)) (already-absolute (let ((handler (find-file-name-handler file nil))) (if (and handler (not (get handler ...))) (concat "/:" file) file))) ((eq localp (quote no-dir)) file) ((equal (dired-current-directory) "/") (setq file (concat (dired-current-directory localp) file)) (let ((handler (find-file-name-handler file nil))) (if (and handler (not (get handler ...))) (concat "/:" file) file))) (t (concat (dired-current-directory localp) file))))
  dired-get-filename(nil t)
  (or (dired-get-filename nil t) "")
  (file-name-nondirectory (or (dired-get-filename nil t) ""))
  (string-match dired-trivial-filenames (file-name-nondirectory (or (dired-get-filename nil t) "")))
  (and (not (eobp)) (string-match dired-trivial-filenames (file-name-nondirectory (or (dired-get-filename nil t) ""))))
  (while (and (not (eobp)) (string-match dired-trivial-filenames (file-name-nondirectory (or (dired-get-filename nil t) "")))) (forward-line 1) (dired-move-to-filename))
  (if (stringp dired-trivial-filenames) (while (and (not (eobp)) (string-match dired-trivial-filenames (file-name-nondirectory (or (dired-get-filename nil t) "")))) (forward-line 1) (dired-move-to-filename)))
  dired-goto-next-nontrivial-file()
  (if dired-trivial-filenames (dired-goto-next-nontrivial-file))
  dired-initial-position("~/today/a\nb/")
  (if (not new-buffer-p) (cond (switches (setq dired-directory dir-or-list) (dired-sort-other switches)) ((eq dired-auto-revert-buffer t) (revert-buffer)) ((functionp dired-auto-revert-buffer) (when (funcall dired-auto-revert-buffer dirname) (revert-buffer) (message "Changed directory automatically updated"))) ((when (dired-directory-changed-p dirname) (message "%s" (substitute-command-keys "Directory has changed on disk; type \\[revert-buffer] to update Dired"))))) (setq default-directory (file-name-directory dirname)) (or switches (setq switches dired-listing-switches)) (if mode (funcall mode) (dired-mode dir-or-list switches)) (let ((failed t)) (unwind-protect (progn (dired-readin) (setq failed nil)) (if failed (kill-buffer buffer)))) (goto-char (point-min)) (dired-initial-position dirname))
  (let* ((old-buf (current-buffer)) (dirname (if (consp dir-or-list) (car dir-or-list) dir-or-list)) (buffer (dired-find-buffer-nocreate dirname mode)) (new-buffer-p (null buffer))) (or buffer (setq buffer (create-file-buffer (directory-file-name dirname)))) (set-buffer buffer) (if (not new-buffer-p) (cond (switches (setq dired-directory dir-or-list) (dired-sort-other switches)) ((eq dired-auto-revert-buffer t) (revert-buffer)) ((functionp dired-auto-revert-buffer) (when (funcall dired-auto-revert-buffer dirname) (revert-buffer) (message "Changed directory automatically updated"))) ((when (dired-directory-changed-p dirname) (message "%s" (substitute-command-keys "Directory has changed on disk; type \\[revert-buffer] to update Dired"))))) (setq default-directory (file-name-directory dirname)) (or switches (setq switches dired-listing-switches)) (if mode (funcall mode) (dired-mode dir-or-list switches)) (let ((failed t)) (unwind-protect (progn (dired-readin) (setq failed nil)) (if failed (kill-buffer buffer)))) (goto-char (point-min)) (dired-initial-position dirname)) (set-buffer old-buf) buffer)
  dired-internal-noselect("~/today/a\nb/" nil)
  (let (dirname initially-was-dirname) (if (consp dir-or-list) (setq dirname (car dir-or-list)) (setq dirname dir-or-list)) (setq initially-was-dirname (string= (file-name-as-directory dirname) dirname)) (setq dirname (abbreviate-file-name (expand-file-name (directory-file-name dirname)))) (if find-file-visit-truename (setq dirname (file-truename dirname))) (if (or initially-was-dirname (file-directory-p dirname)) (setq dirname (file-name-as-directory dirname))) (if (consp dir-or-list) (setq dir-or-list (cons dirname (cdr dir-or-list))) (setq dir-or-list dirname)) (dired-internal-noselect dir-or-list switches))
  dired-noselect("/home/micha/today/a\nb" nil)
  (switch-to-buffer (dired-noselect dirname switches))
  dired("/home/micha/today/a\nb")
  (or (and (cdr dired-subdir-alist) (dired-goto-subdir file)) (dired file))
  (if (file-directory-p file) (or (and (cdr dired-subdir-alist) (dired-goto-subdir file)) (dired file)) (view-file file))
  (let ((file (dired-get-file-for-visit))) (if (file-directory-p file) (or (and (cdr dired-subdir-alist) (dired-goto-subdir file)) (dired file)) (view-file file)))
  dired-view-file()
  call-interactively(dired-view-file nil nil)

Would be cool if it worked.


Regards,

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10469; Package emacs. (Tue, 17 Jan 2012 22:30:02 GMT) Full text and rfc822 format available.

Message #31 received at 10469 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: michael_heerdegen <at> web.de
Cc: 10469 <at> debbugs.gnu.org
Subject: Re: bug#10469: 24.0.92; find-name-dired quotes characters in output
Date: Tue, 17 Jan 2012 17:28:21 -0500
Michael Heerdegen wrote:

> I.e., set dired-listing-switches to "-abl".  Create a directory "a
> b" somewhere.  It gets shown as "a\nb" as expected.  But if I try to
> visit it from dired, I get this error:

I think this works too now. But Dired obviously has not been designed
with files with newlines in the name in mind, so I would not be
surprised if there are still many places where it gets it wrong.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10469; Package emacs. (Wed, 18 Jan 2012 00:17:01 GMT) Full text and rfc822 format available.

Message #34 received at 10469 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 10469 <at> debbugs.gnu.org
Subject: Re: bug#10469: 24.0.92; find-name-dired quotes characters in output
Date: Wed, 18 Jan 2012 01:16:47 +0100
Glenn Morris <rgm <at> gnu.org> writes:

> > I.e., set dired-listing-switches to "-abl".  Create a directory "a
> > b" somewhere.  It gets shown as "a\nb" as expected.  But if I try to
> > visit it from dired, I get this error:
>
> I think this works too now. But Dired obviously has not been designed
> with files with newlines in the name in mind, so I would not be
> surprised if there are still many places where it gets it wrong.

I made some small tests - worked, even wdired worked!

I've set `dired-listing-switches' in my init file to include -b now, so
that I can test this in the future.


Thanks again,

Michael.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 15 Feb 2012 12:24:05 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 21 Feb 2012 21:44:02 GMT) Full text and rfc822 format available.

Forcibly Merged 10469 10817. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 21 Feb 2012 21:44:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 21 Mar 2012 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 46 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.