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