diff options
| author | Stefan Monnier | 2002-09-16 17:13:16 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2002-09-16 17:13:16 +0000 |
| commit | 2b2059d899a9978349ee00eb009d22e10a66b22c (patch) | |
| tree | 18b98a8cce780b2add7bd35421be55ff27a1e1cc | |
| parent | c721078eb9ed2e7ff3093dd6e96dd43a71df199a (diff) | |
| download | emacs-2b2059d899a9978349ee00eb009d22e10a66b22c.tar.gz emacs-2b2059d899a9978349ee00eb009d22e10a66b22c.zip | |
(dired-font-lock-keywords): Use regexp-opt.
(dired-move-to-filename): Better message when we fail to find the file.
(dired-sort-toggle): Minor optimization.
| -rw-r--r-- | lisp/dired.el | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/lisp/dired.el b/lisp/dired.el index 43941bc17aa..d5bbaaddebc 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -192,7 +192,7 @@ with the buffer narrowed to the listing." | |||
| 192 | ;; Note this can't simply be run inside function `dired-ls' as the hook | 192 | ;; Note this can't simply be run inside function `dired-ls' as the hook |
| 193 | ;; functions probably depend on the dired-subdir-alist to be OK. | 193 | ;; functions probably depend on the dired-subdir-alist to be OK. |
| 194 | 194 | ||
| 195 | ;;; Internal variables | 195 | ;; Internal variables |
| 196 | 196 | ||
| 197 | (defvar dired-marker-char ?* ; the answer is 42 | 197 | (defvar dired-marker-char ?* ; the answer is 42 |
| 198 | ;; so that you can write things like | 198 | ;; so that you can write things like |
| @@ -304,11 +304,10 @@ Subexpression 2 must end right before the \\n or \\r.") | |||
| 304 | ;; | 304 | ;; |
| 305 | ;; Files suffixed with `completion-ignored-extensions'. | 305 | ;; Files suffixed with `completion-ignored-extensions'. |
| 306 | '(eval . | 306 | '(eval . |
| 307 | (let ((extensions (mapcar 'regexp-quote completion-ignored-extensions))) | 307 | ;; It is quicker to first find just an extension, then go back to the |
| 308 | ;; It is quicker to first find just an extension, then go back to the | 308 | ;; start of that file name. So we do this complex MATCH-ANCHORED form. |
| 309 | ;; start of that file name. So we do this complex MATCH-ANCHORED form. | 309 | (list (concat "\\(" (regexp-opt completion-ignored-extensions) "\\|#\\)$") |
| 310 | (list (concat "\\(" (mapconcat 'identity extensions "\\|") "\\|#\\)$") | 310 | '(".+" (dired-move-to-filename) nil (0 font-lock-string-face))))) |
| 311 | '(".+" (dired-move-to-filename) nil (0 font-lock-string-face)))))) | ||
| 312 | "Additional expressions to highlight in Dired mode.") | 311 | "Additional expressions to highlight in Dired mode.") |
| 313 | 312 | ||
| 314 | ;;; Macros must be defined before they are used, for the byte compiler. | 313 | ;;; Macros must be defined before they are used, for the byte compiler. |
| @@ -1449,7 +1448,7 @@ Optional arg NO-ERROR-IF-NOT-FILEP means return nil if no filename on | |||
| 1449 | (setq file | 1448 | (setq file |
| 1450 | (read | 1449 | (read |
| 1451 | (concat "\"" | 1450 | (concat "\"" |
| 1452 | ;; some ls -b don't escape quotes, argh! | 1451 | ;; Some ls -b don't escape quotes, argh! |
| 1453 | ;; This is not needed for GNU ls, though. | 1452 | ;; This is not needed for GNU ls, though. |
| 1454 | (or (dired-string-replace-match | 1453 | (or (dired-string-replace-match |
| 1455 | "\\([^\\]\\|\\`\\)\"" file "\\1\\\\\"" nil t) | 1454 | "\\([^\\]\\|\\`\\)\"" file "\\1\\\\\"" nil t) |
| @@ -1584,17 +1583,21 @@ regardless of the language.") | |||
| 1584 | ;; Returns position (point) or nil if no filename on this line." | 1583 | ;; Returns position (point) or nil if no filename on this line." |
| 1585 | (defun dired-move-to-filename (&optional raise-error eol) | 1584 | (defun dired-move-to-filename (&optional raise-error eol) |
| 1586 | ;; This is the UNIX version. | 1585 | ;; This is the UNIX version. |
| 1587 | (or eol (setq eol (progn (end-of-line) (point)))) | 1586 | (or eol (setq eol (line-end-position))) |
| 1588 | (beginning-of-line) | 1587 | (beginning-of-line) |
| 1589 | ;; First try assuming `ls --dired' was used. | 1588 | ;; First try assuming `ls --dired' was used. |
| 1590 | (let ((change (next-single-property-change (point) 'dired-filename | 1589 | (let ((change (next-single-property-change (point) 'dired-filename nil eol))) |
| 1591 | nil eol))) | 1590 | (cond |
| 1592 | (if (and change (< change eol)) | 1591 | ((and change (< change eol)) |
| 1593 | (goto-char change) | 1592 | (goto-char change)) |
| 1594 | (if (re-search-forward dired-move-to-filename-regexp eol t) | 1593 | ((re-search-forward dired-move-to-filename-regexp eol t) |
| 1595 | (goto-char (match-end 0)) | 1594 | (goto-char (match-end 0))) |
| 1596 | (if raise-error | 1595 | ((re-search-forward dired-permission-flags-regexp eol t) |
| 1597 | (error "No file on this line")))))) | 1596 | ;; Ha! There *is* a file. Our regexp-from-hell just failed to find it. |
| 1597 | (funcall (if raise-error 'error 'message) | ||
| 1598 | "Unrecognized line! Check dired-move-to-filename-regexp")) | ||
| 1599 | (raise-error | ||
| 1600 | (error "No file on this line"))))) | ||
| 1598 | 1601 | ||
| 1599 | (defun dired-move-to-end-of-filename (&optional no-error) | 1602 | (defun dired-move-to-end-of-filename (&optional no-error) |
| 1600 | ;; Assumes point is at beginning of filename, | 1603 | ;; Assumes point is at beginning of filename, |
| @@ -2244,9 +2247,8 @@ Command symbols are `byte-compile', `chgrp', `chmod', `chown', `compress', | |||
| 2244 | `uncompress'.") | 2247 | `uncompress'.") |
| 2245 | 2248 | ||
| 2246 | (defun dired-mark-pop-up (bufname op-symbol files function &rest args) | 2249 | (defun dired-mark-pop-up (bufname op-symbol files function &rest args) |
| 2247 | "Args BUFNAME OP-SYMBOL FILES FUNCTION &rest ARGS. | 2250 | "Return FUNCTION's result on ARGS after popping up a window |
| 2248 | Return FUNCTION's result on ARGS after popping up a window (in a buffer | 2251 | \(in a buffer named BUFNAME, nil gives \" *Marked Files*\") showing the marked |
| 2249 | named BUFNAME, nil gives \" *Marked Files*\") showing the marked | ||
| 2250 | files. Uses function `dired-pop-to-buffer' to do that. | 2252 | files. Uses function `dired-pop-to-buffer' to do that. |
| 2251 | FUNCTION should not manipulate files. | 2253 | FUNCTION should not manipulate files. |
| 2252 | It should only read input (an argument or confirmation). | 2254 | It should only read input (an argument or confirmation). |
| @@ -2749,7 +2751,7 @@ With a prefix argument you can edit the current listing switches instead." | |||
| 2749 | (if (string-match " " dired-actual-switches) | 2751 | (if (string-match " " dired-actual-switches) |
| 2750 | ;; New toggle scheme: add/remove a trailing " -t" | 2752 | ;; New toggle scheme: add/remove a trailing " -t" |
| 2751 | (if (string-match " -t\\'" dired-actual-switches) | 2753 | (if (string-match " -t\\'" dired-actual-switches) |
| 2752 | (dired-replace-in-string " -t\\'" "" dired-actual-switches) | 2754 | (substring dired-actual-switches 0 (match-beginning 0)) |
| 2753 | (concat dired-actual-switches " -t")) | 2755 | (concat dired-actual-switches " -t")) |
| 2754 | ;; old toggle scheme: look for some 't' switch and add/remove it | 2756 | ;; old toggle scheme: look for some 't' switch and add/remove it |
| 2755 | (concat | 2757 | (concat |