changeset 10126:b4262885826e

(dired-insert-directory): Quote certain chars with \. (dired-get-filename): Always unquote \ quoting.
author Richard M. Stallman <rms@gnu.org>
date Wed, 07 Dec 1994 10:57:12 +0000
parents 317294dfa695
children 45dc21b49023
files lisp/dired.el
diffstat 1 files changed, 29 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/dired.el	Wed Dec 07 10:25:44 1994 +0000
+++ b/lisp/dired.el	Wed Dec 07 10:57:12 1994 +0000
@@ -540,7 +540,8 @@
   ;; list).
   ;; We expand the file names here because the may have been abbreviated
   ;; in dired-noselect.
-  (let ((opoint (point)))
+  (let ((opoint (point))
+	end)
     (if (consp dir-or-list)
 	(progn
 	  (mapcar
@@ -548,9 +549,20 @@
 						   switches wildcard full-p)))
 	   (cdr dir-or-list)))
       (insert-directory (expand-file-name dir-or-list) switches wildcard full-p))
+    ;; Quote certain characters, unless ls quoted them for us.
+    (cond ((not (string-match "b" dired-actual-switches))
+	   (setq end (point-marker))
+	   (goto-char opoint)
+	   (while (search-forward "\\" end t)
+	     (replace-match "\\\\" nil t))
+	   (goto-char opoint)
+	   (while (search-forward "\^m" end t)
+	     (replace-match "\\015" nil t))
+	   (set-marker end nil)))
     (dired-insert-set-properties opoint (point)))
   (setq dired-directory dir-or-list))
 
+;; Make the file names highlight when the mouse is on them.
 (defun dired-insert-set-properties (beg end)
   (save-excursion
     (goto-char beg)
@@ -1129,25 +1141,22 @@
       (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))))
     ;; nil if no file on this line, but no-error-if-not-filep is t:
-    (if (setq file (and p1 p2 (format "%s" (buffer-substring p1 p2))))
-	;; Check if ls quoted the names, and unquote them.
-	;; Using read to unquote is much faster than substituting
-	;; \007 (4 chars) -> ^G  (1 char) etc. in a lisp loop.
-	(cond ((string-match "b" dired-actual-switches) ; System V ls
-	       ;; This case is about 20% slower than without -b.
-	       (setq file
-		     (read
-		      (concat "\""
-			      ;; some ls -b don't escape quotes, argh!
-			      ;; This is not needed for GNU ls, though.
-			      (or (dired-string-replace-match
-				   "\\([^\\]\\)\"" file "\\1\\\\\"")
-				  file)
-			      "\""))))
-	      ;; If you do this, update dired-insert-subdir-validate too
-	      ;; ((string-match "Q" dired-actual-switches) ; GNU ls
-	      ;;  (setq file (read file)))
-	      ))
+    (if (setq file (and p1 p2 (buffer-substring p1 p2)))
+	(progn
+	  ;; Get rid of the mouse-face property that file names have.
+	  (set-text-properties 0 (length file) nil file)
+	  ;; Unquote names quoted by ls or by dired-insert-directory.
+	  ;; Using read to unquote is much faster than substituting
+	  ;; \007 (4 chars) -> ^G  (1 char) etc. in a lisp loop.
+	  (setq file
+		(read
+		 (concat "\""
+			 ;; some ls -b don't escape quotes, argh!
+			 ;; This is not needed for GNU ls, though.
+			 (or (dired-string-replace-match
+			      "\\([^\\]\\)\"" file "\\1\\\\\"")
+			     file)
+			 "\"")))))
     (if (eq localp 'no-dir)
 	file
       (and file (concat (dired-current-directory localp) file)))))