aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorGlenn Morris2012-01-13 18:09:28 -0500
committerGlenn Morris2012-01-13 18:09:28 -0500
commit1498536e41ad60bda317e7b02a32c8710ddd1627 (patch)
tree0100c56c4eb21e31e54be685b8dde5e941380905 /lisp
parent6e9ddbb313cf7db66550f93a74cbba12e39e93c0 (diff)
downloademacs-1498536e41ad60bda317e7b02a32c8710ddd1627.tar.gz
emacs-1498536e41ad60bda317e7b02a32c8710ddd1627.zip
dired fix for `ls -b' quoting of spaces (bug#10469)
* lisp/dired.el (dired-switches-escape-p): New function. (dired-insert-directory): Use dired-switches-escape-p. (dired-get-filename): Undo "\ " quoting if needed.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/dired.el16
2 files changed, 18 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index be7c45339fa..6497182cae6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,9 @@
12012-01-13 Glenn Morris <rgm@gnu.org> 12012-01-13 Glenn Morris <rgm@gnu.org>
2 2
3 * dired.el (dired-switches-escape-p): New function.
4 (dired-insert-directory): Use dired-switches-escape-p.
5 (dired-get-filename): Undo "\ " quoting if needed. (Bug#10469)
6
3 * find-dired.el (find-ls-option): Doc fix. (Bug#10262) 7 * find-dired.el (find-ls-option): Doc fix. (Bug#10262)
4 8
52012-01-12 Glenn Morris <rgm@gnu.org> 92012-01-12 Glenn Morris <rgm@gnu.org>
diff --git a/lisp/dired.el b/lisp/dired.el
index 6f2ddbbc73d..42d2c7d7a5a 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -1111,6 +1111,11 @@ BEG..END is the line where the file info is located."
1111 1111
1112(defvar ls-lisp-use-insert-directory-program) 1112(defvar ls-lisp-use-insert-directory-program)
1113 1113
1114(defun dired-switches-escape-p (switches)
1115 "Return non-nil if the string SWITCHES contains -b or --escape."
1116 ;; Do not match things like "--block-size" that happen to contain "b".
1117 (string-match "\\(\\`\\| \\)-[[:alnum:]]*b\\|--escape\\>" switches))
1118
1114(defun dired-insert-directory (dir switches &optional file-list wildcard hdr) 1119(defun dired-insert-directory (dir switches &optional file-list wildcard hdr)
1115 "Insert a directory listing of DIR, Dired style. 1120 "Insert a directory listing of DIR, Dired style.
1116Use SWITCHES to make the listings. 1121Use SWITCHES to make the listings.
@@ -1152,7 +1157,7 @@ see `dired-use-ls-dired' for more details.")
1152 (dired-align-file beg (point)))) 1157 (dired-align-file beg (point))))
1153 (insert-directory dir switches wildcard (not wildcard))) 1158 (insert-directory dir switches wildcard (not wildcard)))
1154 ;; Quote certain characters, unless ls quoted them for us. 1159 ;; Quote certain characters, unless ls quoted them for us.
1155 (if (not (string-match "b" dired-actual-switches)) 1160 (if (not (dired-switches-escape-p dired-actual-switches))
1156 (save-excursion 1161 (save-excursion
1157 (setq end (point-marker)) 1162 (setq end (point-marker))
1158 (goto-char opoint) 1163 (goto-char opoint)
@@ -2099,7 +2104,13 @@ Otherwise, an error occurs in these cases."
2099 ;; with quotation marks in their names. 2104 ;; with quotation marks in their names.
2100 (while (string-match "\\(?:[^\\]\\|\\`\\)\\(\"\\)" file) 2105 (while (string-match "\\(?:[^\\]\\|\\`\\)\\(\"\\)" file)
2101 (setq file (replace-match "\\\"" nil t file 1))) 2106 (setq file (replace-match "\\\"" nil t file 1)))
2102 2107 ;; Unescape any spaces escaped by ls -b (bug#10469).
2108 ;; Other -b quotes, eg \t, \n, work transparently.
2109 (if (dired-switches-escape-p dired-actual-switches)
2110 (let ((start 0))
2111 (while (string-match "\\(\\\\\\) " file start)
2112 (setq file (replace-match "" nil t file 1)
2113 start (1- (match-end 0))))))
2103 (when (eq system-type 'windows-nt) 2114 (when (eq system-type 'windows-nt)
2104 (save-match-data 2115 (save-match-data
2105 (let ((start 0)) 2116 (let ((start 0))
@@ -2107,6 +2118,7 @@ Otherwise, an error occurs in these cases."
2107 (aset file (match-beginning 0) ?/) 2118 (aset file (match-beginning 0) ?/)
2108 (setq start (match-end 0)))))) 2119 (setq start (match-end 0))))))
2109 2120
2121 ;; Hence we don't need to worry about converting `\\' back to `\'.
2110 (setq file (read (concat "\"" file "\""))) 2122 (setq file (read (concat "\"" file "\"")))
2111 ;; The above `read' will return a unibyte string if FILE 2123 ;; The above `read' will return a unibyte string if FILE
2112 ;; contains eight-bit-control/graphic characters. 2124 ;; contains eight-bit-control/graphic characters.