changeset 16454:76b0d4d3371e

Tweak dired-font-lock-keywords.
author Simon Marshall <simon@gnu.org>
date Wed, 23 Oct 1996 09:26:39 +0000
parents 90a2c2aebc37
children 0ea4c341ed0c
files lisp/dired.el
diffstat 1 files changed, 38 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/dired.el	Wed Oct 23 09:26:35 1996 +0000
+++ b/lisp/dired.el	Wed Oct 23 09:26:39 1996 +0000
@@ -120,17 +120,6 @@
   "*If non-nil, Dired preserves the last-modified time in a file copy.
 \(This works on only some systems.)")
 
-(defvar dired-font-lock-keywords
-  '(;; Put directory headers in italics.
-    ("^  \\(/.+\\)" 1 font-lock-type-face)
-    ;; Put symlinks in bold italics.
-    ("\\([^ ]+\\) -> [^ ]+$" . font-lock-function-name-face)
-    ;; Put marks in bold.
-    ("^[^ ]" . font-lock-reference-face)
-    ;; Put files that are subdirectories in bold.
-    ("^..d.* \\([^ ]+\\)$" 1 font-lock-keyword-face))
-  "Additional expressions to highlight in Dired mode.")
-
 ;;; Hook variables
 
 (defvar dired-load-hook nil
@@ -223,6 +212,44 @@
 of the line (\\n or \\r).
 Subexpression 2 must end right before the \\n or \\r.")
 
+(defvar dired-font-lock-keywords
+  (list
+   ;;
+   ;; Directory headers.
+   (list dired-subdir-regexp '(1 font-lock-type-face))
+   ;;
+   ;; We make heavy use of MATCH-ANCHORED, since the regexps don't identify the
+   ;; file name itself.  We search for Dired defined regexps, and then use the
+   ;; Dired defined function `dired-move-to-filename' before searching for the
+   ;; simple regexp ".+".  It is that regexp which matches the file name.
+   ;;
+   ;; Dired marks.
+   (list dired-re-mark
+	 '(0 font-lock-reference-face)
+	 '(".+" (dired-move-to-filename) nil (0 font-lock-warning-face)))
+   ;;
+   ;; Files that are group or world writable.
+   (list (concat dired-re-maybe-mark dired-re-inode-size
+		 "\\([-d]\\(....w....\\|.......w.\\)\\)")
+	 '(1 font-lock-comment-face)
+	 '(".+" (dired-move-to-filename) nil (0 font-lock-comment-face)))
+   ;;
+   ;; Subdirectories.
+   (list dired-re-dir
+	 '(".+" (dired-move-to-filename) nil (0 font-lock-function-name-face)))
+   ;;
+   ;; Symbolic links.
+   (list dired-re-sym 
+	 '(".+" (dired-move-to-filename) nil (0 font-lock-keyword-face)))
+   ;;
+   ;; Files suffixed with `completion-ignored-extensions'.
+   '(eval .
+     (let ((extensions (mapcar 'regexp-quote completion-ignored-extensions)))
+       ;; 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 "\\|") "\\|#\\)$")
+	     '(".+" (dired-move-to-filename) nil (0 font-lock-string-face))))))
+  "Additional expressions to highlight in Dired mode.")
 
 ;;; Macros must be defined before they are used, for the byte compiler.