;; Dired marks.
(list dired-re-mark
'(0 font-lock-constant-face)
- '("[ \t]+" (dired-move-to-filename) nil (0 font-lock-warning-face)))
+ '(".+" (dired-move-to-filename) nil (0 font-lock-warning-face)))
;; People who are paranoid about security would consider this more
;; important than other things such as whether it is a directory.
;; But we don't want to encourage paranoia, so our default
;;
;; Subdirectories.
(list dired-re-dir
- '("[ \t]+" (dired-move-to-filename) nil (0 font-lock-function-name-face)))
+ '(".+" (dired-move-to-filename) nil (0 font-lock-function-name-face)))
;;
;; Symbolic links.
(list dired-re-sym
- '("[ \t]+" (dired-move-to-filename) nil (0 font-lock-keyword-face)))
+ '(".+" (dired-move-to-filename) nil (0 font-lock-keyword-face)))
;;
;; Files suffixed with `completion-ignored-extensions'.
'(eval .
;; It is quicker to first find just an extension, then go back to the
;; start of that file name. So we do this complex MATCH-ANCHORED form.
(list (concat "\\(" (mapconcat 'identity extensions "\\|") "\\|#\\)$")
- '("[ \t]+" (dired-move-to-filename) nil (0 font-lock-string-face))))))
+ '(".+" (dired-move-to-filename) nil (0 font-lock-string-face))))))
"Additional expressions to highlight in Dired mode.")
\f
;;; Macros must be defined before they are used, for the byte compiler.
(and (> count 0) count))))
(defmacro dired-map-over-marks (body arg &optional show-progress)
-;; "Macro: Perform BODY with point somewhere on each marked line
-;;and return a list of BODY's results.
-;;If no marked file could be found, execute BODY on the current line.
-;; If ARG is an integer, use the next ARG (or previous -ARG, if ARG<0)
-;; files instead of the marked files.
-;; In that case point is dragged along. This is so that commands on
-;; the next ARG (instead of the marked) files can be chained easily.
-;; If ARG is otherwise non-nil, use current file instead.
-;;If optional third arg SHOW-PROGRESS evaluates to non-nil,
-;; redisplay the dired buffer after each file is processed.
-;;No guarantee is made about the position on the marked line.
-;; BODY must ensure this itself if it depends on this.
-;;Search starts at the beginning of the buffer, thus the car of the list
-;; corresponds to the line nearest to the buffer's bottom. This
-;; is also true for (positive and negative) integer values of ARG.
-;;BODY should not be too long as it is expanded four times."
-;;
-;;Warning: BODY must not add new lines before point - this may cause an
-;;endless loop.
-;;This warning should not apply any longer, sk 2-Sep-1991 14:10.
- (` (prog1
- (let (buffer-read-only case-fold-search found results)
- (if (, arg)
- (if (integerp (, arg))
- (progn;; no save-excursion, want to move point.
- (dired-repeat-over-lines
- (, arg)
- (function (lambda ()
- (if (, show-progress) (sit-for 0))
- (setq results (cons (, body) results)))))
- (if (< (, arg) 0)
- (nreverse results)
- results))
- ;; non-nil, non-integer ARG means use current file:
- (list (, body)))
- (let ((regexp (dired-marker-regexp)) next-position)
- (save-excursion
- (goto-char (point-min))
- ;; remember position of next marked file before BODY
- ;; can insert lines before the just found file,
- ;; confusing us by finding the same marked file again
- ;; and again and...
+ "Eval BODY with point on each marked line. Return a list of BODY's results.
+If no marked file could be found, execute BODY on the current line.
+ If ARG is an integer, use the next ARG (or previous -ARG, if ARG<0)
+ files instead of the marked files.
+ In that case point is dragged along. This is so that commands on
+ the next ARG (instead of the marked) files can be chained easily.
+ If ARG is otherwise non-nil, use current file instead.
+If optional third arg SHOW-PROGRESS evaluates to non-nil,
+ redisplay the dired buffer after each file is processed.
+No guarantee is made about the position on the marked line.
+ BODY must ensure this itself if it depends on this.
+Search starts at the beginning of the buffer, thus the car of the list
+ corresponds to the line nearest to the buffer's bottom. This
+ is also true for (positive and negative) integer values of ARG.
+BODY should not be too long as it is expanded four times."
+ ;;
+ ;;Warning: BODY must not add new lines before point - this may cause an
+ ;;endless loop.
+ ;;This warning should not apply any longer, sk 2-Sep-1991 14:10.
+ `(prog1
+ (let (buffer-read-only case-fold-search found results)
+ (if ,arg
+ (if (integerp ,arg)
+ (progn ;; no save-excursion, want to move point.
+ (dired-repeat-over-lines
+ ,arg
+ (function (lambda ()
+ (if ,show-progress (sit-for 0))
+ (setq results (cons ,body results)))))
+ (if (< ,arg 0)
+ (nreverse results)
+ results))
+ ;; non-nil, non-integer ARG means use current file:
+ (list ,body))
+ (let ((regexp (dired-marker-regexp)) next-position)
+ (save-excursion
+ (goto-char (point-min))
+ ;; remember position of next marked file before BODY
+ ;; can insert lines before the just found file,
+ ;; confusing us by finding the same marked file again
+ ;; and again and...
+ (setq next-position (and (re-search-forward regexp nil t)
+ (point-marker))
+ found (not (null next-position)))
+ (while next-position
+ (goto-char next-position)
+ (if ,show-progress (sit-for 0))
+ (setq results (cons ,body results))
+ ;; move after last match
+ (goto-char next-position)
+ (forward-line 1)
+ (set-marker next-position nil)
(setq next-position (and (re-search-forward regexp nil t)
- (point-marker))
- found (not (null next-position)))
- (while next-position
- (goto-char next-position)
- (if (, show-progress) (sit-for 0))
- (setq results (cons (, body) results))
- ;; move after last match
- (goto-char next-position)
- (forward-line 1)
- (set-marker next-position nil)
- (setq next-position (and (re-search-forward regexp nil t)
- (point-marker)))))
- (if found
- results
- (list (, body))))))
- ;; save-excursion loses, again
- (dired-move-to-filename))))
+ (point-marker)))))
+ (if found
+ results
+ (list ,body)))))
+ ;; save-excursion loses, again
+ (dired-move-to-filename)))
(defun dired-get-marked-files (&optional localp arg)
"Return the marked files' names as list of strings.
;; Also, we can run this hook which may want to modify the switches
;; based on default-directory, e.g. with ange-ftp to a SysV host
;; where ls won't understand -Al switches.
- (let (dirname)
+ (let (dirname
+ (indent-tabs-mode nil))
(if (consp dir-or-list)
(setq dirname (car dir-or-list))
(setq dirname dir-or-list))
(goto-char (point-min))
(when (re-search-forward "total [0-9]+$" nil t)
(insert " free ")
- (let ((beg (point)))
- (if (zerop (call-process dired-free-space-program nil t nil
- dired-free-space-args
- (expand-file-name dir-or-list)))
- (progn
- (goto-char beg)
- (forward-line 1)
- (skip-chars-forward "^ \t")
- (forward-word 2)
- (skip-chars-forward " \t")
- (delete-region beg (point))
- (forward-word 1)
- (delete-region (point)
- (progn (forward-line 1) (point))))
- ;; The dired-free-space-program failed; delete its output
- (delete-region (- beg 7) (point))))))))
+ ;; Non-Posix systems don't always have dired-free-space-program,
+ ;; but might have an equivalent system call.
+ (if (fboundp 'file-system-info)
+ (insert
+ (format "%.0f"
+ (/ (nth 2 (file-system-info dir-or-list)) 1024)))
+ (let ((beg (point)))
+ (condition-case nil
+ (if (zerop (call-process dired-free-space-program nil t nil
+ dired-free-space-args
+ (expand-file-name dir-or-list)))
+ (progn
+ (goto-char beg)
+ (forward-line 1)
+ (skip-chars-forward "^ \t")
+ (forward-word 2)
+ (skip-chars-forward " \t")
+ (delete-region beg (point))
+ (forward-word 1)
+ (delete-region (point)
+ (progn (forward-line 1) (point))))
+ ;; The dired-free-space-program failed; delete its output
+ (delete-region (- beg 7) (point)))
+ (error (delete-region (- beg 7) (point))))))))))
;; Quote certain characters, unless ls quoted them for us.
(if (not (string-match "b" dired-actual-switches))
(save-excursion
"In dired, return name of file mentioned on this line.
Value returned normally includes the directory name.
Optional arg LOCALP with value `no-dir' means don't include directory
- name in result. A value of t means construct name relative to
+ name in result. A value of `verbatim' means to return the name exactly as
+ it occurs in the buffer, and a value of t means construct name relative to
`default-directory', which still may contain slashes if in a subdirectory.
Optional arg NO-ERROR-IF-NOT-FILEP means return nil if no filename on
this line, otherwise an error occurs."
(not default-file-name-coding-system)
(setq file (encode-coding-string file buffer-file-coding-system)))
(cond
+ ((eq localp 'verbatim)
+ file)
((and (eq localp 'no-dir) already-absolute)
(file-name-nondirectory file))
((or already-absolute (eq localp 'no-dir))
"\\|" yyyy s s "?"
"\\|" s "?" yyyy
"\\)"))
- (japanese (concat mm k s dd k s "\\(" s HH:MM "\\|" yyyy k "\\)")))
+ (japanese
+ (concat mm k s dd k "?" s "\\(" s HH:MM "\\|" yyyy k "?" "\\)")))
;; The "[0-9]" below requires the previous column to end in a digit.
;; This avoids recognizing `1 may 1997' as a date in the line:
;; -r--r--r-- 1 may 1997 1168 Oct 19 16:49 README
`uncompress'.")
(defun dired-mark-pop-up (bufname op-symbol files function &rest args)
- ;;"Args BUFNAME OP-SYMBOL FILES FUNCTION &rest ARGS.
- ;;Return FUNCTION's result on ARGS after popping up a window (in a buffer
- ;;named BUFNAME, nil gives \" *Marked Files*\") showing the marked
- ;;files. Uses function `dired-pop-to-buffer' to do that.
- ;; FUNCTION should not manipulate files.
- ;; It should only read input (an argument or confirmation).
- ;;The window is not shown if there is just one file or
- ;; OP-SYMBOL is a member of the list in `dired-no-confirm'.
- ;;FILES is the list of marked files."
+ "Args BUFNAME OP-SYMBOL FILES FUNCTION &rest ARGS.
+Return FUNCTION's result on ARGS after popping up a window (in a buffer
+named BUFNAME, nil gives \" *Marked Files*\") showing the marked
+files. Uses function `dired-pop-to-buffer' to do that.
+ FUNCTION should not manipulate files.
+ It should only read input (an argument or confirmation).
+The window is not shown if there is just one file or
+ OP-SYMBOL is a member of the list in `dired-no-confirm'.
+FILES is the list of marked files."
(or bufname (setq bufname " *Marked Files*"))
(if (or (eq dired-no-confirm t)
(memq op-symbol dired-no-confirm)
(= (length files) 1))
(apply function args)
- (save-excursion
- (set-buffer (get-buffer-create bufname))
+ (with-current-buffer (get-buffer-create bufname)
(erase-buffer)
(dired-format-columns-of-files files)
(remove-text-properties (point-min) (point-max) '(mouse-face)))
;; Point must be at beginning of line
;; Should be equivalent to (save-excursion (not (dired-move-to-filename)))
;; but is about 1.5..2.0 times as fast. (Actually that's not worth it)
- (or (looking-at "^$\\|^. *$\\|^. total\\|^. wildcard\\|^. used")
+ (or (looking-at "^$\\|^. *$\\|^. total\\|^. wildcard\\|^. used\\|^. find")
(and (looking-at dired-subdir-regexp)
(save-excursion (not (dired-move-to-filename))))))