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

From: Michael Heerdegen <[email-masked]>
Date: Sat, 14 Jan 2012 17:11:28 +0100

Glenn Morris <[email-masked]> 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.