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