aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/dired.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/dired.el')
-rw-r--r--lisp/dired.el78
1 files changed, 50 insertions, 28 deletions
diff --git a/lisp/dired.el b/lisp/dired.el
index 9d500a9f52d..a056ad679fa 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -920,11 +920,12 @@ periodically reverts at specified time intervals."
920 "Directory has changed on disk; type \\[revert-buffer] to update Dired"))))) 920 "Directory has changed on disk; type \\[revert-buffer] to update Dired")))))
921 ;; Else a new buffer 921 ;; Else a new buffer
922 (setq default-directory 922 (setq default-directory
923 ;; We can do this unconditionally 923 (or (car-safe (insert-directory-wildcard-in-dir-p dirname))
924 ;; because dired-noselect ensures that the name 924 ;; We can do this unconditionally
925 ;; is passed in directory name syntax 925 ;; because dired-noselect ensures that the name
926 ;; if it was the name of a directory at all. 926 ;; is passed in directory name syntax
927 (file-name-directory dirname)) 927 ;; if it was the name of a directory at all.
928 (file-name-directory dirname)))
928 (or switches (setq switches dired-listing-switches)) 929 (or switches (setq switches dired-listing-switches))
929 (if mode (funcall mode) 930 (if mode (funcall mode)
930 (dired-mode dir-or-list switches)) 931 (dired-mode dir-or-list switches))
@@ -1056,13 +1057,14 @@ wildcards, erases the buffer, and builds the subdir-alist anew
1056 (not file-list)) 1057 (not file-list))
1057 ;; If we are reading a whole single directory... 1058 ;; If we are reading a whole single directory...
1058 (dired-insert-directory dir dired-actual-switches nil nil t) 1059 (dired-insert-directory dir dired-actual-switches nil nil t)
1059 (if (not (file-readable-p 1060 (if (and (not (insert-directory-wildcard-in-dir-p dir))
1060 (directory-file-name (file-name-directory dir)))) 1061 (not (file-readable-p
1061 (error "Directory %s inaccessible or nonexistent" dir) 1062 (directory-file-name (file-name-directory dir)))))
1062 ;; Else treat it as a wildcard spec 1063 (error "Directory %s inaccessible or nonexistent" dir))
1063 ;; unless we have an explicit list of files. 1064 ;; Else treat it as a wildcard spec
1064 (dired-insert-directory dir dired-actual-switches 1065 ;; unless we have an explicit list of files.
1065 file-list (not file-list) t))))) 1066 (dired-insert-directory dir dired-actual-switches
1067 file-list (not file-list) t))))
1066 1068
1067(defun dired-align-file (beg end) 1069(defun dired-align-file (beg end)
1068 "Align the fields of a file to the ones of surrounding lines. 1070 "Align the fields of a file to the ones of surrounding lines.
@@ -1207,29 +1209,46 @@ If HDR is non-nil, insert a header line with the directory name."
1207 ;; as indicated by `ls-lisp-use-insert-directory-program'. 1209 ;; as indicated by `ls-lisp-use-insert-directory-program'.
1208 (not (and (featurep 'ls-lisp) 1210 (not (and (featurep 'ls-lisp)
1209 (null ls-lisp-use-insert-directory-program))) 1211 (null ls-lisp-use-insert-directory-program)))
1210 (or (if (eq dired-use-ls-dired 'unspecified) 1212 (not (and (featurep 'eshell)
1213 (bound-and-true-p eshell-ls-use-in-dired)))
1214 (or (file-remote-p dir)
1215 (if (eq dired-use-ls-dired 'unspecified)
1211 ;; Check whether "ls --dired" gives exit code 0, and 1216 ;; Check whether "ls --dired" gives exit code 0, and
1212 ;; save the answer in `dired-use-ls-dired'. 1217 ;; save the answer in `dired-use-ls-dired'.
1213 (or (setq dired-use-ls-dired 1218 (or (setq dired-use-ls-dired
1214 (eq 0 (call-process insert-directory-program 1219 (eq 0 (call-process insert-directory-program
1215 nil nil nil "--dired"))) 1220 nil nil nil "--dired")))
1216 (progn 1221 (progn
1217 (message "ls does not support --dired; \ 1222 (message "ls does not support --dired; \
1218see `dired-use-ls-dired' for more details.") 1223see `dired-use-ls-dired' for more details.")
1219 nil)) 1224 nil))
1220 dired-use-ls-dired) 1225 dired-use-ls-dired)))
1221 (file-remote-p dir)))
1222 (setq switches (concat "--dired " switches))) 1226 (setq switches (concat "--dired " switches)))
1223 ;; We used to specify the C locale here, to force English month names; 1227 ;; Expand directory wildcards and fill file-list.
1224 ;; but this should not be necessary any more, 1228 (let ((dir-wildcard (insert-directory-wildcard-in-dir-p dir)))
1225 ;; with the new value of `directory-listing-before-filename-regexp'. 1229 (cond (dir-wildcard
1226 (if file-list 1230 (setq switches (concat "-d " switches))
1227 (dolist (f file-list) 1231 (let ((default-directory (car dir-wildcard))
1228 (let ((beg (point))) 1232 (script (format "ls %s %s" switches (cdr dir-wildcard))))
1229 (insert-directory f switches nil nil) 1233 (unless
1230 ;; Re-align fields, if necessary. 1234 (zerop
1231 (dired-align-file beg (point)))) 1235 (process-file
1232 (insert-directory dir switches wildcard (not wildcard))) 1236 "/bin/sh" nil (current-buffer) nil "-c" script))
1237 (user-error
1238 "%s: No files matching wildcard" (cdr dir-wildcard)))
1239 (insert-directory-clean (point) switches)))
1240 (t
1241 ;; We used to specify the C locale here, to force English
1242 ;; month names; but this should not be necessary any
1243 ;; more, with the new value of
1244 ;; `directory-listing-before-filename-regexp'.
1245 (if file-list
1246 (dolist (f file-list)
1247 (let ((beg (point)))
1248 (insert-directory f switches nil nil)
1249 ;; Re-align fields, if necessary.
1250 (dired-align-file beg (point))))
1251 (insert-directory dir switches wildcard (not wildcard))))))
1233 ;; Quote certain characters, unless ls quoted them for us. 1252 ;; Quote certain characters, unless ls quoted them for us.
1234 (if (not (dired-switches-escape-p dired-actual-switches)) 1253 (if (not (dired-switches-escape-p dired-actual-switches))
1235 (save-excursion 1254 (save-excursion
@@ -1279,11 +1298,14 @@ see `dired-use-ls-dired' for more details.")
1279 ;; Note that dired-build-subdir-alist will replace the name 1298 ;; Note that dired-build-subdir-alist will replace the name
1280 ;; by its expansion, so it does not matter whether what we insert 1299 ;; by its expansion, so it does not matter whether what we insert
1281 ;; here is fully expanded, but it should be absolute. 1300 ;; here is fully expanded, but it should be absolute.
1282 (insert " " (directory-file-name (file-name-directory dir)) ":\n") 1301 (insert " " (or (car-safe (insert-directory-wildcard-in-dir-p dir))
1302 (directory-file-name (file-name-directory dir))) ":\n")
1283 (setq content-point (point))) 1303 (setq content-point (point)))
1284 (when wildcard 1304 (when wildcard
1285 ;; Insert "wildcard" line where "total" line would be for a full dir. 1305 ;; Insert "wildcard" line where "total" line would be for a full dir.
1286 (insert " wildcard " (file-name-nondirectory dir) "\n"))) 1306 (insert " wildcard " (or (cdr-safe (insert-directory-wildcard-in-dir-p dir))
1307 (file-name-nondirectory dir))
1308 "\n")))
1287 (dired-insert-set-properties content-point (point))))) 1309 (dired-insert-set-properties content-point (point)))))
1288 1310
1289(defun dired-insert-set-properties (beg end) 1311(defun dired-insert-set-properties (beg end)