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