unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#10469: 24.0.92; find-name-dired quotes characters in output
@ 2012-01-09 21:24 Michael Heerdegen
  2012-01-12  9:09 ` Glenn Morris
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Heerdegen @ 2012-01-09 21:24 UTC (permalink / raw)
  To: 10469

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






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

* bug#10469: 24.0.92; find-name-dired quotes characters in output
       [not found] <mailman.1538.1326144231.15002.bug-gnu-emacs@gnu.org>
@ 2012-01-10  4:21 ` Michael Heerdegen
  0 siblings, 0 replies; 10+ messages in thread
From: Michael Heerdegen @ 2012-01-10  4:21 UTC (permalink / raw)
  To: 10469

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.






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

* bug#10469: 24.0.92; find-name-dired quotes characters in output
  2012-01-09 21:24 Michael Heerdegen
@ 2012-01-12  9:09 ` Glenn Morris
  2012-01-13 15:48   ` Michael Heerdegen
  2012-01-13 23:11   ` Glenn Morris
  0 siblings, 2 replies; 10+ messages in thread
From: Glenn Morris @ 2012-01-12  9:09 UTC (permalink / raw)
  To: michael_heerdegen; +Cc: 10469

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).





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

* bug#10469: 24.0.92; find-name-dired quotes characters in output
  2012-01-12  9:09 ` Glenn Morris
@ 2012-01-13 15:48   ` Michael Heerdegen
  2012-01-13 23:11   ` Glenn Morris
  1 sibling, 0 replies; 10+ messages in thread
From: Michael Heerdegen @ 2012-01-13 15:48 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 10469

Glenn Morris <rgm@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.





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

* bug#10469: 24.0.92; find-name-dired quotes characters in output
  2012-01-12  9:09 ` Glenn Morris
  2012-01-13 15:48   ` Michael Heerdegen
@ 2012-01-13 23:11   ` Glenn Morris
  2012-01-14  0:54     ` Michael Heerdegen
  1 sibling, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2012-01-13 23:11 UTC (permalink / raw)
  To: 10469-done

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.





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

* bug#10469: 24.0.92; find-name-dired quotes characters in output
  2012-01-13 23:11   ` Glenn Morris
@ 2012-01-14  0:54     ` Michael Heerdegen
  2012-01-14  2:10       ` Glenn Morris
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Heerdegen @ 2012-01-14  0:54 UTC (permalink / raw)
  To: 10469

Glenn Morris <rgm@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.





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

* bug#10469: 24.0.92; find-name-dired quotes characters in output
  2012-01-14  0:54     ` Michael Heerdegen
@ 2012-01-14  2:10       ` Glenn Morris
  2012-01-14 16:11         ` Michael Heerdegen
  0 siblings, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2012-01-14  2:10 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 10469

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.





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

* bug#10469: 24.0.92; find-name-dired quotes characters in output
  2012-01-14  2:10       ` Glenn Morris
@ 2012-01-14 16:11         ` Michael Heerdegen
  2012-01-17 22:28           ` Glenn Morris
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Heerdegen @ 2012-01-14 16:11 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 10469

Glenn Morris <rgm@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.





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

* bug#10469: 24.0.92; find-name-dired quotes characters in output
  2012-01-14 16:11         ` Michael Heerdegen
@ 2012-01-17 22:28           ` Glenn Morris
  2012-01-18  0:16             ` Michael Heerdegen
  0 siblings, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2012-01-17 22:28 UTC (permalink / raw)
  To: michael_heerdegen; +Cc: 10469

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.





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

* bug#10469: 24.0.92; find-name-dired quotes characters in output
  2012-01-17 22:28           ` Glenn Morris
@ 2012-01-18  0:16             ` Michael Heerdegen
  0 siblings, 0 replies; 10+ messages in thread
From: Michael Heerdegen @ 2012-01-18  0:16 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 10469

Glenn Morris <rgm@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.





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

end of thread, other threads:[~2012-01-18  0:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.1538.1326144231.15002.bug-gnu-emacs@gnu.org>
2012-01-10  4:21 ` bug#10469: 24.0.92; find-name-dired quotes characters in output Michael Heerdegen
2012-01-09 21:24 Michael Heerdegen
2012-01-12  9:09 ` Glenn Morris
2012-01-13 15:48   ` Michael Heerdegen
2012-01-13 23:11   ` Glenn Morris
2012-01-14  0:54     ` Michael Heerdegen
2012-01-14  2:10       ` Glenn Morris
2012-01-14 16:11         ` Michael Heerdegen
2012-01-17 22:28           ` Glenn Morris
2012-01-18  0:16             ` Michael Heerdegen

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).