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