0
|
1 ;;; Copyright (C) 1993 Cengiz Alaettinoglu
|
|
2 ;;; Cengiz Alaettinoglu <ca@cs.umd.edu>
|
|
3
|
|
4 ;;; Copyright (C) 1991 Tim Wilson and Sebastian Kremer
|
|
5 ;;; Tim.Wilson@cl.cam.ac.uk
|
|
6 ;;; Sebastian Kremer <sk@thp.uni-koeln.de>
|
|
7 ;;; Modified to work with XEmacs
|
|
8
|
|
9 ;; Keywords: dired extensions, faces
|
|
10
|
|
11 ;; This file is part of XEmacs.
|
|
12
|
|
13 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
14 ;; under the terms of the GNU General Public License as published by
|
|
15 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
16 ;; any later version.
|
|
17
|
|
18 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
21 ;; General Public License for more details.
|
|
22
|
|
23 ;; You should have received a copy of the GNU General Public License
|
16
|
24 ;; along with XEmacs; see the file COPYING. If not, write to the
|
|
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
26 ;; Boston, MA 02111-1307, USA.
|
0
|
27
|
|
28 ;;; Synched up with: Not synched with FSF.
|
|
29
|
|
30
|
|
31 ; How to install
|
|
32 ; (add-hook 'dired-load-hook '(lambda () (require 'dired-xemacs-highlight)) t)
|
|
33
|
|
34 (require 'dired)
|
|
35 (require 'dired-extra "dired-x")
|
|
36 (provide 'dired-xemacs-highlight)
|
|
37
|
|
38 (or (find-face 'dired-face-marked)
|
|
39 (and
|
|
40 (make-face 'dired-face-marked)
|
|
41 (or (face-differs-from-default-p 'dired-face-marked)
|
|
42 (if (eq (device-class) 'color)
|
|
43 (progn
|
|
44 (set-face-foreground 'dired-face-marked (face-foreground 'default))
|
|
45 (set-face-background 'dired-face-marked "PaleVioletRed"))
|
|
46 (set-face-underline-p 'dired-face-marked t)))))
|
|
47
|
|
48 (or (find-face 'dired-face-deleted)
|
|
49 (and
|
|
50 (make-face 'dired-face-deleted)
|
|
51 (or (face-differs-from-default-p 'dired-face-deleted)
|
|
52 (if (eq (device-class) 'color)
|
|
53 (progn
|
|
54 (set-face-foreground 'dired-face-deleted
|
|
55 (face-foreground 'default))
|
|
56 (set-face-background 'dired-face-deleted "LightSlateGray"))
|
|
57 (set-face-underline-p 'dired-face-deleted t)))))
|
|
58
|
|
59 (or (find-face 'dired-face-directory)
|
|
60 (and
|
|
61 (make-face 'dired-face-directory)
|
|
62 (or (face-differs-from-default-p 'dired-face-directory)
|
|
63 (if (eq (device-class) 'color)
|
|
64 (progn
|
|
65 (set-face-foreground 'dired-face-directory
|
|
66 (face-foreground 'default))
|
|
67 (make-face-bold 'dired-face-directory))
|
|
68 (make-face-bold-italic 'dired-face-directory)))))
|
|
69
|
|
70 (or (find-face 'dired-face-executable)
|
|
71 (and
|
|
72 (make-face 'dired-face-executable)
|
|
73 (or (face-differs-from-default-p 'dired-face-executable)
|
|
74 (if (eq (device-class) 'color)
|
|
75 (set-face-foreground 'dired-face-executable "SeaGreen")
|
|
76 (make-face-bold 'dired-face-executable)))))
|
|
77
|
|
78 (or (find-face 'dired-face-setuid)
|
|
79 (and
|
|
80 (make-face 'dired-face-setuid)
|
|
81 (or (face-differs-from-default-p 'dired-face-setuid)
|
|
82 (if (eq (device-class) 'color)
|
|
83 (set-face-foreground 'dired-face-setuid "Red")
|
|
84 (make-face-bold 'dired-face-setuid)))))
|
|
85
|
|
86 (or (find-face 'dired-face-socket)
|
|
87 (and
|
|
88 (make-face 'dired-face-socket)
|
|
89 (or (face-differs-from-default-p 'dired-face-socket)
|
|
90 (if (eq (device-class) 'color)
|
|
91 (set-face-foreground 'dired-face-socket "Gold")
|
|
92 (make-face-italic 'dired-face-socket)))))
|
|
93
|
|
94 (or (find-face 'dired-face-symlink)
|
|
95 (and
|
|
96 (make-face 'dired-face-symlink)
|
|
97 (or (face-differs-from-default-p 'dired-face-symlink)
|
|
98 (if (eq (device-class) 'color)
|
|
99 (progn
|
|
100 (set-face-foreground 'dired-face-symlink "MediumBlue")
|
|
101 (make-face-bold 'dired-face-symlink))
|
|
102 (make-face-italic 'dired-face-symlink)))))
|
|
103
|
|
104 (or (find-face 'dired-face-boring)
|
|
105 (and
|
|
106 (make-face 'dired-face-boring)
|
|
107 (or (face-differs-from-default-p 'dired-face-boring)
|
|
108 (if (eq (device-class) 'color)
|
|
109 (set-face-foreground 'dired-face-boring "Grey")
|
|
110 (set-face-background-pixmap
|
|
111 'dired-face-boring
|
|
112 [32 2 "\125\125\125\125\252\252\252\252"])))))
|
|
113
|
|
114 (defvar dired-do-permission-highlighting-too nil
|
|
115 "Set if we think we should use dired-chmod style permission highlighting.
|
|
116 This is determined at first-pass time, to avoid filtering the buffer twice.")
|
|
117
|
|
118 (defvar dired-x11-re-boring (if (fboundp 'dired-omit-regexp)
|
|
119 (dired-omit-regexp)
|
|
120 "^#\\|~$")
|
|
121 "Regexp to match backup, autosave and otherwise boring files.
|
|
122 Those files are displayed in a boring color such as grey (see
|
|
123 variable `dired-x11-boring-color').")
|
|
124
|
|
125 (defvar dired-re-socket
|
|
126 (concat dired-re-maybe-mark dired-re-inode-size "s"))
|
|
127
|
|
128 (defvar dired-re-setuid
|
|
129 (concat dired-re-maybe-mark dired-re-inode-size
|
|
130 "-[-r][-w][Ss][-r][-w][sx][-r][-w][xst]")
|
|
131 "setuid plain file (even if not executable)")
|
|
132
|
|
133 (defvar dired-re-setgid
|
|
134 (concat dired-re-maybe-mark dired-re-inode-size
|
|
135 "-[-r][-w][-x][-r][-w][Ss][-r][-w][xst]")
|
|
136 "setgid plain file (even if not executable)")
|
|
137
|
|
138 (defun dired-xemacs-highlight-one (face)
|
|
139 (and (dired-move-to-filename t)
|
|
140 (set-extent-face (make-extent (dired-move-to-filename)
|
|
141 (dired-move-to-end-of-filename))
|
|
142 face)))
|
|
143
|
|
144 (defun dired-xemacs-highlight ()
|
|
145 (message "Highlighting... directory")
|
|
146 ;; Let's try to do this in one pass...
|
|
147 (setq dired-do-permission-highlighting-too
|
|
148 (or dired-do-permission-highlighting-too (featurep 'dired-chmod)))
|
|
149 (if (and dired-do-permission-highlighting-too
|
|
150 (member 'dired-permissions-highlight dired-after-readin-hook))
|
|
151 (remove-hook 'dired-after-readin-hook 'dired-permissions-highlight))
|
|
152 (save-excursion
|
|
153 (goto-char (point-min))
|
|
154 (while (not (eobp))
|
|
155 (and (not (eolp))
|
|
156 (progn
|
|
157 (beginning-of-line)
|
|
158 (cond
|
|
159 ((re-search-forward
|
|
160 dired-x11-re-boring
|
|
161 (save-excursion
|
|
162 (end-of-line)
|
|
163 (point))
|
|
164 t)
|
|
165 (dired-xemacs-highlight-one 'dired-face-boring))
|
|
166 ((looking-at dired-re-dir)
|
|
167 (dired-xemacs-highlight-one 'dired-face-directory))
|
|
168 ((looking-at dired-re-sym)
|
|
169 (dired-xemacs-highlight-one 'dired-face-symlink))
|
|
170 ((or (looking-at dired-re-setuid)
|
|
171 (looking-at dired-re-setgid))
|
|
172 (dired-xemacs-highlight-one 'dired-face-setuid))
|
|
173 ((looking-at dired-re-exe)
|
|
174 (dired-xemacs-highlight-one 'dired-face-executable))
|
|
175 ((looking-at dired-re-socket)
|
|
176 (dired-xemacs-highlight-one 'dired-face-socket)))
|
|
177 (if dired-do-permission-highlighting-too
|
|
178 (dired-make-permissions-interactive))))
|
|
179 (forward-line 1))
|
|
180 (message "Highlighting...done")
|
|
181 ))
|
|
182
|
|
183 ;FSF's version?
|
|
184 ;(defconst dired-font-lock-keywords
|
|
185 ; (list (cons "^\\*.*$" 'dired-face-marked)
|
|
186 ; (cons "^\\D.*$" 'dired-face-deleted)))
|
|
187
|
|
188 (defconst dired-font-lock-keywords (purecopy
|
|
189 (let ((bn (concat "\\(Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|Jul\\|"
|
|
190 "Aug\\|Sep\\|Oct\\|Nov\\|Dec\\) +[0-9]+ +[0-9:]+")))
|
|
191 (list
|
|
192 '("^ [/~].*:$" . bold-italic) ; Header
|
|
193 (list (concat "^\\(\\([^ ].*\\)" bn "\\) \\(.*\\)$") 1 'bold) ; Marked
|
|
194 (list (concat "^. +d.*" bn " \\(.*\\)$") 2 'bold) ; Subdirs
|
|
195 (list (concat "^. +l.*" bn " \\(.*\\)$") 2 'italic) ; Links
|
|
196 (cons (concat "^. +-..[xsS]......\\|" ; Regular files with executable
|
|
197 "^. +-.....[xsS]...\\|" ; or setuid/setgid bits set
|
|
198 "^. +-........[xsS]")
|
|
199 'bold)
|
|
200 ;; Possibly we should highlight more types of files differently:
|
|
201 ;; backups; autosaves; core files? Those with ignored-extensions?
|
|
202 )))
|
|
203 "Expressions to highlight in Dired buffers.")
|
|
204
|
|
205 (put 'dired-mode 'font-lock-keywords 'dired-font-lock-keywords)
|
|
206
|
|
207 (add-hook 'dired-after-readin-hook 'dired-xemacs-highlight)
|