aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-12-07 10:57:12 +0000
committerRichard M. Stallman1994-12-07 10:57:12 +0000
commit9888aa65fd373ba3d60129f8262f2c1b0ca3261e (patch)
tree62804f6877f4d12b918fbfb4811f322c4a00996f
parentcf7c8463984e064a7a1e3948e31dcbaf920b1d85 (diff)
downloademacs-9888aa65fd373ba3d60129f8262f2c1b0ca3261e.tar.gz
emacs-9888aa65fd373ba3d60129f8262f2c1b0ca3261e.zip
(dired-insert-directory): Quote certain chars with \.
(dired-get-filename): Always unquote \ quoting.
-rw-r--r--lisp/dired.el49
1 files changed, 29 insertions, 20 deletions
diff --git a/lisp/dired.el b/lisp/dired.el
index c7ce5b13cb3..e0303cb4f00 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -540,7 +540,8 @@ If DIRNAME is already in a dired buffer, that buffer is used without refresh."
540 ;; list). 540 ;; list).
541 ;; We expand the file names here because the may have been abbreviated 541 ;; We expand the file names here because the may have been abbreviated
542 ;; in dired-noselect. 542 ;; in dired-noselect.
543 (let ((opoint (point))) 543 (let ((opoint (point))
544 end)
544 (if (consp dir-or-list) 545 (if (consp dir-or-list)
545 (progn 546 (progn
546 (mapcar 547 (mapcar
@@ -548,9 +549,20 @@ If DIRNAME is already in a dired buffer, that buffer is used without refresh."
548 switches wildcard full-p))) 549 switches wildcard full-p)))
549 (cdr dir-or-list))) 550 (cdr dir-or-list)))
550 (insert-directory (expand-file-name dir-or-list) switches wildcard full-p)) 551 (insert-directory (expand-file-name dir-or-list) switches wildcard full-p))
552 ;; Quote certain characters, unless ls quoted them for us.
553 (cond ((not (string-match "b" dired-actual-switches))
554 (setq end (point-marker))
555 (goto-char opoint)
556 (while (search-forward "\\" end t)
557 (replace-match "\\\\" nil t))
558 (goto-char opoint)
559 (while (search-forward "\^m" end t)
560 (replace-match "\\015" nil t))
561 (set-marker end nil)))
551 (dired-insert-set-properties opoint (point))) 562 (dired-insert-set-properties opoint (point)))
552 (setq dired-directory dir-or-list)) 563 (setq dired-directory dir-or-list))
553 564
565;; Make the file names highlight when the mouse is on them.
554(defun dired-insert-set-properties (beg end) 566(defun dired-insert-set-properties (beg end)
555 (save-excursion 567 (save-excursion
556 (goto-char beg) 568 (goto-char beg)
@@ -1129,25 +1141,22 @@ Optional arg NO-ERROR-IF-NOT-FILEP means return nil if no filename on
1129 (if (setq p1 (dired-move-to-filename (not no-error-if-not-filep))) 1141 (if (setq p1 (dired-move-to-filename (not no-error-if-not-filep)))
1130 (setq p2 (dired-move-to-end-of-filename no-error-if-not-filep)))) 1142 (setq p2 (dired-move-to-end-of-filename no-error-if-not-filep))))
1131 ;; nil if no file on this line, but no-error-if-not-filep is t: 1143 ;; nil if no file on this line, but no-error-if-not-filep is t:
1132 (if (setq file (and p1 p2 (format "%s" (buffer-substring p1 p2)))) 1144 (if (setq file (and p1 p2 (buffer-substring p1 p2)))
1133 ;; Check if ls quoted the names, and unquote them. 1145 (progn
1134 ;; Using read to unquote is much faster than substituting 1146 ;; Get rid of the mouse-face property that file names have.
1135 ;; \007 (4 chars) -> ^G (1 char) etc. in a lisp loop. 1147 (set-text-properties 0 (length file) nil file)
1136 (cond ((string-match "b" dired-actual-switches) ; System V ls 1148 ;; Unquote names quoted by ls or by dired-insert-directory.
1137 ;; This case is about 20% slower than without -b. 1149 ;; Using read to unquote is much faster than substituting
1138 (setq file 1150 ;; \007 (4 chars) -> ^G (1 char) etc. in a lisp loop.
1139 (read 1151 (setq file
1140 (concat "\"" 1152 (read
1141 ;; some ls -b don't escape quotes, argh! 1153 (concat "\""
1142 ;; This is not needed for GNU ls, though. 1154 ;; some ls -b don't escape quotes, argh!
1143 (or (dired-string-replace-match 1155 ;; This is not needed for GNU ls, though.
1144 "\\([^\\]\\)\"" file "\\1\\\\\"") 1156 (or (dired-string-replace-match
1145 file) 1157 "\\([^\\]\\)\"" file "\\1\\\\\"")
1146 "\"")))) 1158 file)
1147 ;; If you do this, update dired-insert-subdir-validate too 1159 "\"")))))
1148 ;; ((string-match "Q" dired-actual-switches) ; GNU ls
1149 ;; (setq file (read file)))
1150 ))
1151 (if (eq localp 'no-dir) 1160 (if (eq localp 'no-dir)
1152 file 1161 file
1153 (and file (concat (dired-current-directory localp) file))))) 1162 (and file (concat (dired-current-directory localp) file)))))