Commit | Line | Data |
---|---|---|
be010748 RS |
1 | ;;; hilit19.el --- customizable highlighting for Emacs19 |
2 | ||
8f1204db | 3 | ;; Copyright (c) 1993, 1994 Free Software Foundation, Inc. |
be010748 | 4 | |
6267bd25 | 5 | ;; Author: Jonathan Stigelman <stig@hackvan.com> |
9a5e9959 | 6 | ;; Keywords: faces |
be010748 RS |
7 | |
8 | ;; This file is part of GNU Emacs. | |
9 | ||
10 | ;; GNU Emacs is free software; you can redistribute it and/or modify | |
9a5e9959 | 11 | ;; it under the terms of the GNU General Public License as published by |
be010748 RS |
12 | ;; the Free Software Foundation; either version 2, or (at your option) |
13 | ;; any later version. | |
14 | ||
15 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
9a5e9959 RS |
16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | ;; GNU General Public License for more details. | |
be010748 | 19 | |
9a5e9959 | 20 | ;; You should have received a copy of the GNU General Public License |
b578f267 EN |
21 | ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 | ;; Boston, MA 02111-1307, USA. | |
9a5e9959 RS |
24 | |
25 | ;;; Commentary: | |
26 | ||
280a6a9f RS |
27 | ;; Hilit19.el is a customizable highlighting package for Emacs19. It supports |
28 | ;; not only source code highlighting, but also Info, RMAIL, VM, gnus... | |
29 | ;; Hilit19 knows (or thinks it knows) how to highlight emacs buffers in | |
30 | ;; about 25 different modes. | |
31 | ;; | |
32 | ;; WHERE TO GET THE LATEST VERSIONS OF HILIT19.EL (beta and release), | |
9a5e9959 RS |
33 | ;; PLUS LOTS OF OTHER *WAY COOL* STUFF VIA ANONYMOUS FTP: |
34 | ;; | |
67cbfd2a | 35 | ;; ftp.hackvan.com:/pub/stig/src/elisp/hilit19.el.gz |
9a5e9959 RS |
36 | ;; |
37 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
38 | ;; | |
39 | ;; TO SUBMIT BUG REPORTS (or feedback of any sort)... | |
40 | ;; | |
41 | ;; M-x hilit-submit-feedback RET | |
42 | ;; | |
43 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
44 | ;; | |
733619f9 | 45 | ;; hilit19.el,v 2.19 1993/09/08 18:44:10 stig Release |
9a5e9959 RS |
46 | ;; |
47 | ;; LCD Archive Entry: | |
6267bd25 | 48 | ;; hilit19|Jonathan Stigelman|stig@hackvan.com| |
280a6a9f | 49 | ;; Comprehensive (and comparatively fast) regex-based highlighting for Emacs 19| |
733619f9 | 50 | ;; 1993/09/08 18:44:10|Release 2.19|~/packages/hilit19.el.Z| |
9a5e9959 RS |
51 | ;; |
52 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
53 | ;; | |
54 | ;; GENERAL OVERVIEW | |
55 | ;; | |
56 | ;; This package installs numerous hooks to colorfully highlight your | |
57 | ;; source code buffers as well as mail and news buffers. Most | |
58 | ;; programming languages have predefined highlighting patterns. | |
59 | ;; Just load hilit19 and files will be automatically highlighted as | |
60 | ;; they're loaded. | |
61 | ;; | |
62 | ;; Rehighlight a buffer by typing C-S-l (control-shift-lowercase-L). | |
63 | ;; | |
64 | ;; If, when you edit the buffer, the coloring gets messed up, just | |
65 | ;; redraw and the coloring will be adjusted. If automatic highlighting | |
66 | ;; in the current buffer has been turned off, then typing C-u C-S-l will | |
67 | ;; force a rehighlight of the entire buffer. | |
68 | ;; | |
69 | ;; Hilit19 can build faces by examining the names that you give to them | |
70 | ;; For example, green/black-bold-italic-underline would be created as | |
71 | ;; a face with a green foreground, and a black background, using a | |
72 | ;; bold-italic font...with underlining for good measure. | |
73 | ;; | |
74 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
75 | ;; | |
76 | ;; SETUP -- In your .emacs: | |
77 | ;; | |
280a6a9f RS |
78 | ;; |
79 | ;; (cond (window-system | |
80 | ;; (setq hilit-mode-enable-list '(not text-mode) | |
81 | ;; hilit-background-mode 'light | |
82 | ;; hilit-inhibit-hooks nil | |
83 | ;; hilit-inhibit-rebinding nil) | |
84 | ;; | |
85 | ;; (require 'hilit19) | |
86 | ;; )) | |
87 | ;; | |
88 | ;; If you like font-lock-mode and want to use both packages, then you can | |
89 | ;; disable hilit for the modes in which you want to use font-lock by listing | |
90 | ;; said modes in hilit-mode-enable-list. | |
91 | ;; | |
9a5e9959 RS |
92 | ;; (hilit-translate type 'RoyalBlue ; enable highlighting in C/C++ |
93 | ;; string nil) ; disable string highlighting | |
94 | ;; | |
95 | ;; To get 100% of the utility of hilit19, you may also have to apply the | |
96 | ;; patches below for info.el and vm5.33L_19/vm-summary.el | |
97 | ;; | |
98 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
99 | ;; | |
100 | ;; SETUP -- Are you using the right font for Emacs? | |
101 | ;; | |
102 | ;; Emacs cannot properly find bold and italic fonts unless you specify a | |
733619f9 RS |
103 | ;; verbose X11 font name. If you specify a font for emacs in your |
104 | ;; .Xdefaults, it *MUST* be specified using the long form of the font name. | |
105 | ;; Here's a good font menu: | |
9a5e9959 RS |
106 | ;; |
107 | ;; (setq | |
108 | ;; x-fixed-font-alist | |
109 | ;; '("Font Menu" | |
733619f9 | 110 | ;; ("Misc" |
9a5e9959 RS |
111 | ;; ("6x12" "-misc-fixed-medium-r-semicondensed--12-110-75-75-c-60-*-1") |
112 | ;; ("6x13" "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-*-1") | |
113 | ;; ("lucida 13" | |
114 | ;; "-b&h-lucidatypewriter-medium-r-normal-sans-0-0-0-0-m-0-*-1") | |
115 | ;; ("7x13" "-misc-fixed-medium-r-normal--13-120-75-75-c-70-*-1") | |
116 | ;; ("7x14" "-misc-fixed-medium-r-normal--14-130-75-75-c-70-*-1") | |
117 | ;; ("9x15" "-misc-fixed-medium-r-normal--15-140-*-*-c-*-*-1") | |
118 | ;; ("") | |
119 | ;; ("clean 8x8" "-schumacher-clean-medium-r-normal--*-80-*-*-c-*-*-1") | |
120 | ;; ("clean 8x14" "-schumacher-clean-medium-r-normal--*-140-*-*-c-*-*-1") | |
121 | ;; ("clean 8x10" "-schumacher-clean-medium-r-normal--*-100-*-*-c-*-*-1") | |
122 | ;; ("clean 8x16" "-schumacher-clean-medium-r-normal--*-160-*-*-c-*-*-1") | |
123 | ;; ("") | |
124 | ;; ("sony 8x16" "-sony-fixed-medium-r-normal--16-120-100-100-c-80-*-1") | |
125 | ;; ("") | |
126 | ;; ("-- Courier --") | |
127 | ;; ("Courier 10" "-adobe-courier-medium-r-normal--*-100-*-*-m-*-*-1") | |
128 | ;; ("Courier 12" "-adobe-courier-medium-r-normal--*-120-*-*-m-*-*-1") | |
129 | ;; ("Courier 14" "-adobe-courier-medium-r-normal--*-140-*-*-m-*-*-1") | |
130 | ;; ("Courier 18" "-adobe-courier-medium-r-normal--*-180-*-*-m-*-*-1") | |
131 | ;; ("Courier 18-b" "-adobe-courier-bold-r-normal--*-180-*-*-m-*-*-1") | |
132 | ;; ))) | |
133 | ;; | |
134 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
135 | ;; | |
136 | ;; KNOWN BUGS/TO DO LIST/HELP WANTED/APPLY WITHIN | |
137 | ;; | |
280a6a9f | 138 | ;; * unbalanced, unescaped double quote characters can confuse hilit19. |
733619f9 | 139 | ;; This will be fixed someday, so don't bug me about it. |
9a5e9959 | 140 | ;; |
280a6a9f RS |
141 | ;; * ALTHOUGH HILIT19 IS FASTER THAN FONT-LOCK-MODE... |
142 | ;; For various reasons, the speed of the package could still stand to be | |
143 | ;; improved. If you care to do a little profiling and make things tighter... | |
9a5e9959 | 144 | ;; |
280a6a9f RS |
145 | ;; * hilit-toggle-highlight is flaky when auto-rehighlight is neither t nor nil. |
146 | ;; Does anyone actually USE this? I think I might just remove it. | |
9a5e9959 RS |
147 | ;; |
148 | ;; PROJECTS THAT YOU CAN TAKE OVER BECAUSE I DON'T MUCH CARE ABOUT THEM... | |
149 | ;; | |
150 | ;; * Moved hilit-wysiwyg-replace here from my version of man.el, this is not | |
151 | ;; a bug. The bug is that I don't have a reverse operation yet...just a | |
152 | ;; stub Wysiwyg-anything really belongs in a package of it's own. | |
153 | ;; | |
154 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
155 | ;; | |
156 | ;; Thanks to the following people for their input: | |
280a6a9f RS |
157 | ;; ebert@enpc.enpc.fr (Rolf EBERT), ada, LaTeX & bibtex highlights |
158 | ;; Vivek Khera <khera@cs.duke.edu>, gnus hooks + random advice & patches | |
159 | ;; brian@athe.WUstl.EDU (Brian Dunford-Shore), prolog highlights | |
160 | ;; John Ladwig <jladwig@soils.umn.edu>, 1st pass nroff highlights | |
161 | ;; campo@sunthpi3.difi.unipi.it (Massimo Campostrini), fortran highlights | |
162 | ;; jayb@laplace.MATH.ColoState.EDU (Jay Bourland), 1st pass dired | |
163 | ;; Yoshio Turner <yoshio@CS.UCLA.EDU>, modula 2 highlights | |
164 | ;; Fritz Knabe <knabe@ecrc.de>, advice & patches | |
165 | ;; Alon Albert <alon@milcse.rtsg.mot.com>, advice & patches | |
166 | ;; dana@thumper.bellcore.com (Dana A. Chee), working on the multi-frame bug | |
167 | ;; derway@ndc.com (Don Erway), for breaking it... | |
733619f9 RS |
168 | ;; moss_r@summer.chem.su.oz.au (Richard Moss), first pass at add-pattern |
169 | ;; Olivier Lecarme <ol@aiguemarine.unice.fr>, Pascal & Icon patterns | |
9a5e9959 RS |
170 | ;; |
171 | ;; With suggestions and minor regex patches from numerous others... | |
172 | ;; | |
173 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
174 | ;; | |
280a6a9f | 175 | ;; hilit19.el,v |
733619f9 RS |
176 | ;; Revision 2.19 1993/09/08 18:44:10 stig |
177 | ;; installed patch for elusive bug in hilit-rehighlight-region that caused | |
178 | ;; hilit-unhighlight-region to hang in an infinite loop. | |
179 | ;; | |
180 | ;; Revision 2.18 1993/08/27 03:51:00 stig | |
181 | ;; minor mods to lisp-mode and c/c++ mode patterns | |
182 | ;; | |
183 | ;; Revision 2.17 1993/08/25 02:19:17 stig | |
184 | ;; work-around for bug in next-overlay-change that caused dired and jargon-mode | |
185 | ;; to hang in an endless loop. Perhaps other modes were doing this too. | |
186 | ;; | |
187 | ;; Revision 2.16 1993/08/22 19:46:00 stig | |
188 | ;; bug fix for next-overlay-change and accompanying change to | |
189 | ;; hilit-unhighlight-region | |
190 | ;; | |
191 | ;; Revision 2.15 1993/08/20 12:16:22 stig | |
192 | ;; minor change to fortran patterns | |
193 | ;; | |
194 | ;; Revision 2.14 1993/08/17 14:12:10 stig | |
195 | ;; added default face mapping for 'formula' which is needed for new latex | |
196 | ;; patterns. | |
197 | ;; | |
198 | ;; twiddled the calendar-mode patterns a bit. | |
199 | ;; | |
200 | ;; Revision 2.13 1993/08/16 04:33:54 stig | |
201 | ;; hilit-set-mode-patterns was screwing up two part patterns. it doesn't now. | |
202 | ;; | |
203 | ;; Revision 2.12 1993/08/16 00:16:41 stig | |
204 | ;; changed references to default-bold-italic to just bold-italic because the | |
205 | ;; font for that face is maintained by emacs. | |
206 | ;; | |
207 | ;; the pattern matcher now starts it's searches from the end of the most | |
208 | ;; recently highlighted region (which is not necessarily the end of the most | |
209 | ;; recently matched regex). | |
210 | ;; | |
211 | ;; multiple errors in pattern matcher now just give an error instead of lots of | |
212 | ;; annoying messages and dings. | |
213 | ;; | |
214 | ;; no longer use vm-summary-mode-hooks. | |
215 | ;; | |
216 | ;; some code moved from hilit-highlight-region to hilit-set-mode-patterns. | |
217 | ;; This will affect you if you pass your patterns directly to | |
218 | ;; hilit-highlight-region....use a pseudo-mode instead. | |
219 | ;; | |
220 | ;; pattern changes to C/C++, latex, texinfo, fortran, nroff, etc. | |
221 | ;; | |
222 | ;; Revision 2.11 1993/08/13 12:12:37 stig | |
223 | ;; removed some crufty commented-out code | |
224 | ;; | |
225 | ;; diverged lisp-mode and emacs-lisp-mode...also added lisp keywords. | |
226 | ;; | |
227 | ;; Revision 2.10 1993/08/13 09:47:06 stig | |
228 | ;; added calendar-mode, icon-mode and pascal-mode patterns | |
229 | ;; | |
230 | ;; commented out hilit-toggle-highlight because I want to phase it out entirely | |
231 | ;; | |
232 | ;; Revision 2.9 1993/08/13 08:44:22 stig | |
233 | ;; added optional case-fold argument to hilit-set-mode-patterns, this case-fold | |
234 | ;; parameter is now stored in hilit-patterns-alist. | |
235 | ;; | |
236 | ;; Revision 2.8 1993/08/12 22:05:03 stig | |
237 | ;; fixed some typos in documentation | |
238 | ;; | |
239 | ;; twiddled some of the color defaults for dark backgrounds | |
240 | ;; | |
241 | ;; always get 'mono color defaults if (not (x-display-color-p)) | |
242 | ;; | |
243 | ;; added hilit-rehighlight-buffer-quietly to dired-after-readin-hook | |
244 | ;; | |
245 | ;; fixed bug in hilit-string-find that mishandled strings of the form: "\\" | |
246 | ;; | |
247 | ;; NEW FUNCTION: hilit-add-mode-pattern... kinda like add-hook for patterns | |
248 | ;; | |
249 | ;; fixed minor pattern bugs for latex-mode and emacs-lisp-mode | |
250 | ;; | |
280a6a9f RS |
251 | ;; Revision 2.7 1993/07/30 02:43:01 stig |
252 | ;; added const to the list of modifiers for C/C++ types | |
9a5e9959 | 253 | ;; |
280a6a9f RS |
254 | ;; Revision 2.6 1993/07/30 00:30:54 stig |
255 | ;; now permit selection of arbitrary subexpressions for highlighting... | |
256 | ;; fixed keyword patterns for C/C++ using this technique. | |
9a5e9959 | 257 | ;; |
280a6a9f RS |
258 | ;; Revision 2.5 1993/07/28 05:02:56 stig |
259 | ;; improvements to makefile regular expressions | |
260 | ;; removed about 130 lines just by compacting the big defconst for | |
261 | ;; hilit-face-translation-table into a mapcar and defining a separate table | |
262 | ;; of default faces. | |
263 | ;; | |
264 | ;; Revision 2.4 1993/07/27 14:09:05 stig | |
265 | ;; documented another "known problem" to "head off gripe mail at the pass." | |
266 | ;; | |
267 | ;; Revision 2.3 1993/07/27 02:15:49 stig | |
268 | ;; (hilit-lookup-face-create) incorporated patch which improves it's behavior | |
269 | ;; with more than one frame... Still can't have bold on the same face in two | |
67bd87ba | 270 | ;; different fonts sizes at the same time... |
280a6a9f RS |
271 | ;; |
272 | ;; Revision 2.2 1993/07/27 02:02:59 stig | |
273 | ;; vastly improved the makefile patterns | |
274 | ;; added hook for mh-show-mode | |
9a5e9959 | 275 | ;; |
280a6a9f RS |
276 | ;; Revision 2.1 1993/07/24 17:46:21 stig |
277 | ;; Phasing out Info-select-hook... Version 19.18 will use Info-selection-hook. | |
278 | ;; | |
279 | ;; Revision 2.0 1993/07/24 13:50:10 stig | |
280 | ;; better documentation and added the function hilit-submit-feedback. | |
281 | ;; C-S-l (control shift l) repaints the buffer. Other bindings are optional. | |
282 | ;; multi-line highlights no longer cause problems when | |
283 | ;; hilit-auto-rehighlight is 'visible | |
284 | ;; added hilit-predefined-face-list... | |
285 | ;; changed name of hilit-mode-alist to hilit-patterns-alist | |
286 | ;; added hilit-message-quietly to mail-setup-hook | |
287 | ;; added hilit-parser-alist which can be used to apply different patterns to | |
288 | ;; different parts of a buffer. This could be integrated in a far more | |
289 | ;; elegant manner, but it presently serves the purpose of not applying | |
290 | ;; message header patterns to message bodies in mail-mode and it's kin. | |
291 | ;; hilit-set-mode-patterns now takes a list of modes and an optional parse-fn | |
292 | ;; | |
293 | ||
9a5e9959 RS |
294 | ;;;;;; AND THIS CAN BE APPLIED TO VM 5.33L_19 |
295 | ;; | |
296 | ;; *** ../site/vm5.33L_19/vm-summary.el Fri Jun 4 22:17:11 1993 | |
297 | ;; --- ./vm-summary.el Tue Jun 22 16:39:30 1993 | |
298 | ;; *************** | |
299 | ;; *** 152,158 **** | |
300 | ;; (insert "->") | |
301 | ;; (delete-char 2) | |
302 | ;; (forward-char -2) | |
303 | ;; ! (and w vm-auto-center-summary (vm-auto-center-summary)))) | |
304 | ;; (and old-window (select-window old-window))))))) | |
305 | ;; | |
306 | ;; (defun vm-mark-for-display-update (message) | |
307 | ;; --- 152,159 ---- | |
308 | ;; (insert "->") | |
309 | ;; (delete-char 2) | |
310 | ;; (forward-char -2) | |
311 | ;; ! (and w vm-auto-center-summary (vm-auto-center-summary)) | |
312 | ;; ! (run-hooks 'vm-summary-pointer-hook))) | |
313 | ;; (and old-window (select-window old-window))))))) | |
314 | ;; | |
315 | ;; (defun vm-mark-for-display-update (message) | |
316 | ;; | |
317 | ;;;;;; | |
318 | \f | |
4ccadbc0 | 319 | ;;; Code: |
9a5e9959 RS |
320 | |
321 | ;; User Options: | |
322 | ||
323 | (defvar hilit-quietly nil | |
324 | "* If non-nil, this inhibits progress indicators during highlighting") | |
325 | ||
9a5e9959 RS |
326 | (defvar hilit-auto-highlight t |
327 | "* T if we should highlight all buffers as we find 'em, nil to disable | |
328 | automatic highlighting by the find-file hook.") | |
329 | ||
733619f9 | 330 | (defvar hilit-auto-highlight-maxout 60000 ; hilit19 keeps getting bigger... |
9a5e9959 RS |
331 | "* auto-highlight is disabled in buffers larger than this") |
332 | ||
333 | (defvar hilit-auto-rehighlight t | |
334 | "* If this is non-nil, then hilit-redraw and hilit-recenter will also | |
280a6a9f RS |
335 | rehighlight part or all of the current buffer. T will rehighlight the |
336 | whole buffer, a NUMBER will rehighlight that many lines before and after | |
337 | the cursor, and the symbol 'visible' will rehighlight only the visible | |
338 | portion of the current buffer. This variable is buffer-local.") | |
9a5e9959 RS |
339 | |
340 | (make-variable-buffer-local 'hilit-auto-rehighlight) | |
9a5e9959 RS |
341 | |
342 | (defvar hilit-auto-rehighlight-fallback '(20000 . 100) | |
343 | "* Cons of the form (THRESHOLD . FALLBACK), where FALLBACK is assigned to | |
280a6a9f RS |
344 | hilit-auto-rehighlight if the size of a newly opened buffer is larger than |
345 | THRESHOLD.") | |
9a5e9959 RS |
346 | |
347 | (defvar hilit-face-check t | |
348 | "* T slows down highlighting but permits the user to change fonts without | |
280a6a9f RS |
349 | losing bold and italic faces... T causes hilit-lookup-face-create to dig |
350 | through the frame parameters for the current window every time it's called. | |
351 | If you never change fonts in emacs, set this to NIL.") | |
352 | ||
353 | ;; Variables which must be set before loading hilit19. | |
354 | ||
355 | (defvar hilit-inhibit-rebinding nil | |
356 | "If non-nil, this inhibits replacement of recenter, yank, and yank-pop.") | |
357 | ||
358 | (defvar hilit-inhibit-hooks nil | |
359 | "If non-nil, this inhibits installation of hooks for Info, gnus, & vm.") | |
360 | ||
361 | (defvar hilit-background-mode 'light | |
362 | "'mono inhibits color, 'dark or 'light indicate the background brightness.") | |
363 | ||
364 | (defvar hilit-mode-enable-list nil | |
365 | "If a list of modes to exclusively enable or specifically disable. | |
366 | The sense of the list is negated if it begins with the symbol 'not'. | |
367 | Set this variable before you load hilit19. | |
368 | ||
369 | Ex: (perl-mode jargon-mode c-mode) ; just perl, C, and jargon modes | |
370 | (not text-mode) ; all modes except text mode") | |
9a5e9959 RS |
371 | |
372 | ;; Variables that are not generally modified directly | |
373 | ||
374 | (defvar hilit-parser-alist nil | |
375 | "alist of major-mode values and parsers called by hilit-rehighlight-buffer. | |
376 | ||
377 | Parsers for a given mode are IGNORED for partial rehighlights...maybe you'd | |
378 | like to make this more universal?") | |
379 | ||
380 | (defvar hilit-patterns-alist nil | |
381 | "alist of major-mode values and default highlighting patterns | |
382 | ||
733619f9 RS |
383 | A highlighting pattern is a list of the form (start end face), where |
384 | start is a regex, end is either a regex or a match number for start, and face | |
9a5e9959 RS |
385 | is the name of an entry in hilit-face-translation-table, the name of a face, |
386 | or nil (which disables the pattern). | |
387 | ||
733619f9 RS |
388 | Each entry in the alist is of the form: |
389 | (mode . (case-fold pattern [pattern ...])) | |
390 | ||
9a5e9959 RS |
391 | See the hilit-lookup-face-create documentation for valid face names.") |
392 | ||
393 | (defvar hilit-predefined-face-list (face-list) | |
280a6a9f | 394 | "List of faces with which hilit-lookup-face-create will NOT tamper. |
9a5e9959 RS |
395 | |
396 | If hilit19 is dumped into emacs at your site, you may have to set this in | |
397 | your init file.") | |
398 | ||
733619f9 RS |
399 | (eval-when-compile (setq byte-optimize t)) |
400 | ||
9a5e9959 RS |
401 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
402 | ;; Use this to report bugs: | |
403 | ||
280a6a9f RS |
404 | (eval-when-compile (require 'reporter)) ; no compilation gripes |
405 | ||
733619f9 | 406 | (defun hilit-submit-feedback () |
6267bd25 | 407 | "Submit feedback on hilit19 to the author: stig@hackvan.com" |
9a5e9959 RS |
408 | (interactive) |
409 | (require 'reporter) | |
410 | (and (y-or-n-p "Do you really want to submit a report on hilit19? ") | |
411 | (reporter-submit-bug-report | |
6267bd25 | 412 | "Jonathan Stigelman <stig@hackvan.com>" |
733619f9 | 413 | "hilit19.el (Release 2.19)" |
9a5e9959 RS |
414 | (and (y-or-n-p "Do you need to include a dump hilit variables? ") |
415 | (append | |
416 | '( | |
417 | hilit-quietly hilit-inhibit-hooks | |
418 | hilit-background-mode hilit-mode-enable-list | |
419 | hilit-auto-highlight hilit-auto-highlight-maxout | |
420 | hilit-auto-rehighlight hilit-auto-rehighlight-fallback | |
421 | hilit-face-check | |
422 | ) | |
423 | (and (y-or-n-p "Have you modified the standard patterns? ") | |
424 | (yes-or-no-p "Are your patterns *REALLY* relevant? ") | |
425 | '(hilit-parser-alist | |
426 | hilit-patterns-alist | |
427 | hilit-predefined-face-list | |
428 | )))) | |
429 | (function | |
430 | (lambda () | |
280a6a9f RS |
431 | (and (y-or-n-p "Is this a problem with font display? ") |
432 | (insert "\nFrame Configuration:\n====================\n" | |
433 | (prin1-to-string (frame-configuration-to-register ?F)) | |
434 | "\n" | |
435 | )))) | |
9a5e9959 RS |
436 | nil |
437 | (concat | |
280a6a9f | 438 | "This is (check all that apply, and delete what's irrelevant):\n" |
9a5e9959 | 439 | " [ ] a _MASSIVE_THANK_YOU_ for writing hilit19.el\n" |
280a6a9f | 440 | " [ ] An invitation to attend the next Hackers Conference\n" |
9a5e9959 RS |
441 | " [ ] You're a RIGHTEOUS HACKER, what are your rates?\n" |
442 | " [ ] I've used the force and read the source, but I'M CONFUSED\n" | |
733619f9 | 443 | " [ ] a PATCH. (output of 'diff -uw old.el new.el' or 'diff -cw')\n" |
67bd87ba | 444 | " [ ] a SERIOUS AND REPRODUCIBLE BUG that is not an EMACS bug\n" |
9a5e9959 | 445 | " - I *swear* that it's not already mentioned in the KNOWN BUGS\n" |
67cbfd2a | 446 | " - I HAVE CHECKED ftp.hackvan.com:/pub/stig/src/elisp/hilit19.el.gz\n" |
9a5e9959 | 447 | " for a newer release that fixes the problem.\n" |
67cbfd2a | 448 | " >> I HAVE ALSO CHECKED ftp.hackvan.com:/pub/stig/src/elisp/hl319.el.gz\n" |
733619f9 | 449 | " This is the alpha version...what will become hilit19 (Beta 3.0).\n" |
9a5e9959 | 450 | "\n" |
280a6a9f | 451 | "Hey Stig, I *know* you're busy but...\n")))) |
9a5e9959 RS |
452 | |
453 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
454 | ;; | |
455 | ;; These faces are either a valid face name, or nil | |
456 | ;; if you want to change them, you must do so AFTER hilit19 is loaded | |
457 | ||
280a6a9f RS |
458 | (defconst hilit-default-face-table |
459 | '( | |
c0d79871 | 460 | ;; used for C/C++ and Emacs Lisp and perl |
280a6a9f | 461 | (comment firebrick-italic moccasin italic) |
733619f9 | 462 | (include purple Plum1 bold-italic) |
280a6a9f | 463 | (define ForestGreen-bold green bold) |
733619f9 | 464 | (defun blue-bold cyan-bold bold-italic) |
280a6a9f RS |
465 | (decl RoyalBlue cyan bold) |
466 | (type nil yellow nil) | |
733619f9 RS |
467 | (keyword RoyalBlue cyan bold-italic) |
468 | (label red-underline orange-underlined underline) | |
280a6a9f RS |
469 | (string grey40 orange underline) |
470 | ||
471 | ;; some further faces for Ada | |
472 | (struct black-bold white-bold bold) | |
473 | (glob-struct magenta Plum1 default-bold-underline) | |
474 | (named-param DarkGoldenrod Goldenrod underline) | |
9a5e9959 | 475 | |
67bd87ba | 476 | ;; and another one for LaTeX |
280a6a9f | 477 | (crossref DarkGoldenrod Goldenrod underline) |
733619f9 | 478 | (formula Goldenrod DarkGoldenrod underline) |
9a5e9959 | 479 | |
280a6a9f | 480 | ;; compilation buffers |
733619f9 RS |
481 | (active-error default/pink-bold default/DeepPink-bold default-underline) |
482 | (error red-bold yellow bold) | |
483 | (warning blue-italic green italic) | |
280a6a9f RS |
484 | |
485 | ;; Makefiles (some faces borrowed from C/C++ too) | |
733619f9 | 486 | (rule blue-bold-underline cyan-underline default-bold-underline) |
280a6a9f RS |
487 | |
488 | ;; VM, GNUS and Text mode | |
489 | (msg-subject blue-bold yellow bold) | |
733619f9 | 490 | (msg-from purple-bold green bold) |
280a6a9f | 491 | (msg-header firebrick-bold cyan italic) |
733619f9 RS |
492 | (msg-separator black/tan-bold black/lightblue nil) |
493 | (msg-quote ForestGreen pink italic) | |
280a6a9f RS |
494 | |
495 | (summary-seen grey40 white nil) | |
496 | (summary-killed grey50 white nil) | |
497 | (summary-Xed OliveDrab2 green nil) | |
498 | (summary-deleted firebrick white italic) | |
499 | (summary-unread RoyalBlue yellow bold) | |
733619f9 RS |
500 | (summary-new blue-bold yellow-bold bold-italic) |
501 | (summary-current default/skyblue-bold green/dimgrey-bold reverse-default) | |
280a6a9f RS |
502 | |
503 | (gnus-group-unsubscribed grey50 white nil) | |
733619f9 | 504 | (gnus-group-empty nil nil nil) |
280a6a9f | 505 | (gnus-group-full ForestGreen green italic) |
733619f9 | 506 | (gnus-group-overflowing firebrick red bold-italic) |
280a6a9f RS |
507 | |
508 | ;; dired mode | |
509 | (dired-directory blue-bold cyan bold) | |
510 | (dired-link firebrick-italic green italic) | |
511 | (dired-ignored ForestGreen moccasin nil) | |
733619f9 | 512 | (dired-deleted red-bold-italic orange bold-italic) |
280a6a9f | 513 | (dired-marked purple Plum1 nil) |
9a5e9959 | 514 | |
280a6a9f RS |
515 | ;; Info-mode, and jargon-mode.el and prep.ai.mit.edu:/pub/gnu/jargon* |
516 | (jargon-entry blue-bold cyan bold) | |
517 | (jargon-xref purple-bold Plum1 italic) | |
518 | (jargon-keyword firebrick-underline yellow underline) | |
519 | ) | |
733619f9 RS |
520 | "alist of default faces (face . (light-default dark-default mono-default)) |
521 | ||
522 | There is no way for the user to modify this table such that it will have any | |
523 | effect upon the translations used by hilit19. Instead, use the function | |
524 | hilit-translate AFTER hilit19 has been loaded. | |
525 | ||
526 | See also the documentation for hilit-lookup-face-create.") | |
280a6a9f RS |
527 | |
528 | (defconst hilit-face-translation-table | |
733619f9 RS |
529 | (let ((index (or (and (x-display-color-p) |
530 | (cdr (assq hilit-background-mode | |
531 | '((light . 1) (dark . 2))))) | |
280a6a9f RS |
532 | 3))) |
533 | (mapcar (function (lambda (x) (cons (car x) (nth index x)))) | |
534 | hilit-default-face-table)) | |
535 | "alist that maps symbolic face-names to real face names") | |
9a5e9959 RS |
536 | |
537 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
538 | ;; To translate one face to another... | |
539 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
540 | ||
541 | (defmacro hilit-translate (&rest args) | |
542 | "(hilit-translate FROM TO FROM TO ...): translate each face FROM to the | |
543 | value of its TO face. This is like setq for faces. | |
544 | ||
545 | The function hilit-lookup-face-create will repeatedly translate until no more | |
546 | translations for the face exist in the translation table. | |
547 | ||
280a6a9f | 548 | See the documentation for hilit-lookup-face-create for names of valid faces." |
9a5e9959 RS |
549 | (or (zerop (% (length args) 2)) |
550 | (error "wrong number of args")) | |
551 | (let (cmdl from to) | |
552 | (while args | |
553 | (setq from (car args) to (nth 1 args) args (nthcdr 2 args) | |
554 | cmdl (cons (list 'hilit-associate ''hilit-face-translation-table | |
280a6a9f | 555 | (list 'quote from) to) |
9a5e9959 RS |
556 | cmdl))) |
557 | (cons 'progn cmdl))) | |
558 | ||
559 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
560 | ;; This function actually translates and then creates the faces... | |
561 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
562 | ||
563 | (defun hilit-lookup-face-create (face &optional force) | |
564 | "Get a FACE, or create it if it doesn't exist. In order for it to | |
67bd87ba | 565 | properly create the face, the following naming convention must be used: |
9a5e9959 RS |
566 | [reverse-](fgcolor[/bgcolor])[-bold][-italic][-underline] |
567 | Example: (hilit-lookup-face-create 'comment-face) might create and return 'red | |
568 | ||
569 | Each color is either the name of an X color (see .../X11/lib/X11/rgb.txt), | |
570 | a hexadecimal specification of the form \"hex-[0-9A-Fa-f]+\", or \"default\". | |
571 | ||
572 | An optional argument, FORCE, will cause the face to be recopied from the | |
573 | default...which is probably of use only if you've changed fonts. | |
574 | ||
575 | See the documentation for hilit-translate and hilit-face-translation-table." | |
576 | ||
577 | ;; translate the face ... | |
578 | (let ((trec t) visited) | |
579 | (while trec | |
580 | (cond ((memq face visited) (error "face translation loop: %S" visited)) | |
581 | (t (setq visited (cons face visited) | |
582 | trec (assq face hilit-face-translation-table)) | |
583 | (and trec (setq face (cdr trec))))))) | |
584 | ||
585 | ;; make the face if we need to... | |
586 | (let* ((fn (symbol-name face)) | |
587 | (frame (selected-frame)) | |
588 | (basefont (cdr (assq 'font (frame-parameters frame)))) | |
589 | error fgcolor bgcolor) | |
590 | (cond | |
591 | ((or (null face) | |
592 | (memq face hilit-predefined-face-list)) | |
593 | ;; do nothing if the face is nil or if it's predefined. | |
594 | ) | |
595 | ((or force | |
596 | (not (memq face (face-list))) | |
597 | (and hilit-face-check | |
598 | (not (string= (get face 'basefont) basefont)))) | |
599 | (copy-face 'default 'scratch-face) | |
600 | (if (string-match "^reverse-?" fn) | |
601 | (progn (invert-face 'scratch-face) | |
602 | (setq fn (substring fn (match-end 0))))) | |
603 | ||
604 | ;; parse foreground color | |
605 | (if (string-match "^\\(hex-\\)?\\([A-Za-z0-9]+\\)" fn) | |
606 | (setq fgcolor (concat | |
607 | (if (match-beginning 1) "#") | |
608 | (substring fn (match-beginning 2) (match-end 2))) | |
609 | fn (substring fn (match-end 0))) | |
610 | (error "bad face name %S" face)) | |
611 | ||
612 | ;; parse background color | |
613 | (if (string-match "^/\\(hex-\\)?\\([A-Za-z0-9]+\\)" fn) | |
614 | (setq bgcolor (concat | |
615 | (and (match-beginning 1) "#") | |
616 | (substring fn (match-beginning 2) (match-end 2))) | |
617 | fn (substring fn (match-end 0)))) | |
618 | ||
619 | (and (string= "default" fgcolor) (setq fgcolor nil)) | |
620 | (and (string= "default" bgcolor) (setq bgcolor nil)) | |
621 | ||
622 | ;; catch errors if we can't allocate the color(s) | |
623 | (condition-case nil | |
624 | (progn (set-face-foreground 'scratch-face fgcolor) | |
625 | (set-face-background 'scratch-face bgcolor) | |
626 | (copy-face 'scratch-face face) | |
627 | (put face 'basefont basefont)) | |
628 | (error (message "couldn't allocate color for '%s'" | |
629 | (symbol-name face)) | |
630 | (setq face 'default) | |
631 | (setq error t))) | |
632 | (or error | |
633 | ;; don't bother w/ bold or italic if we didn't get the color | |
634 | ;; we wanted, but ignore errors making the face bold or italic | |
635 | ;; if the font isn't available, there's nothing to do about it... | |
636 | (progn | |
637 | (set-face-font face nil frame) | |
638 | (set-face-underline-p face (string-match "underline" fn)) | |
639 | (if (string-match ".*bold" fn) | |
ed6bdcdd KH |
640 | ;; make face bold in all frames |
641 | (make-face-bold face nil 'noerr)) | |
9a5e9959 | 642 | (if (string-match ".*italic" fn) |
ed6bdcdd KH |
643 | ;; make face italic in all frames |
644 | (make-face-italic face nil 'noerr)) | |
9a5e9959 RS |
645 | )) |
646 | ))) | |
647 | face) | |
648 | ||
649 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
650 | ;; Region Highlight/Unhighlight code (Both overlay and text-property versions) | |
651 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
652 | ||
653 | (defsubst hilit-region-set-face (start end face-name &optional prio prop) | |
654 | "Highlight region from START to END using FACE and, optionally, PRIO. | |
655 | The optional 5th arg, PROP is a property to set instead of 'hilit." | |
656 | (let ((overlay (make-overlay start end))) | |
657 | (overlay-put overlay 'face face-name) | |
658 | (overlay-put overlay (or prop 'hilit) t) | |
659 | (and prio (overlay-put overlay 'priority prio)))) | |
660 | ||
661 | (defun hilit-unhighlight-region (start end &optional quietly) | |
662 | "Unhighlights the region from START to END, optionally in a QUIET way" | |
663 | (interactive "r") | |
664 | (or quietly hilit-quietly (message "Unhighlighting")) | |
733619f9 RS |
665 | (let ((lstart 0)) |
666 | (while (and start (> start lstart) (< start end)) | |
667 | (mapcar (function (lambda (ovr) | |
668 | (and (overlay-get ovr 'hilit) (delete-overlay ovr)))) | |
669 | (overlays-at start)) | |
670 | (setq lstart start start (next-overlay-change start)))) | |
9a5e9959 RS |
671 | (or quietly hilit-quietly (message "Done unhighlighting"))) |
672 | ||
673 | ;;;; These functions use text properties instead of overlays. Text properties | |
674 | ;;;; are copied through kill and yank...which might be convenient, but is not | |
675 | ;;;; terribly efficient as of 19.12, ERGO it's been disabled | |
676 | ;; | |
677 | ;;(defsubst hilit-region-set-face (start end face-name &optional prio prop) | |
678 | ;; "Highlight region from START to END using FACE and, optionally, PRIO. | |
679 | ;;The optional 5th arg, PROP is a property to set instead of 'hilit." | |
680 | ;; (put-text-property start end 'face face-name) | |
681 | ;; ) | |
682 | ;; | |
683 | ;;(defun hilit-unhighlight-region (start end &optional quietly) | |
684 | ;; "Unhighlights the region from START to END, optionally in a QUIET way" | |
685 | ;; (interactive "r") | |
686 | ;; (let ((buffer-read-only nil) | |
687 | ;; (bm (buffer-modified-p))) | |
688 | ;; (remove-text-properties start end '(face)) | |
689 | ;; (set-buffer-modified-p bm))) | |
690 | ;;;; | |
691 | ||
692 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
693 | ;; Pattern Application code and user functions | |
694 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
695 | ||
696 | (defun hilit-highlight-region (start end &optional patterns quietly) | |
697 | "Highlights the area of the buffer between START and END (the region when | |
698 | interactive). Without the optional PATTERNS argument, the pattern for | |
699 | major-mode is used. If PATTERNS is a symbol, then the patterns associated | |
700 | with that symbol are used. QUIETLY suppresses progress messages if | |
701 | non-nil." | |
702 | (interactive "r") | |
703 | (cond ((null patterns) | |
704 | (setq patterns (cdr (assq major-mode hilit-patterns-alist)))) | |
705 | ((symbolp patterns) | |
706 | (setq patterns (cdr (assq patterns hilit-patterns-alist))))) | |
707 | ;; txt prop: (setq patterns (reverse patterns)) | |
733619f9 RS |
708 | (let ((case-fold-search (car patterns)) |
709 | (prio (1- (length patterns))) | |
9a5e9959 RS |
710 | ;; txt prop: (buffer-read-only nil) |
711 | ;; txt prop: (bm (buffer-modified-p)) | |
733619f9 | 712 | p pstart pend face mstart (puke-count 0)) |
9a5e9959 | 713 | ;; txt prop: (unwind-protect |
733619f9 | 714 | (setq patterns (cdr patterns)) ; remove case-fold from head of pattern |
9a5e9959 RS |
715 | (save-excursion |
716 | (save-restriction | |
717 | (narrow-to-region start end) | |
718 | (while patterns | |
719 | (setq p (car patterns)) | |
720 | (setq pstart (car p) | |
721 | pend (nth 1 p) | |
722 | face (hilit-lookup-face-create (nth 2 p))) | |
723 | (if (not face) ; skipped if nil | |
724 | nil | |
725 | (or quietly hilit-quietly | |
726 | (message "highlighting %d: %s%s" prio pstart | |
733619f9 | 727 | (if (stringp pend) (concat " ... " pend) ""))) |
9a5e9959 | 728 | (goto-char (point-min)) |
733619f9 | 729 | (condition-case msg |
9a5e9959 RS |
730 | (cond |
731 | ((symbolp pstart) | |
732 | ;; inner loop -- special function to find pattern | |
733 | (let (region) | |
734 | (while (setq region (funcall pstart pend)) | |
735 | (hilit-region-set-face (car region) (cdr region) | |
736 | face prio)))) | |
280a6a9f | 737 | ((stringp pend) |
9a5e9959 RS |
738 | ;; inner loop -- regex-start ... regex-end |
739 | (while (re-search-forward pstart nil t nil) | |
740 | (goto-char (setq mstart (match-beginning 0))) | |
741 | (if (re-search-forward pend nil t nil) | |
742 | (hilit-region-set-face mstart (match-end 0) | |
743 | face prio) | |
744 | (forward-char 1)))) | |
733619f9 | 745 | ((numberp pend) |
9a5e9959 RS |
746 | ;; inner loop -- just one regex to match whole pattern |
747 | (while (re-search-forward pstart nil t nil) | |
733619f9 | 748 | (goto-char (match-end pend)) |
280a6a9f | 749 | (hilit-region-set-face (match-beginning pend) |
733619f9 RS |
750 | (match-end pend) face prio))) |
751 | (t (error "malformed pattern"))) | |
752 | (error (if (> (setq puke-count (1+ puke-count)) 1) | |
753 | (error msg) | |
754 | (message "Error: '%s'" msg) | |
755 | (ding) (sit-for 4))))) | |
9a5e9959 RS |
756 | (setq prio (1- prio) |
757 | patterns (cdr patterns))) | |
733619f9 | 758 | )) |
9a5e9959 RS |
759 | (or quietly hilit-quietly (message "")) ; "Done highlighting" |
760 | ;; txt prop: (set-buffer-modified-p bm)) ; unwind protection | |
761 | )) | |
762 | ||
763 | (defun hilit-rehighlight-region (start end &optional quietly) | |
764 | "Re-highlights the region, optionally in a QUIET way" | |
765 | (interactive "r") | |
733619f9 RS |
766 | (save-restriction |
767 | (widen) | |
768 | (setq start (apply 'min start (mapcar 'overlay-start (overlays-at start))) | |
769 | end (apply 'max end (mapcar 'overlay-end (overlays-at end)))) | |
770 | (hilit-unhighlight-region start end quietly) | |
771 | (hilit-highlight-region start end nil quietly))) | |
9a5e9959 RS |
772 | |
773 | (defun hilit-rehighlight-buffer (&optional quietly) | |
774 | "Re-highlights the buffer, optionally in a QUIET way" | |
775 | (interactive "") | |
776 | (let ((parse-fn (cdr (assq major-mode hilit-parser-alist)))) | |
777 | (if parse-fn | |
778 | (funcall parse-fn quietly) | |
779 | (hilit-rehighlight-region (point-min) (point-max) quietly))) | |
780 | nil) | |
781 | ||
782 | (defun hilit-rehighlight-buffer-quietly () | |
783 | (hilit-rehighlight-buffer t)) | |
784 | ||
785 | (defun hilit-rehighlight-message (quietly) | |
786 | "Highlight a buffer containing a news article or mail message." | |
787 | (save-excursion | |
788 | (goto-char (point-min)) | |
789 | (re-search-forward "^$" nil 'noerr) | |
790 | (hilit-unhighlight-region (point-min) (point-max) quietly) | |
791 | (hilit-highlight-region (point-min) (point) 'msg-header quietly) | |
792 | (hilit-highlight-region (point) (point-max) 'msg-body quietly))) | |
793 | ||
794 | (defalias 'hilit-highlight-buffer 'hilit-rehighlight-buffer) | |
795 | ||
733619f9 RS |
796 | ;; Well, I want to remove this function...there's one sure way to find out if |
797 | ;; anyone uses it or not...and that's to comment it out. | |
798 | ;; | |
799 | ;; (defun hilit-toggle-highlight (arg) | |
800 | ;; "Locally toggle highlighting. With arg, forces highlighting off." | |
801 | ;; (interactive "P") | |
802 | ;; ;; FIXME -- this loses numeric information in hilit-auto-rehighlight | |
803 | ;; (setq hilit-auto-rehighlight | |
804 | ;; (and (not arg) (not hilit-auto-rehighlight))) | |
805 | ;; (if hilit-auto-rehighlight | |
806 | ;; (hilit-rehighlight-buffer) | |
807 | ;; (hilit-unhighlight-region (point-min) (point-max))) | |
808 | ;; (message "Rehighlighting is set to %s" hilit-auto-rehighlight)) | |
9a5e9959 RS |
809 | |
810 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
811 | ;; HOOKS | |
812 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
813 | ||
814 | (defun hilit-find-file-hook () | |
815 | "Find-file hook for hilit package. See the variable hilit-auto-highlight." | |
816 | (cond ((and hilit-auto-highlight | |
817 | (assq major-mode hilit-patterns-alist)) | |
818 | (if (> buffer-saved-size (car hilit-auto-rehighlight-fallback)) | |
819 | (setq hilit-auto-rehighlight | |
820 | (cdr hilit-auto-rehighlight-fallback))) | |
8b947f90 RS |
821 | (if (> buffer-saved-size hilit-auto-highlight-maxout) |
822 | nil | |
823 | (let ((bm (buffer-modified-p))) | |
824 | (hilit-rehighlight-buffer) | |
825 | (set-buffer-modified-p bm)))))) | |
9a5e9959 RS |
826 | |
827 | (defun hilit-repaint-command (arg) | |
828 | "Rehighlights according to the value of hilit-auto-rehighlight, or the | |
829 | prefix argument if that is specified. | |
830 | \t\\[hilit-repaint-command]\t\trepaint according to hilit-auto-rehighlight | |
831 | \t^U \\[hilit-repaint-command]\trepaint entire buffer | |
832 | \t^U - \\[hilit-repaint-command]\trepaint visible portion of buffer | |
833 | \t^U n \\[hilit-repaint-command]\trepaint n lines to either side of point" | |
834 | (interactive "P") | |
835 | (let (st en quietly) | |
836 | (or arg (setq arg hilit-auto-rehighlight)) | |
837 | (cond ((or (eq arg 'visible) (eq arg '-)) | |
838 | (setq st (window-start) en (window-end) quietly t)) | |
839 | ((numberp arg) | |
840 | (setq st (save-excursion (forward-line (- arg)) (point)) | |
841 | en (save-excursion (forward-line arg) (point)))) | |
842 | (arg | |
843 | (hilit-rehighlight-buffer))) | |
844 | (if st | |
845 | (hilit-rehighlight-region st en quietly)))) | |
846 | ||
9a5e9959 RS |
847 | (defun hilit-recenter (arg) |
848 | "Recenter, then rehighlight according to hilit-auto-rehighlight. If called | |
849 | with an unspecified prefix argument (^U but no number), then a rehighlight of | |
850 | the entire buffer is forced." | |
851 | (interactive "P") | |
852 | (recenter arg) | |
853 | ;; force display update | |
854 | (sit-for 0) | |
855 | (hilit-repaint-command (consp arg))) | |
856 | ||
9a5e9959 RS |
857 | (defun hilit-yank (arg) |
858 | "Yank with rehighlighting" | |
859 | (interactive "*P") | |
860 | (let ((transient-mark-mode nil)) | |
861 | (yank arg) | |
280a6a9f RS |
862 | (and hilit-auto-rehighlight |
863 | (hilit-rehighlight-region (region-beginning) (region-end) t)) | |
9a5e9959 RS |
864 | (setq this-command 'yank))) |
865 | ||
866 | (defun hilit-yank-pop (arg) | |
867 | "Yank-pop with rehighlighting" | |
868 | (interactive "*p") | |
869 | (let ((transient-mark-mode nil)) | |
870 | (yank-pop arg) | |
280a6a9f RS |
871 | (and hilit-auto-rehighlight |
872 | (hilit-rehighlight-region (region-beginning) (region-end) t)) | |
9a5e9959 RS |
873 | (setq this-command 'yank))) |
874 | ||
875 | ;;; this line highlighting stuff is untested. play with it only if you feel | |
876 | ;;; adventurous...don't ask me to fix it...though you're welcome to. -- Stig | |
877 | ;; | |
878 | ;; (defun hilit-rehighlight-line-quietly (&rest args) | |
879 | ;; "Quietly rehighlight just this line. | |
880 | ;; Useful as an after change hook in VM/gnus summary buffers and dired buffers. | |
881 | ;; If only there were an after-change-function, that is..." | |
882 | ;; (save-excursion | |
883 | ;; (push-mark nil t) | |
884 | ;; (hilit-rehighlight-yank-region) | |
885 | ;; (and orig-achange-function (apply orig-achange-function args)))) | |
886 | ;; | |
887 | ;; (defun hilit-install-line-hooks () | |
888 | ;; (make-variable-buffer-local 'after-change-function) | |
889 | ;; (make-local-variable 'orig-achange-function) | |
890 | ;; (setq orig-achange-function after-change-function) | |
891 | ;; (setq after-change-function 'hilit-rehighlight-line-quietly)) | |
892 | ||
893 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
894 | ;; Wysiwyg Stuff... take it away and build a whole package around it! | |
895 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
896 | ;; | |
897 | ;; ; For the Jargon-impaired, WYSIWYG === What You See Is What You Get | |
898 | ;; ; Sure, it sucks to type. Oh, well. | |
899 | ;; (defun hilit-wysiwyg-replace () | |
67bd87ba | 900 | ;; "Replace overstruck text with normal text that's been overlaid with the |
9a5e9959 RS |
901 | ;; appropriate text attribute. Suitable for a find-file hook." |
902 | ;; (save-excursion | |
903 | ;; (goto-char (point-min)) | |
904 | ;; (let ((wysb (hilit-lookup-face-create 'wysiwyg-bold)) | |
905 | ;; (wysu (hilit-lookup-face-create 'wysiwyg-underline)) | |
906 | ;; (bmod (buffer-modified-p))) | |
907 | ;; (while (re-search-forward "\\(.\b.\\)+" nil t) | |
908 | ;; (let ((st (match-beginning 0)) (en (match-end 0))) | |
909 | ;; (goto-char st) | |
910 | ;; (if (looking-at "_") | |
911 | ;; (hilit-region-set-face st en wysu 100 'wysiwyg) | |
912 | ;; (hilit-region-set-face st en wysb 100 'wysiwyg)) | |
913 | ;; (while (and (< (point) en) (looking-at ".\b")) | |
914 | ;; (replace-match "") (forward-char)) | |
915 | ;; )) | |
916 | ;; (set-buffer-modified-p bmod)))) | |
917 | ;; | |
918 | ;; ; is this more appropriate as a write-file-hook or a write-contents-hook? | |
919 | ;; (defun hilit-wysiwyg-write-repair () | |
920 | ;; "Replace wysiwyg overlays with overstrike text." | |
921 | ;; (message "*sigh* hilit-wysiwyg-write-repair not implemented yet") | |
922 | ;; | |
923 | ;; For efficiency, this hook should copy the current buffer to a scratch | |
924 | ;; buffer and do it's overstriking there. Overlays are not copied, so it'll | |
925 | ;; be necessary to hop back and forth. This is OK since you're not fiddling | |
926 | ;; with--making or deleting--any overlays. THEN write the new buffer, | |
927 | ;; delete it, and RETURN T. << important | |
928 | ;; | |
929 | ;; Just so you know...there is already an emacs function called | |
930 | ;; underline-region that does underlining. I think that the thing to do is | |
931 | ;; extend that to do overstriking as well. | |
932 | ;; | |
933 | ;; (while (< start end) | |
934 | ;; (mapcar (function (lambda (ovr) | |
935 | ;; (and (overlay-get ovr 'hilit) (delete-overlay ovr)))) | |
936 | ;; (overlays-at start)) | |
937 | ;; (setq start (next-overlay-change start))) | |
938 | ;; nil) | |
939 | ||
940 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
941 | ;; Initialization. | |
942 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
943 | ||
280a6a9f RS |
944 | (and (not hilit-inhibit-rebinding) |
945 | window-system | |
946 | (progn | |
947 | (substitute-key-definition 'yank 'hilit-yank | |
948 | (current-global-map)) | |
949 | (substitute-key-definition 'yank-pop 'hilit-yank-pop | |
950 | (current-global-map)) | |
951 | (substitute-key-definition 'recenter 'hilit-recenter | |
952 | (current-global-map)))) | |
9a5e9959 RS |
953 | |
954 | (global-set-key [?\C-\S-l] 'hilit-repaint-command) | |
955 | ||
956 | (and window-system | |
957 | (add-hook 'find-file-hooks 'hilit-find-file-hook t)) | |
958 | ||
280a6a9f RS |
959 | (eval-when-compile (require 'gnus)) ; no compilation gripes |
960 | ||
9a5e9959 RS |
961 | (and (not hilit-inhibit-hooks) |
962 | window-system | |
963 | (condition-case c | |
964 | (progn | |
965 | ||
966 | ;; BUFFER highlights... | |
967 | (mapcar (function | |
968 | (lambda (hook) | |
969 | (add-hook hook 'hilit-rehighlight-buffer-quietly))) | |
970 | '( | |
280a6a9f RS |
971 | Info-selection-hook |
972 | ||
733619f9 | 973 | ;; runs too early vm-summary-mode-hooks |
9a5e9959 | 974 | vm-summary-pointer-hook |
9a5e9959 RS |
975 | vm-preview-message-hook |
976 | vm-show-message-hook | |
280a6a9f | 977 | |
9a5e9959 RS |
978 | rmail-show-message-hook |
979 | mail-setup-hook | |
280a6a9f | 980 | mh-show-mode-hook |
733619f9 RS |
981 | |
982 | dired-after-readin-hook | |
9a5e9959 | 983 | )) |
9a5e9959 RS |
984 | ) |
985 | (error (message "Error loading highlight hooks: %s" c) | |
986 | (ding) (sit-for 1)))) | |
987 | ||
988 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
989 | ;; Default patterns for various modes. | |
990 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
991 | ||
992 | ;;; do I need this? I changed the defconst to a defvar because defconst is | |
993 | ;;; inappropriate, but I don't know why I wanted hilit-patterns-alist to be | |
994 | ;;; reset on every reload... | |
995 | ||
996 | (setq hilit-patterns-alist nil) | |
997 | ||
998 | (defun hilit-associate (alist key val) | |
999 | "creates, or destructively replaces, the pair (key . val) in alist" | |
1000 | (let ((oldentry (assq key (eval alist)))) | |
1001 | (if oldentry | |
1002 | (setcdr oldentry val) | |
1003 | (set alist (cons (cons key val) (eval alist)))))) | |
1004 | ||
733619f9 RS |
1005 | (defun hilit-set-mode-patterns (modelist patterns |
1006 | &optional parse-fn case-fold) | |
280a6a9f | 1007 | "Sets the default highlighting patterns for MODE to PATTERNS. |
733619f9 RS |
1008 | See the variable hilit-mode-enable-list. |
1009 | ||
1010 | Takes optional arguments PARSE-FN and CASE-FOLD." | |
1011 | ;; change pattern | |
1012 | (mapcar (function (lambda (p) | |
1013 | (and (stringp (car p)) | |
1014 | (null (nth 1 p)) | |
1015 | (setcar (cdr p) 0)))) | |
1016 | patterns) | |
1017 | (setq patterns (cons case-fold patterns)) | |
1018 | ||
9a5e9959 RS |
1019 | (or (consp modelist) (setq modelist (list modelist))) |
1020 | (let (ok (flip (eq (car hilit-mode-enable-list) 'not))) | |
1021 | (mapcar (function | |
1022 | (lambda (m) | |
1023 | (setq ok (or (null hilit-mode-enable-list) | |
1024 | (memq m hilit-mode-enable-list))) | |
1025 | (and flip (setq ok (not ok))) | |
1026 | (and ok | |
733619f9 RS |
1027 | (progn |
1028 | (and parse-fn | |
1029 | (hilit-associate 'hilit-parser-alist m parse-fn)) | |
1030 | (hilit-associate 'hilit-patterns-alist m patterns))))) | |
9a5e9959 RS |
1031 | modelist))) |
1032 | ||
733619f9 RS |
1033 | (defun hilit-add-pattern (pstart pend face &optional mode first) |
1034 | "Highlight pstart with face for the current major-mode. | |
1035 | Optionally, place the new pattern first in the pattern list" | |
1036 | (interactive "sPattern start regex: \nsPattern end regex (default none): \nxFace: ") | |
1037 | ||
1038 | (and (equal pstart "") (error "Must specify starting regex")) | |
1039 | (cond ((equal pend "") (setq pend 0)) | |
1040 | ((string-match "^[0-9]+$" pend) (setq pend (string-to-int pend)))) | |
1041 | (or mode (setq mode major-mode)) | |
1042 | (let ((old-patterns (cdr (assq mode hilit-patterns-alist))) | |
1043 | (new-pat (list pstart pend face))) | |
1044 | (cond ((not old-patterns) | |
1045 | (hilit-set-mode-patterns mode (list new-pat))) | |
1046 | (first | |
1047 | (setcdr old-patterns (cons new-pat (cdr old-patterns)))) | |
1048 | (t | |
1049 | (nconc old-patterns (list new-pat))))) | |
1050 | (and (interactive-p) (hilit-rehighlight-buffer))) | |
1051 | ||
9a5e9959 RS |
1052 | (defun hilit-string-find (qchar) |
1053 | "looks for a string and returns (start . end) or NIL. The argument QCHAR | |
1054 | is the character that would precede a character constant double quote. | |
733619f9 RS |
1055 | Finds strings delimited by double quotes. The first double quote may not be |
1056 | preceded by QCHAR and the closing double quote may not be preceded by an odd | |
1057 | number of backslashes." | |
9a5e9959 RS |
1058 | (let (st en) |
1059 | (while (and (search-forward "\"" nil t) | |
1060 | (eq qchar (char-after (1- (setq st (match-beginning 0))))))) | |
1061 | (while (and (search-forward "\"" nil t) | |
733619f9 RS |
1062 | (save-excursion |
1063 | (setq en (point)) | |
1064 | (forward-char -1) | |
1065 | (skip-chars-backward "\\\\") | |
1066 | (forward-char 1) | |
1067 | (not (zerop (% (- en (point)) 2)))))) | |
9a5e9959 RS |
1068 | (and en (cons st en)))) |
1069 | ||
733619f9 RS |
1070 | ;; return types on same line... |
1071 | ;; ("^[a-zA-z].*\\(\\w\\|[$_]\\)+\\s *\\(\\(\\w\\|[$_]\\)+\\s *((\\|(\\)[^)]*)+" nil defun) | |
9a5e9959 | 1072 | |
733619f9 RS |
1073 | ;; On another note, a working pattern for grabbing function definitions for C is |
1074 | ;; | |
1075 | ;; ("^[a-zA-Z_]+.*[;{]$" nil ForestGreen) ; global defns ( start at col 1 ) | |
1076 | ;; ("^[a-zA-Z_]+.*(" ")" defun) | |
1077 | ;; ; defuns assumed to start at col 1, not with # or { | |
1078 | ;; | |
1079 | ;; this will make external declarations/definitions green, and function | |
1080 | ;; definitions the defun face. Hmmm - seems to work for me anyway. | |
1081 | ||
1082 | (let ((comments '(("/\\*" "\\*/" comment))) | |
1083 | (c++-comments '(("//.*$" nil comment) | |
1084 | ("^/.*$" nil comment))) | |
1085 | (strings '((hilit-string-find ?' string))) | |
1086 | (preprocessor '(("^#[ \t]*\\(undef\\|define\\).*$" "[^\\]$" define) | |
1087 | ("^#.*$" nil include)))) | |
1088 | ||
1089 | (hilit-set-mode-patterns | |
1090 | '(c-mode c++-c-mode elec-c-mode) | |
1091 | (append | |
1092 | comments strings preprocessor | |
1093 | '( | |
1094 | ;; function decls are expected to have types on the previous line | |
1095 | ("^\\(\\w\\|[$_]\\)+\\s *\\(\\(\\w\\|[$_]\\)+\\s *((\\|(\\)[^)]*)+" nil defun) | |
1096 | ("^\\(typedef\\|struct\\|union\\|enum\\).*$" nil decl) | |
1097 | ;; datatype -- black magic regular expression | |
1098 | ("[ \n\t({]\\(\\(const\\|register\\|volatile\\|unsigned\\|extern\\|static\\)\\s +\\)*\\(\\(\\w\\|[$_]\\)+_t\\|float\\|double\\|void\\|char\\|short\\|int\\|long\\|FILE\\|\\(\\(struct\\|union\\|enum\\)\\([ \t]+\\(\\w\\|[$_]\\)*\\)\\)\\)\\(\\s +\\*+)?\\|[ \n\t;()]\\)" nil type) | |
1099 | ;; key words | |
1100 | ("[^_]\\<\\(return\\|goto\\|if\\|else\\|case\\|default\\|switch\\|break\\|continue\\|while\\|do\\|for\\)\\>[^_]" 1 keyword) | |
1101 | ))) | |
1102 | ||
1103 | (hilit-set-mode-patterns | |
1104 | 'c++-mode | |
1105 | (append | |
1106 | comments c++-comments strings preprocessor | |
1107 | '( | |
1108 | ;; function decls are expected to have types on the previous line | |
1109 | ("^\\(\\(\\w\\|[$_]\\)+::\\)?\\(\\w\\|[$_]\\)+\\s *\\(\\(\\w\\|[$_]\\)+\\s *((\\|(\\)[^)]*)+" nil defun) | |
1110 | ("^\\(\\(\\w\\|[$_]\\)+[ \t]*::[ \t]*\\)?\\(\\(\\w\\|[$_]\\)+\\|operator.*\\)\\s *\\(\\(\\w\\|[$_]\\)+\\s *((\\|(\\)[^)]*)+" nil defun) | |
1111 | ("^\\(template\\|typedef\\|struct\\|union\\|class\\|enum\\|public\\|private\\|protected\\).*$" nil decl) | |
1112 | ;; datatype -- black magic regular expression | |
1113 | ("[ \n\t({]\\(\\(const\\|register\\|volatile\\|unsigned\\|extern\\|static\\)\\s +\\)*\\(\\(\\w\\|[$_]\\)+_t\\|float\\|double\\|void\\|char\\|short\\|int\\|long\\|FILE\\|\\(\\(struct\\|union\\|enum\\|class\\)\\([ \t]+\\(\\w\\|[$_]\\)*\\)\\)\\)\\(\\s +\\*+)?\\|[ \n\t;()]\\)" nil type) | |
1114 | ;; key words | |
1115 | ("[^_]\\<\\(return\\|goto\\|if\\|else\\|case\\|default\\|switch\\|break\\|continue\\|while\\|do\\|for\\|public\\|protected\\|private\\|delete\\|new\\)\\>[^_]" | |
b7c2e3d8 RS |
1116 | 1 keyword)))) |
1117 | ||
1118 | (hilit-set-mode-patterns | |
1119 | '(objc-mode objective-C-mode) | |
1120 | (append | |
1121 | comments c++-comments strings preprocessor | |
1122 | '( | |
1123 | ;; function decls are expected to have types on the previous line | |
1124 | ("^\\(\\(\\w\\|[$_]\\)+::\\)?\\(\\w\\|[$_]\\)+\\s *\\(\\(\\w\\|[$_]\\)+\\s *((\\|(\\)[^)]*)+" nil defun) | |
1125 | ("^\\(\\(\\w\\|[$_]\\)+[ \t]*::[ \t]*\\)?\\(\\(\\w\\|[$_]\\)+\\|operator.*\\)\\s *\\(\\(\\w\\|[$_]\\)+\\s *((\\|(\\)[^)]*)+" nil defun) | |
1126 | ||
1127 | ("^\\(template\\|typedef\\|struct\\|union\\|class\\|enum\\|public\\|private\\|protected\\).*$" nil decl) | |
1128 | ;; datatype -- black magic regular expression | |
1129 | ("[ \n\t({]\\(\\(const\\|register\\|volatile\\|unsigned\\|extern\\|static\\)\\s +\\)*\\(\\(\\w\\|[$_]\\)+_t\\|float\\|double\\|void\\|char\\|short\\|int\\|long\\|FILE\\|\\(\\(struct\\|union\\|enum\\|class\\)\\([ \t]+\\(\\w\\|[$_]\\)*\\)\\)\\)\\(\\s +\\*+)?\\|[ \n\t;()]\\)" nil type) | |
1130 | ;; key words | |
1131 | ("[^_]\\<\\(return\\|goto\\|if\\|else\\|case\\|default\\|switch\\|break\\|continue\\|while\\|do\\|for\\|public\\|protected\\|private\\|interface\\|implementation\\|end\\|super\\|self\\)\\>[^_]" | |
1132 | 1 keyword)))) | |
1133 | ) | |
9a5e9959 RS |
1134 | |
1135 | (hilit-set-mode-patterns | |
1136 | 'perl-mode | |
1137 | '(("\\s #.*$" nil comment) | |
1138 | ("^#.*$" nil comment) | |
1139 | ("\"[^\\\"]*\\(\\\\\\(.\\|\n\\)[^\\\"]*\\)*\"" nil string) | |
1140 | ("^\\(__....?__\\|\\s *\\sw+:\\)" nil label) | |
1141 | ("^require.*$" nil include) | |
1142 | ("^package.*$" nil decl) | |
1143 | ("^\\s *sub\\s +\\(\\w\\|[_']\\)+" nil defun) | |
1144 | ("\\b\\(do\\|if\\|unless\\|while\\|until\\|else\\|elsif\\|for\\|foreach\\|continue\\|next\\|redo\\|last\\|goto\\|return\\|die\\|exit\\)\\b" nil keyword))) | |
1145 | ||
1146 | (hilit-set-mode-patterns | |
1147 | 'ada-mode | |
1148 | '(;; comments | |
1149 | ("--.*$" nil comment) | |
1150 | ;; main structure | |
1151 | ("[ \t\n]procedure[ \t]" "\\([ \t]\\(is\\|renames\\)\\|);\\)" glob-struct) | |
1152 | ("[ \t\n]task[ \t]" "[ \t]is" glob-struct) | |
1153 | ("[ \t\n]function[ \t]" "return[ \t]+[A-Za-z_0-9]+[ \t]*\\(is\\|;\\|renames\\)" glob-struct) | |
1154 | ("[ \t\n]package[ \t]" "[ \t]\\(is\\|renames\\)" glob-struct) | |
1155 | ;; if there is nothing before "private", it is part of the structure | |
1156 | ("^[ \t]*private[ \t\n]" nil glob-struct) | |
1157 | ;; if there is no indentation before the "end", then it is most | |
1158 | ;; probably the end of the package | |
1159 | ("^end.*$" ";" glob-struct) | |
1160 | ;; program structure -- "null", "delay" and "terminate" omitted | |
1161 | ("[ \n\t]\\(in\\|out\\|select\\|if\\|else\\|case\\|when\\|and\\|or\\|not\\|accept\\|loop\\|do\\|then\\|elsif\\|else\\|for\\|while\\|exit\\)[ \n\t;]" nil struct) | |
1162 | ;; block structure | |
1163 | ("[ \n\t]\\(begin\\|end\\|declare\\|exception\\|generic\\|raise\\|return\\|package\\|body\\)[ \n\t;]" nil struct) | |
1164 | ;; type declaration | |
1165 | ("^[ \t]*\\(type\\|subtype\\).*$" ";" decl) | |
1166 | ("[ \t]+is record.*$" "end record;" decl) | |
1167 | ;; "pragma", "with", and "use" are close to C cpp directives | |
1168 | ("^[ \t]*\\(with\\|pragma\\|use\\)" ";" include) | |
1169 | ;; nice for named parameters, but not so beautiful in case statements | |
1170 | ("[A-Za-z_0-9.]+[ \t]*=>" nil named-param) | |
1171 | ;; string constants probably not everybody likes this one | |
1172 | ("\"" ".*\"" string))) | |
1173 | ||
1174 | (hilit-set-mode-patterns | |
1175 | 'fortran-mode | |
1176 | '(("^[*Cc].*$" nil comment) | |
733619f9 | 1177 | ("'[^'\n]*'" nil string) |
9a5e9959 RS |
1178 | ("\\(^[ \t]*[0-9]+\\|[ \t]continue[ \t\n]\\|format\\)" nil define) |
1179 | ("[ \t]\\(do\\|do[ \t]*[0-9]+\\|go[ \t]*to[ \t]*[0-9]+\\|end[ \t]*do\\|if\\|else[ \t]*if\\|then\\|else\\|end[ \t]*if\\)[ \t\n(]" nil define) | |
733619f9 | 1180 | ("[ \t]\\(call\\|program\\|subroutine\\|function\\|stop\\|return\\|end\\|include\\)[ \t\n]" nil include) |
9a5e9959 RS |
1181 | ("[ \t]\\(parameter[\t\n ]*([^)]*)\\|data\\|save\\|common[ \t\n]*/[^/]*/\\)" |
1182 | nil decl) | |
1183 | ("^ ." nil type) | |
1184 | ("implicit[ \t]*none" nil decl) | |
1185 | ("\\([ \t]\\|implicit[ \t]*\\)\\(dimension\\|integer\\|real\\|double[ \t]*precision\\|character\\|logical\\|complex\\|double[ \t]*complex\\)\\([*][0-9]*\\|[ \t\n]\\)" nil keyword) | |
733619f9 RS |
1186 | ) |
1187 | nil 'case-insensitive) | |
9a5e9959 RS |
1188 | |
1189 | (hilit-set-mode-patterns | |
1190 | '(m2-mode modula-2-mode) | |
1191 | '(("(\\*" "\\*)" comment) | |
1192 | (hilit-string-find ?\\ string) | |
1193 | ("^[ \t]*PROCEDURE[ \t]+\\w+[^ \t(;]*" nil defun) | |
1194 | ("\\<\\(RECORD\\|ARRAY\\|OF\\|POINTER\\|TO\\|BEGIN\\|END\\|FOR\\|IF\\|THEN\\|ELSE\\|ELSIF\\|CASE\\|WHILE\\|DO\\|MODULE\\|FROM\\|RETURN\\|IMPORT\\|EXPORT\\|VAR\\|LOOP\\|UNTIL\\|\\DEFINITION\\|IMPLEMENTATION\\|AND\\|OR\\|NOT\\|CONST\\|TYPE\\|QUALIFIED\\)\\>" nil keyword) | |
733619f9 RS |
1195 | ) |
1196 | nil 'case-insensitive) | |
9a5e9959 RS |
1197 | |
1198 | (hilit-set-mode-patterns 'prolog-mode | |
1199 | '(("/\\*" "\\*/" comment) | |
1200 | ("%.*$" nil comment) | |
1201 | (":-" nil defun) | |
1202 | ("!" nil label) | |
1203 | ("\"[^\\\"]*\\(\\\\\\(.\\|\n\\)[^\\\"]*\\)*\"" nil string) | |
1204 | ("\\b\\(is\\|mod\\)\\b" nil keyword) | |
1205 | ("\\(->\\|-->\\|;\\|==\\|\\\\==\\|=<\\|>=\\|<\\|>\\|=\\|\\\\=\\|=:=\\|=\\\.\\\.\\|\\\\\\\+\\)" nil decl) | |
1206 | ("\\(\\\[\\||\\|\\\]\\)" nil include))) | |
1207 | ||
1208 | (hilit-set-mode-patterns | |
1209 | '( | |
1210 | LaTeX-mode japanese-LaTeX-mode SliTeX-mode | |
1211 | japanese-SliTeX-mode FoilTeX-mode latex-mode | |
1212 | ) | |
1213 | '( | |
1214 | ;; comments | |
1215 | ("[^\\]%.*$" nil comment) | |
1216 | ||
1217 | ;; the following two match \foo[xx]{xx} or \foo*{xx} or \foo{xx} | |
1218 | ("\\\\\\(sub\\)*\\(paragraph\\|section\\)\\(\*\\|\\[.*\\]\\)?{" "}" | |
1219 | keyword) | |
1220 | ("\\\\\\(chapter\\|part\\)\\(\*\\|\\[.*\\]\\)?{" "}" keyword) | |
1221 | ("\\\\footnote\\(mark\\|text\\)?{" "}" keyword) | |
1222 | ("\\\\[a-z]+box" nil keyword) | |
1223 | ("\\\\\\(v\\|h\\)space\\(\*\\)?{" "}" keyword) | |
1224 | ||
1225 | ;; (re-)define new commands/environments/counters | |
1226 | ("\\\\\\(re\\)?new\\(environment\\|command\\){" "}" defun) | |
1227 | ("\\\\new\\(length\\|theorem\\|counter\\){" "}" defun) | |
1228 | ||
1229 | ;; various declarations/definitions | |
1230 | ("\\\\\\(setlength\\|settowidth\\|addtolength\\|setcounter\\|addtocounter\\)" nil define) | |
733619f9 | 1231 | ("\\\\\\(title\\|author\\|date\\|thanks\\){" "}" define) |
9a5e9959 RS |
1232 | |
1233 | ("\\\\documentstyle\\(\\[.*\\]\\)?{" "}" decl) | |
1234 | ("\\\\\\(begin\\|end\\|nofiles\\|includeonly\\){" "}" decl) | |
1235 | ("\\\\\\(raggedright\\|makeindex\\|makeglossary\\|maketitle\\)\\b" nil | |
1236 | decl) | |
1237 | ("\\\\\\(pagestyle\\|thispagestyle\\|pagenumbering\\){" "}" decl) | |
1238 | ("\\\\\\(normalsize\\|small\\|footnotesize\\|scriptsize\\|tiny\\|large\\|Large\\|LARGE\\|huge\\|Huge\\)\\b" nil decl) | |
1239 | ("\\\\\\(appendix\\|tableofcontents\\|listoffigures\\|listoftables\\)\\b" | |
1240 | nil decl) | |
1241 | ("\\\\\\(bf\\|em\\|it\\|rm\\|sf\\|sl\\|ss\\|tt\\)\\b" nil decl) | |
1242 | ||
1243 | ;; label-like things | |
733619f9 RS |
1244 | ("\\\\item\\(\\[[^]]*\\]\\)?" nil label) |
1245 | ("\\\\caption\\(\\[[^]]*\\]\\)?{" "}" label) | |
1246 | ||
1247 | ;; formulas | |
103ffad5 RS |
1248 | ("[^\\]\\\\(" "\\\\)" formula) ; \( \) |
1249 | ("[^\\]\\\\\\[" "\\\\\\]" formula) ; \[ \] | |
96013d6f | 1250 | ("[^\\$]\\(\\$\\(\\$[^$]*\\$\\|[^$]*\\)\\$\\)" 1 formula) ; '$...$' or '$$...$$' |
733619f9 | 1251 | |
9a5e9959 RS |
1252 | ;; things that bring in external files |
1253 | ("\\\\\\(include\\|input\\|bibliography\\){" "}" include) | |
1254 | ||
280a6a9f RS |
1255 | ;; "wysiwyg" emphasis -- these don't work with nested expressions |
1256 | ;; ("{\\\\\\(em\\|it\\|sl\\)" "}" italic) | |
1257 | ;; ("{\\\\bf" "}" bold) | |
9a5e9959 RS |
1258 | |
1259 | ("``" "''" string) | |
1260 | ||
1261 | ;; things that do some sort of cross-reference | |
1262 | ("\\\\\\(\\(no\\)?cite\\|\\(page\\)?ref\\|label\\|index\\|glossary\\){" "}" crossref) | |
1263 | )) | |
1264 | ||
1265 | (hilit-set-mode-patterns | |
1266 | 'bibtex-mode | |
1267 | '(;;(";.*$" nil comment) | |
1268 | ("%.*$" nil comment) | |
1269 | ("@[a-zA-Z]+" nil keyword) | |
1270 | ("{[ \t]*[-a-z:_A-Z0-9]+," nil label) ; is wrong sometimes | |
1271 | ("^[ \t]*[a-zA-Z]+[ \t]*=" nil define))) | |
1272 | ||
1273 | (hilit-set-mode-patterns | |
1274 | 'compilation-mode | |
280a6a9f RS |
1275 | '( |
1276 | ("^[-_.\"A-Za-z0-9]+\\(:\\|, line \\)[0-9]+: warning:.*$" nil warning) | |
1277 | ("^[-_.\"A-Za-z0-9]+\\(:\\|, line \\)[0-9]+:.*$" nil error) | |
1278 | )) | |
9a5e9959 RS |
1279 | |
1280 | (hilit-set-mode-patterns | |
1281 | 'makefile-mode | |
1282 | '(("^#.*$" nil comment) | |
1283 | ("[^$]#.*$" nil comment) | |
1284 | ;; rules | |
280a6a9f | 1285 | ("^[^ \t\n]*%[^ \t\n]*[ \t]*::?[ \t]*[^ \t\n]*[ \t]*\\(#.*\\)?$" nil rule) |
9a5e9959 RS |
1286 | ("^[.][A-Za-z][A-Za-z]?\..*$" nil rule) |
1287 | ;; variable definition | |
280a6a9f RS |
1288 | ("^[_A-Za-z0-9]+[ \t]*\+?=" nil define) |
1289 | ("\\( \\|:=\\)[_A-Za-z0-9]+[ \t]*\\+=" nil define) | |
9a5e9959 | 1290 | ;; variable references |
280a6a9f RS |
1291 | ("\\$\\([^ \t\n{(]\\|[{(]@?[_A-Za-z0-9:.,%/=]+[)}]\\)" nil keyword) |
1292 | ("^[A-Za-z0-9.,/_-]+[ \t]*:.*$" nil defun) | |
9a5e9959 RS |
1293 | ("^include " nil include))) |
1294 | ||
1295 | (let* ((header-patterns '(("^Subject:.*$" nil msg-subject) | |
1296 | ("^From:.*$" nil msg-from) | |
1297 | ("^--text follows this line--$" nil msg-separator) | |
1298 | ("^[A-Za-z][A-Za-z0-9-]+:" nil msg-header))) | |
280a6a9f | 1299 | (body-patterns '(("^\\(In article\\|[ \t]*\\w*[]<>}|]\\).*$" |
9a5e9959 RS |
1300 | nil msg-quote))) |
1301 | (message-patterns (append header-patterns body-patterns))) | |
1302 | (hilit-set-mode-patterns 'msg-header header-patterns) | |
1303 | (hilit-set-mode-patterns 'msg-body body-patterns) | |
280a6a9f RS |
1304 | (hilit-set-mode-patterns '(vm-mode text-mode mail-mode rmail-mode |
1305 | gnus-article-mode news-reply-mode mh-show-mode) | |
1306 | message-patterns | |
1307 | 'hilit-rehighlight-message)) | |
9a5e9959 RS |
1308 | |
1309 | (hilit-set-mode-patterns | |
1310 | 'gnus-group-mode | |
aace9f6b EN |
1311 | '(("^ U.*$" nil gnus-group-unsubscribed) |
1312 | ("^\\*? +[01]?[0-9]:.*$" nil gnus-group-empty) | |
9a5e9959 RS |
1313 | ("^ +[2-9][0-9]:.*$" nil gnus-group-full) |
1314 | ("^ +[0-9][0-9][0-9]+:.*$" nil gnus-group-overflowing))) | |
1315 | ||
9a5e9959 RS |
1316 | (hilit-set-mode-patterns |
1317 | 'vm-summary-mode | |
1318 | '(("^ .*$" nil summary-seen) | |
1319 | ("^->.*$" nil summary-current) | |
1320 | ("^ D.*$" nil summary-deleted) | |
1321 | ("^ U.*$" nil summary-unread) | |
1322 | ("^ N.*$" nil summary-new))) | |
1323 | ||
1324 | ||
733619f9 RS |
1325 | ;;; this will match only comments w/ an even (zero is even) number of quotes... |
1326 | ;;; which is still inadequate because it matches comments in multi-line strings | |
1327 | ;;; how anal do you want to get about never highlighting comments in strings? | |
1328 | ;;; I could twiddle with this forever and still it wouldn't be perfect. | |
1329 | ;;; (";\\([^\"\n]*\"[^\"\n]*\"\\)*[^\"\n]*$" nil comment) | |
1330 | ||
9a5e9959 | 1331 | (hilit-set-mode-patterns |
733619f9 | 1332 | '(emacs-lisp-mode lisp-interaction-mode) |
9a5e9959 RS |
1333 | '( |
1334 | (";.*" nil comment) | |
733619f9 RS |
1335 | |
1336 | ;;; This almost works...but I think I'll stick with the parser function | |
1337 | ;;;("[^?]\\(\"\\(\"\\||\\([^\"]+\\|[\\]\\([\\][\\]\\)*\"\\)*\"\\)\\)" 1 string) | |
9a5e9959 | 1338 | (hilit-string-find ?\\ string) |
733619f9 RS |
1339 | |
1340 | ("^\\s *(def\\(un\\|macro\\|advice\\|alias\\|subst\\)[ \t\n]" | |
1341 | "\\()\\|nil\\)" defun) | |
9a5e9959 RS |
1342 | ("^\\s *(defvar\\s +\\S +" nil decl) |
1343 | ("^\\s *(defconst\\s +\\S +" nil define) | |
1344 | ("^\\s *(\\(provide\\|require\\|\\(auto\\)?load\\).*$" nil include) | |
733619f9 RS |
1345 | ("\\s *\\&\\(rest\\|optional\\)\\s *" nil keyword) |
1346 | ("(\\(let\\*?\\|cond\\|if\\|or\\|and\\|map\\(car\\|concat\\)\\|prog[n1*]?\\|while\\|lambda\\|function\\|set\\([qf]\\|car\\|cdr\\)?\\|nconc\\|eval-when-compile\\|condition-case\\|unwind-protect\\|catch\\|throw\\|error\\)[ \t\n]" 1 keyword) | |
1347 | )) | |
1348 | ||
1349 | (hilit-set-mode-patterns | |
1350 | '(lisp-mode ilisp-mode) | |
1351 | '( | |
1352 | (";.*" nil comment) | |
1353 | ("#|" "|#" comment) | |
1354 | ;;; This almost works...but I think I'll stick with the parser function | |
1355 | ;;;("[^?]\\(\"\\(\"\\||\\([^\"]+\\|[\\]\\([\\][\\]\\)*\"\\)*\"\\)\\)" 1 string) | |
1356 | (hilit-string-find ?\\ string) | |
1357 | ||
1358 | ;; this is waaaaaaaay too slow | |
1359 | ;; ("^\\s *(def\\(un\\|macro\\|advice\\|alias\\|method\\|subst\\)\\s \\S +[ \t\n]+\\(nil\\|(\\(([^()]*)\\|[^()]+\\)*)\\)" nil defun) | |
1360 | ("^\\s *(def\\(un\\|macro\\|advice\\|subst\\|method\\)\\s " "\\()\\|nil\\)" defun) | |
1361 | ||
1362 | ("^\\s *(\\(def\\(var\\|type\\|parameter\\)\\|declare\\)\\s +\\S +" nil decl) | |
9ee4654d | 1363 | ("^\\s *(def\\(const\\(ant\\)?\\|class\\|struct\\)\\s \\S +[ \t\n]+" nil define) |
733619f9 RS |
1364 | ("^\\s *(\\(provide\\|require\\|\\(auto\\)?load\\).*$" nil include) |
1365 | ("[ \t]\\&\\(key\\|rest\\|optional\\|aux\\)\\s *" nil keyword) | |
9ee4654d | 1366 | ("(\\(let\\*?\\|locally\\|cond\\|if\\*?\\|or\\|and\\|map\\(car\\|c[ao]n\\)?\\|prog[nv1*]?\\|while\\|when\\|unless\\|do\\(\\*\\|list\\|times\\)\\|list\\|lambda\\|function\\|values\\|set\\([qf]\\|car\\|cdr\\)?\\|rplac[ad]\\|nconc\\|block\\|go\\|return\\(-from\\)?\\|[ec]?\\(type\\)?case\\|multiple-value-\\(bind\\|setq\\|list\\|call\\|prog1\\)\\|unwind-protect\\|handler-case\\|catch\\|throw\\|eval-when\\(-compile\\)?\\)[ \t\n]" 1 keyword) |
9a5e9959 RS |
1367 | )) |
1368 | ||
1369 | ||
1370 | (hilit-set-mode-patterns | |
1371 | 'plain-tex-mode | |
1372 | '(("^%%.*$" nil comment) | |
1373 | ("{\\\\em\\([^}]+\\)}" nil comment) | |
1374 | ("\\(\\\\\\w+\\)" nil keyword) | |
1375 | ("{\\\\bf\\([^}]+\\)}" nil keyword) | |
1376 | ("^[ \t\n]*\\\\def[\\\\@]\\(\\w+\\)" nil defun) | |
1377 | ("\\\\\\(begin\\|end\\){\\([A-Za-z0-9\\*]+\\)}" nil defun) | |
733619f9 | 1378 | ;; ("[^\\\\]\\$\\([^$]*\\)\\$" nil string) |
9a5e9959 RS |
1379 | ("\\$\\([^$]*\\)\\$" nil string) |
1380 | )) | |
1381 | ||
1382 | ;; Reasonable extensions would include smarter parameter handling for such | |
1383 | ;; things as the .IX and .I macros, which alternate the handling of following | |
1384 | ;; arguments. | |
1385 | ||
1386 | (hilit-set-mode-patterns | |
1387 | 'nroff-mode | |
1388 | '(("^\\.[\\\][\\\"].*$" nil comment) | |
1389 | ("^\\.so .*$" nil include) | |
1390 | ("^\\.[ST]H.*$" nil defun) | |
1391 | ;; ("^[^\\.].*\"[^\\\"]*\\(\\\\\\(.\\)[^\\\"]*\\)*\"" nil string) | |
1392 | ("\"" "[^\\]\"" string) | |
733619f9 | 1393 | ("^\\.[A-Z12\\\\].*$" nil define) |
9a5e9959 | 1394 | ("\\([\\\][^ ]*\\)" nil keyword) |
733619f9 RS |
1395 | ("^\\.[A-Z].*$" nil keyword)) |
1396 | nil 'case-insensitive) | |
9a5e9959 RS |
1397 | |
1398 | (hilit-set-mode-patterns | |
1399 | 'texinfo-mode | |
1400 | '(("^\\(@c\\|@comment\\)\\>.*$" nil comment) | |
1401 | ("@\\(emph\\|strong\\|b\\|i\\){[^}]+}" nil comment) | |
733619f9 RS |
1402 | ;; seems broken |
1403 | ;; ("\\$[^$]*\\$" nil string) | |
9a5e9959 RS |
1404 | ("@\\(file\\|kbd\\|key\\){[^}]+}" nil string) |
1405 | ("^\\*.*$" nil defun) | |
1406 | ("@\\(if\\w+\\|format\\|item\\)\\b.*$" nil defun) | |
1407 | ("@end +[A-Za-z0-9]+[ \t]*$" nil defun) | |
1408 | ("@\\(samp\\|code\\|var\\){[^}]+}" nil defun) | |
1409 | ("@\\w+\\({[^}]+}\\)?" nil keyword) | |
1410 | )) | |
1411 | ||
1412 | (hilit-set-mode-patterns | |
1413 | 'dired-mode | |
1414 | (append | |
1415 | '(("^D.*$" nil dired-deleted) | |
1416 | ("^\\*.*$" nil dired-marked) | |
1417 | ("^ d.*$" nil dired-directory) | |
1418 | ("^ l.*$" nil dired-link) | |
1419 | ("^ -.*#.*#$" nil dired-ignored)) | |
1420 | (list (cons | |
1421 | (concat "^ .*\\(" | |
1422 | (mapconcat 'regexp-quote completion-ignored-extensions "\\|") | |
1423 | "\\)$") | |
1424 | '(nil dired-ignored))))) | |
1425 | ||
1426 | (hilit-set-mode-patterns | |
1427 | 'jargon-mode | |
1428 | '(("^:[^:]*:" nil jargon-entry) | |
1429 | ("{[^}]*}+" nil jargon-xref))) | |
1430 | ||
1431 | (hilit-set-mode-patterns | |
1432 | 'Info-mode | |
1433 | '(("^\\* [^:]+:+" nil jargon-entry) | |
1434 | ("\\*[Nn]ote\\b[^:]+:+" nil jargon-xref) | |
1435 | (" \\(Next\\|Prev\\|Up\\):" nil jargon-xref) | |
1436 | ("- \\(Variable\\|Function\\|Macro\\|Command\\|Special Form\\|User Option\\):.*$" | |
1437 | nil jargon-keyword))) ; lisp manual | |
1438 | ||
733619f9 RS |
1439 | (hilit-set-mode-patterns |
1440 | 'calendar-mode | |
1441 | '(("[A-Z][a-z]+ [0-9]+" nil define) ; month and year | |
9ee4654d | 1442 | ("S M Tu W Th F S" nil label))) ; week days |
733619f9 | 1443 | |
33f54425 KH |
1444 | (hilit-set-mode-patterns |
1445 | 'asm-mode | |
1446 | '(("/\\*" "\\*/" comment) | |
1447 | ("^#[ \t]*\\(undef\\|define\\).*$" "[^\\]$" define) | |
1448 | ("^#.*$" nil include) | |
1449 | ;; labels | |
1450 | ("^.+:" nil defun) | |
1451 | ;; assembler directives | |
1452 | ("^[ \t]*\\..*$" nil decl) | |
1453 | ;; register names | |
1454 | ("\\$[a-z0-9]+" nil string) | |
1455 | ;; mnemonics | |
1456 | ("^[ \t]*[a-z]+" nil struct))) | |
1457 | ||
733619f9 RS |
1458 | (hilit-set-mode-patterns |
1459 | 'pascal-mode | |
1460 | '(("(\\*" "\\*)" comment) | |
1461 | ("{" "}" comment) | |
1462 | ;; Doesn't work when there are strings in comments.... | |
1463 | ;; ("'[^']*'" nil string) | |
1464 | ("^#.*$" nil include) | |
1465 | ("^[ \t]*\\(procedure\\|function\\)[ \t]+\\w+[^ \t(;]*" nil defun) | |
1466 | ("\\<\\(program\\|begin\\|end\\)\\>" nil defun) | |
1467 | ("\\<\\(external\\|forward\\)\\>" nil include) | |
1468 | ("\\<\\(label\\|const\\|type\\|var\\)\\>" nil define) | |
1469 | ("\\<\\(record\\|array\\|file\\)\\>" nil type) | |
1470 | ("\\<\\(of\\|to\\|for\\|if\\|then\\|else\\|case\\|while\\|do\\|until\\|and\\|or\\|not\\|with\\|repeat\\)\\>" nil keyword) | |
1471 | ) | |
1472 | nil 'case-insensitive) | |
1473 | ||
1474 | (hilit-set-mode-patterns | |
1475 | 'icon-mode | |
1476 | '(("#.*$" nil comment) | |
1477 | ("\"[^\\\"]*\\(\\\\.[^\\\"]*\\)*\"" nil string) | |
1478 | ;; charsets: these do not work because of a conflict with strings | |
1479 | ;; ("'[^\\']*\\(\\\\.[^\\']*\\)*'" nil string) | |
1480 | ("^[ \t]*procedure[ \t]+\\w+[ \t]*(" ")" defun) | |
1481 | ("^[ \t]*record.*(" ")" include) | |
1482 | ("^[ \t]*\\(global\\|link\\)[ \t\n]+[A-Za-z_0-9]+\\([ \t\n]*,[ \t\n]*[A-Za-z_0-9]+\\)*" nil include) | |
1483 | ("^[ \t]*\\(local\\|static\\)[ \t\n]+[A-Za-z_0-9]+\\([ \t\n]*,[ \t\n]*[A-Za-z_0-9]+\\)*" nil decl) | |
1484 | ("\\<\\(initial\\|end\\)\\>" nil glob-struct) | |
1485 | ("\\<\\(while\\|until\\|return\\|every\\|if\\|then\\|else\\|to\\|case\\|of\\|suspend\\|create\\|do\\|repeat\\|break\\)\\>" nil keyword) | |
1486 | )) | |
1487 | ||
1488 | ;; as you can see, I had two similar problems for Pascal and Icon. In | |
1489 | ;; Pascal, strings are delimited with ' and an embedded quote is doubled, | |
1490 | ;; thus string syntax would be extremely simple. However, if a string | |
1491 | ;; occurs within a comment, the following text is considered a string. | |
1492 | ;; | |
1493 | ;; In Icon, strings are similar to C ones, but there are also charsets, | |
1494 | ;; delimited with simple quotes. I could not manage to use both regexps at | |
1495 | ;; the same time. | |
1496 | ||
1497 | ;; The problem I have with my patterns for Icon is that this language has a | |
1498 | ;; string similar constant to the C one (but a string can be cut on several | |
1499 | ;; lines, if terminated by a dash and continued with initial blanks, like | |
1500 | ;; this: | |
1501 | ;; "This is a somewhat long - | |
1502 | ;; string, written on three - | |
67bd87ba | 1503 | ;; successive lines" |
733619f9 RS |
1504 | ;; in order to insert a double quote in a string, you have to escape it |
1505 | ;; with a \), bu also a character set constant (named a charset), which | |
1506 | ;; uses single quotes instead of double ones. It would seem intuitive to | |
1507 | ;; highlight both constants in the same way. | |
1508 | ||
1509 | ||
9a5e9959 RS |
1510 | (provide 'hilit19) |
1511 | ||
1512 | ;;; hilit19 ends here. |