Mercurial > hg > xemacs
comparison generic-extras.el @ 18:2a3055313d1e
*** empty log message ***
author | ht |
---|---|
date | Sat, 19 Apr 2008 19:10:28 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
17:ee87d53174b1 | 18:2a3055313d1e |
---|---|
1 ;;; generic-extras.el --- Extra Modes for generic-mode | |
2 ;; | |
3 ;; Author: Peter Breton <pbreton@i-kinetics.com> | |
4 ;; Created: Tue Oct 08 1996 | |
5 ;; Version: $Id$ | |
6 ;; Keywords: | |
7 ;; Time-stamp: <98/02/10 22:48:22 pbreton> | |
8 ;; | |
9 ;; Copyright (C) Peter Breton 01Nov96 | |
10 ;; | |
11 ;; This is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 ;; | |
16 ;; generic-extras.el is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
19 ;; General Public License for more details. | |
20 ;; | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 ;; | |
25 ;; LCD Archive Entry: | |
26 ;; generic-extras|Peter Breton|pbreton@i-kinetics.com| | |
27 ;; Sample modes for 'generic-mode'| | |
28 ;; 01-Nov-1996|1.0|~/misc/generic-extras.el.gz| | |
29 ;; | |
30 ;;; Commentary: | |
31 ;; | |
32 ;; This file contains some pre-defined generic-modes. | |
33 ;; | |
34 ;; INSTALLATION: | |
35 ;; | |
36 ;; Add this line to your .emacs file: | |
37 ;; | |
38 ;; (require 'generic-extras) | |
39 ;; | |
40 ;; You can decide which modes to load by setting the variable | |
41 ;; 'generic-extras-enable-list'. Some platform-specific modes are | |
42 ;; affected by the variables 'generic-define-mswindows-modes' and | |
43 ;; 'generic-define-unix-modes' (which see). | |
44 ;; | |
45 ;; ALTERING THESE MODES: | |
46 ;; | |
47 ;; To alter the definition of these modes, use the 'alter-generic-mode-' | |
48 ;; convenience functions defined in generic-mode.el. Each of these functions | |
49 ;; takes an optional how-to-alter argument, which can be one of the following | |
50 ;; symbols: 'overwrite, 'append, 'prepend. | |
51 ;; | |
52 ;; You can also send me new modes (I'll accept ones for file types which are | |
53 ;; reasonably common) or patches to these ones. | |
54 ;; | |
55 ;; PROBLEMS WHEN USED WITH FOLDING MODE: | |
56 ;; | |
57 ;; From Anders Lindgren <andersl@csd.uu.se> | |
58 ;; | |
59 ;; Problem summary: Wayne Adams has found a problem when using folding | |
60 ;; mode in conjuction with font-lock for a mode defined in | |
61 ;; `generic-extras.el'. | |
62 ;; | |
63 ;; The problem, as Wayne described it, was that error messages of the | |
64 ;; following form appeared when both font-lock and folding are used: | |
65 ;; | |
66 ;; > - various msgs including "Fontifying region...(error Stack | |
67 ;; > overflow in regexp matcher)" appear | |
68 ;; | |
69 ;; I have just tracked down the cause of the problem. The regexp:s in | |
70 ;; `generic-extras.el' does not take into account the way that folding | |
71 ;; hides sections of the buffer. The technique is known as | |
72 ;; `selective-display' and has been available for a very long time (I | |
73 ;; started using it back in the good old' Emacs 18 days). Basically, a | |
74 ;; section is hidden by creating one very long line were the newline | |
75 ;; character (C-j) is replaced by a linefeed (C-m) character. | |
76 ;; | |
77 ;; Many other hiding packages, besides folding, use the same technique, | |
78 ;; the problem should occur when using them as well. | |
79 ;; | |
80 ;; The erroronous lines in `generic-extras' look like the following (this | |
81 ;; example is from the `ini' section): | |
82 ;; | |
83 ;; '(("^\\(\\[.*\\]\\)" 1 'font-lock-reference-face) | |
84 ;; ("^\\(.*\\)=" 1 'font-lock-variable-name-face) | |
85 ;; | |
86 ;; The intention of these lines is to highlight lines of the following | |
87 ;; form: | |
88 ;; | |
89 ;; [foo] | |
90 ;; bar = xxx | |
91 ;; | |
92 ;; However, since the `.' regexp symbol match the linefeed character the | |
93 ;; entire folded section is searched, resulting in a regexp stack | |
94 ;; overflow. | |
95 ;; | |
96 ;; Solution suggestion 2: Instead of using ".", use the sequence | |
97 ;; "[^\n\r]". This will make the rules behave just as before, but they | |
98 ;; will work together with selective-display. | |
99 ;; | |
100 ;; | |
101 ;;; Change log: | |
102 ;; $Log$ | |
103 ;; Revision 1.1 2008/04/19 18:10:28 ht | |
104 ;; *** empty log message *** | |
105 ;; | |
106 ;; Revision 1.5 1998/02/11 03:44:32 pbreton | |
107 ;; About to pull out generic-indent code | |
108 ;; | |
109 ;; Revision 1.4 1996/11/01 16:51:20 peter | |
110 ;; Added GPL and LCD information. | |
111 ;; | |
112 ;; Revision 1.3 1996/10/19 12:22:07 peter | |
113 ;; Added new versions of rc and rul modes | |
114 ;; Regexp patches for generic-bat-mode | |
115 ;; | |
116 ;; Revision 1.2 1996/10/17 01:02:41 peter | |
117 ;; Improved samba and apache modes | |
118 ;; Added fvwm and x-resource modes | |
119 ;; | |
120 | |
121 ;;; Code: | |
122 | |
123 (require 'generic-mode) | |
124 (require 'font-lock) | |
125 | |
126 (defvar generic-extras-enable-list nil | |
127 "*List of generic modes to enable by default. | |
128 Each entry in the list should be a symbol. | |
129 The variables `generic-define-mswindows-modes' and `generic-define-unix-modes' | |
130 also affect which generic modes are defined") | |
131 | |
132 (defvar generic-define-mswindows-modes | |
133 (memq system-type (list 'windows-nt 'ms-dos)) | |
134 "*If non-nil, some MS-Windows specific generic modes will be defined.") | |
135 | |
136 (defvar generic-define-unix-modes | |
137 (not generic-define-mswindows-modes) | |
138 "*If non-nil, some Unix specific generic modes will be defined.") | |
139 | |
140 (if generic-define-mswindows-modes | |
141 (setq generic-extras-enable-list | |
142 (append (list 'bat-generic-mode 'ini-generic-mode | |
143 'inf-generic-mode 'rc-generic-mode | |
144 'reg-generic-mode 'rul-generic-mode) | |
145 generic-extras-enable-list))) | |
146 | |
147 (if generic-define-unix-modes | |
148 (setq generic-extras-enable-list | |
149 (append (list 'apache-generic-mode 'samba-generic-mode | |
150 'hosts-generic-mode 'fvwm-generic-mode | |
151 'x-resource-generic-mode | |
152 'crontab-generic-mode) | |
153 generic-extras-enable-list))) | |
154 | |
155 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
156 ;; Generic-modes | |
157 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
158 | |
159 ;;; Apache | |
160 (and | |
161 (memq 'apache-generic-mode generic-extras-enable-list) | |
162 | |
163 (define-generic-mode 'apache-generic-mode | |
164 (list ?#) | |
165 nil | |
166 '(("^\\(<.*>\\)" 1 'font-lock-reference-face) | |
167 ("^\\(\\sw+\\)\\s-" 1 'font-lock-variable-name-face)) | |
168 (list "srm\\.conf$" "httpd\\.conf$" "access\\.conf$") | |
169 nil | |
170 "Generic mode for Apache or HTTPD configuration files.")) | |
171 | |
172 ;;; Samba | |
173 (and | |
174 (memq 'samba-generic-mode generic-extras-enable-list) | |
175 | |
176 (define-generic-mode 'samba-generic-mode | |
177 (list ?\;) | |
178 nil | |
179 '(("^\\(\\[.*\\]\\)" 1 'font-lock-reference-face)) | |
180 (list "smb\\.conf$") | |
181 (list 'generic-bracket-support) | |
182 "Generic mode for Samba configuration files.")) | |
183 | |
184 ;;; Fvwm | |
185 ;; This is pretty basic. Also, modes for other window managers could | |
186 ;; be defined as well. | |
187 (and | |
188 (memq 'fvwm-generic-mode generic-extras-enable-list) | |
189 | |
190 (define-generic-mode 'fvwm-generic-mode | |
191 (list ?#) | |
192 (list "Style" "Function" "EndFunction" "Popup" "EndPopup") | |
193 nil | |
194 (list "\\.fvwmrc") | |
195 nil | |
196 "Generic mode for FVWM configuration files.")) | |
197 | |
198 ;;; X Resource | |
199 ;; I'm pretty sure I've seen an actual mode to do this, but I don't | |
200 ;; think it's standard with Emacs | |
201 (and | |
202 (memq 'x-resource-generic-mode generic-extras-enable-list) | |
203 | |
204 (define-generic-mode 'x-resource-generic-mode | |
205 (list ?!) | |
206 nil | |
207 '(("^\\([^:\n]+:\\)" 1 'font-lock-variable-name-face)) | |
208 (list "\\.Xdefaults" "\\.Xresources") | |
209 nil | |
210 "Generic mode for X Resource configuration files.")) | |
211 | |
212 ;;; Hosts | |
213 (and | |
214 (memq 'hosts-generic-mode generic-extras-enable-list) | |
215 | |
216 (define-generic-mode 'hosts-generic-mode | |
217 (list ?#) | |
218 (list "localhost") | |
219 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 'font-lock-reference-face)) | |
220 (list "[hH][oO][sS][tT][sS]$") | |
221 nil | |
222 "Generic mode for HOSTS files.")) | |
223 | |
224 ;;; Windows INF files | |
225 (and | |
226 (memq 'inf-generic-mode generic-extras-enable-list) | |
227 | |
228 (define-generic-mode 'inf-generic-mode | |
229 (list ?\;) | |
230 nil | |
231 '(("^\\(\\[.*\\]\\)" 1 'font-lock-reference-face)) | |
232 (list "\\.[iI][nN][fF]") | |
233 (list 'generic-bracket-support) | |
234 "Generic mode for MS-Windows INF files.")) | |
235 | |
236 ;;; Windows INI files | |
237 ;; Should define escape character as well! | |
238 (and | |
239 (memq 'ini-generic-mode generic-extras-enable-list) | |
240 | |
241 (define-generic-mode 'ini-generic-mode | |
242 (list ?\;) | |
243 nil | |
244 '(("^\\(\\[.*\\]\\)" 1 'font-lock-reference-face) | |
245 ("^\\([^\n\r]*\\)=\\([^\n\r]*\\)$" | |
246 (1 font-lock-function-name-face) | |
247 (2 font-lock-variable-name-face))) | |
248 (list "\\.[iI][nN][iI]$") | |
249 (list | |
250 (function | |
251 (lambda () | |
252 (setq imenu-generic-expression | |
253 '((nil "^\\[\\(.*\\)\\]" 1) | |
254 ("*Variables*" "^\\s-*\\(.*\\)\\s-*=" 1))) | |
255 ))) | |
256 "Generic mode for MS-Windows INI files.")) | |
257 | |
258 ;;; Windows REG files | |
259 ;;; Unfortunately, Windows 95 and Windows NT have different REG file syntax! | |
260 (and | |
261 (memq 'reg-generic-mode generic-extras-enable-list) | |
262 | |
263 (define-generic-mode 'reg-generic-mode | |
264 '(?\;) | |
265 '("key" "classes_root" "REGEDIT" "REGEDIT4") | |
266 '(("\\(\\[.*]\\)" 1 'font-lock-reference-face) | |
267 ("^\\([^\n\r]*\\)\\s-*=" 1 'font-lock-variable-name-face)) | |
268 '("\\.[rR][eE][gG]$") | |
269 (list | |
270 (function | |
271 (lambda () | |
272 (setq imenu-generic-expression | |
273 '((nil "^\\s-*\\(.*\\)\\s-*=" 1)))))) | |
274 "Generic mode for MS-Windows Registry files.")) | |
275 | |
276 ;;; Windows BAT files | |
277 (if (not (memq 'bat-generic-mode generic-extras-enable-list)) | |
278 nil | |
279 (define-generic-mode 'bat-generic-mode | |
280 nil | |
281 nil | |
282 (list | |
283 ;; Make this one first in the list, otherwise comments will | |
284 ;; be over-written by other variables | |
285 (list "^[@ \t]*\\([rR][eE][mM][^\n\r]*\\)" 1 'font-lock-comment-face t) | |
286 (list "^[ \t]*\\(::-.*\\)" 1 'font-lock-comment-face t) | |
287 ;; These keywords appear as the first word on a line | |
288 (generic-make-keywords-list | |
289 (list | |
290 "[cC][aA][lL][lL]" | |
291 "[eE][cC][hH][oO]" | |
292 "[fF][oO][rR]" | |
293 "[iI][fF]" | |
294 "[pP][aA][tT][hH]" | |
295 "[pP][aA][uU][sS][eE]" | |
296 "[pP][rR][oO][mM][pP][tT]" | |
297 "[sS][eE][tT]" | |
298 "[sS][tT][aA][rR][tT]" | |
299 ) | |
300 'font-lock-keyword-face "^[@ \t]*") | |
301 ;; These keywords can be anywhere on a line | |
302 (generic-make-keywords-list | |
303 (list | |
304 "[eE][xX][iI][sS][tT]" | |
305 "[eE][rR][rR][oO][rR][lL][eE][vV][eE][lL]" | |
306 "[gG][oO][tT][oO]" | |
307 "[nN][oO][tT]" | |
308 ) 'font-lock-keyword-face) | |
309 (list "^[ \t]*\\(:\\sw+\\)" 1 'font-lock-function-name-face t) | |
310 (list "\\(%\\sw+%\\)" 1 'font-lock-reference-face) | |
311 (list "\\(%[0-9]\\)" 1 'font-lock-reference-face) | |
312 (list "\\(/[^/ \"\t\n]+\\)" 1 'font-lock-type-face) | |
313 (list "[\t ]+\\([+-][^\t\n\" ]+\\)" 1 'font-lock-type-face) | |
314 (list "\\<\\([gG][oO][tT][oO]\\)\\>[ \t]*\\(\\sw+\\)?" | |
315 '(1 font-lock-keyword-face) | |
316 '(2 font-lock-function-name-face nil t)) | |
317 | |
318 ) | |
319 (list "\\.[bB][aA][tT]$" "CONFIG\\." "AUTOEXEC\\." ) | |
320 (list 'generic-bat-mode-setup-function) | |
321 "Generic mode for MS-Windows BAT files.") | |
322 | |
323 (defvar bat-generic-mode-syntax-table nil | |
324 "Syntax table in use in bat-generic-mode buffers.") | |
325 | |
326 ;; Make underscores count as words | |
327 (if bat-generic-mode-syntax-table | |
328 nil | |
329 (setq bat-generic-mode-syntax-table (make-syntax-table)) | |
330 (modify-syntax-entry ?_ "w" bat-generic-mode-syntax-table)) | |
331 | |
332 ;; bat-generic-mode doesn't use the comment functionality of generic-mode | |
333 ;; because it has a three-letter comment-string, so we do it | |
334 ;; here manually instead | |
335 (defun generic-bat-mode-setup-function () | |
336 (make-local-variable 'parse-sexp-ignore-comments) | |
337 (make-local-variable 'comment-start) | |
338 (make-local-variable 'comment-start-skip) | |
339 (make-local-variable 'comment-end) | |
340 (setq imenu-generic-expression '((nil "^:\\(\\sw+\\)" 1)) | |
341 parse-sexp-ignore-comments t | |
342 comment-end "" | |
343 comment-start "[Rr][Ee][Mm] " | |
344 comment-start-skip "[Rr][Ee][Mm] *" | |
345 ) | |
346 (set-syntax-table bat-generic-mode-syntax-table) | |
347 ) | |
348 ) | |
349 | |
350 ;;; Windows RC files | |
351 ;; Contributed by ACorreir@pervasive-sw.com (Alfred Correira) | |
352 (and | |
353 (memq 'rc-generic-mode generic-extras-enable-list) | |
354 | |
355 (define-generic-mode 'rc-generic-mode | |
356 ;; (list ?\/) | |
357 (list "//") | |
358 '("ACCELERATORS" | |
359 "AUTO3STATE" | |
360 "AUTOCHECKBOX" | |
361 "AUTORADIOBUTTON" | |
362 "BITMAP" | |
363 "CAPTION" | |
364 "CHARACTERISTICS" | |
365 "CHECKBOX" | |
366 "CLASS" | |
367 "COMBOBOX" | |
368 "CONTROL" | |
369 "CTEXT" | |
370 "CURSOR" | |
371 "DEFPUSHBUTTON" | |
372 "DIALOG" | |
373 "EDITTEXT" | |
374 "EXSTYLE" | |
375 "FONT" | |
376 "GROUPBOX" | |
377 "ICON" | |
378 "LANGUAGE" | |
379 "LISTBOX" | |
380 "LTEXT" | |
381 "MENUITEM SEPARATOR" | |
382 "MENUITEM" | |
383 "MENU" | |
384 "POPUP" | |
385 "PUSHBOX" | |
386 "PUSHBUTTON" | |
387 "RADIOBUTTON" | |
388 "RCDATA" | |
389 "RTEXT" | |
390 "SCROLLBAR" | |
391 "SEPARATOR" | |
392 "STATE3" | |
393 "STRINGTABLE" | |
394 "STYLE" | |
395 "VERSIONINFO" | |
396 "VERSION" | |
397 ) | |
398 ;; the choice of what tokens go where is somewhat arbitrary, | |
399 ;; as is the choice of which value tokens are included, as | |
400 ;; the choice of face for each token group | |
401 (list | |
402 (generic-make-keywords-list | |
403 (list | |
404 "FILEFLAGSMASK" | |
405 "FILEFLAGS" | |
406 "FILEOS" | |
407 "FILESUBTYPE" | |
408 "FILETYPE" | |
409 "FILEVERSION" | |
410 "PRODUCTVERSION" | |
411 ) 'font-lock-type-face) | |
412 (generic-make-keywords-list | |
413 (list | |
414 "BEGIN" | |
415 "BLOCK" | |
416 "END" | |
417 "VALUE" | |
418 ) 'font-lock-function-name-face) | |
419 '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face) | |
420 '("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face) | |
421 '("^#[ \t]*\\(elif\\|if\\)\\>" | |
422 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil | |
423 (1 font-lock-reference-face) (2 font-lock-variable-name-face nil t))) | |
424 '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?" | |
425 (1 font-lock-reference-face) (2 font-lock-variable-name-face nil t))) | |
426 (list "\\.[rR][cC]$") | |
427 nil | |
428 "Generic mode for MS-Windows Resource files.")) | |
429 | |
430 ;;; InstallShield RUL files | |
431 ;; Contributed by ACorreir@pervasive-sw.com (Alfred Correira) | |
432 ;; Additional contributions by alex@brainstorm.fr (Alex Lemaresquier) | |
433 (and | |
434 (memq 'rul-generic-mode generic-extras-enable-list) | |
435 | |
436 (define-generic-mode 'rul-generic-mode | |
437 ;; Using "/*" and "*/" doesn't seem to be working right | |
438 (list "//") | |
439 '("begin" | |
440 "call" | |
441 "case" | |
442 "declare" | |
443 "default" | |
444 "downto" | |
445 "elseif" | |
446 "else" | |
447 "endfor" | |
448 "endif" | |
449 "endswitch" | |
450 "endwhile" | |
451 "end" | |
452 "exit" | |
453 "external" | |
454 "for" | |
455 "function" | |
456 ;; "goto" -- handled elsewhere | |
457 "if" | |
458 "program" | |
459 "prototype" | |
460 "repeat" | |
461 "return" | |
462 "step" | |
463 "switch" | |
464 "then" | |
465 "to" | |
466 "typedef" | |
467 "until" | |
468 "void" | |
469 "while") | |
470 (list | |
471 ;; preprocessor constructs | |
472 '("#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" | |
473 1 font-lock-string-face) | |
474 '("#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?" | |
475 (1 font-lock-reference-face) | |
476 (2 font-lock-variable-name-face nil t)) | |
477 ;; gotos | |
478 '("[ \t]*\\(\\sw+:\\)" 1 font-lock-reference-face) | |
479 '("\\<\\(goto\\)\\>[ \t]*\\(\\sw+\\)?" | |
480 (1 font-lock-keyword-face) | |
481 (2 font-lock-reference-face nil t)) | |
482 ;; system variables | |
483 (generic-make-keywords-list | |
484 (list | |
485 "CMDLINE" | |
486 "ERRORFILENAME" | |
487 "INFOFILENAME" | |
488 "ISRES" | |
489 "ISUSER" | |
490 "ISVERSION" | |
491 "SRCDIR" | |
492 "SRCDISK" | |
493 "SUPPORTDIR" | |
494 "TARGETDIR" | |
495 "TARGETDISK" | |
496 "WINDIR" | |
497 "WINDISK" | |
498 "WINMAJOR" | |
499 "WINSYSDIR" | |
500 "WINSYSDISK" | |
501 ) | |
502 'font-lock-variable-name-face) | |
503 ;; system functions | |
504 (generic-make-keywords-list | |
505 (list | |
506 "AddFolderIcon" | |
507 "AppCommand" | |
508 "AskDestPath" | |
509 "AskOptions" | |
510 "AskPath" | |
511 "AskText" | |
512 "AskYesNo" | |
513 "CloseFile" | |
514 "CmdGetHwndDlg" | |
515 "CompressEnum" | |
516 "CompressGet" | |
517 "CopyFile" | |
518 "CreateDir" | |
519 "CreateProgramFolder" | |
520 "DeinstallStart" | |
521 "Delay" | |
522 "DeleteDir" | |
523 "DeleteFile" | |
524 "Disable" | |
525 "DoInstall" | |
526 "Do" | |
527 "Enable" | |
528 "EnterDisk" | |
529 "ExistsDir" | |
530 "EzDefineDialog" | |
531 "FindFile" | |
532 "FindWindow" | |
533 "FileCompare" | |
534 "FileSetBeginDefine" | |
535 "FileSetEndDefine" | |
536 "FileSetPerformEz" | |
537 "FileSetPerform" | |
538 "GetDiskSpace" | |
539 "GetDisk" | |
540 "GetExtents" | |
541 "GetProfString" | |
542 "GetSystemInfo" | |
543 "GetVersion" | |
544 "GetWindowHandle" | |
545 "InstallationInfo" | |
546 "Is" | |
547 "LaunchApp" | |
548 "ListCreate" | |
549 "ListDestroy" | |
550 "ListGetFirstString" | |
551 "ListGetNextString" | |
552 "ListSetIndex" | |
553 "LongPathToQuote" | |
554 "LongPathToShortPath" | |
555 "MessageBox" | |
556 "NumToStr" | |
557 "OpenFile" | |
558 "ParsePath" | |
559 "PlaceBitmap" | |
560 "PlaceWindow" | |
561 "ProgDefGroupType" | |
562 "RegDBCreateKeyEx" | |
563 "RegDBGetItem" | |
564 "RegDBSetItem" | |
565 "RegDBGetKeyValueEx" | |
566 "RegDBSetKeyValueEx" | |
567 "RegDBSetDefaultRoot" | |
568 "RenameFile" | |
569 "SdSelectFolder" | |
570 "SdShowMsg" | |
571 "SdWelcome" | |
572 "SetColor" | |
573 "SetDialogTitle" | |
574 "SetFileInfo" | |
575 "SetForegroundWindow" | |
576 "SetStatusWindow" | |
577 "SetTitle" | |
578 "ShowProgramFolder" | |
579 "Sprintf" | |
580 "StatusUpdate" | |
581 "StrCompare" | |
582 "StrFind" | |
583 "StrGetTokens" | |
584 "StrLength" | |
585 "StrRemoveLastSlash" | |
586 "StrToLower" | |
587 "StrToUpper" | |
588 "StrSub" | |
589 "VarRestore" | |
590 "VarSave" | |
591 "WaitOnDialog" | |
592 "Welcome" | |
593 "XCopyFile" | |
594 ) | |
595 'font-lock-function-name-face) | |
596 ;; type keywords | |
597 (generic-make-keywords-list | |
598 (list | |
599 "BOOL" | |
600 "BYREF" | |
601 "CHAR" | |
602 "HIWORD" | |
603 "HWND" | |
604 "INT" | |
605 "LIST" | |
606 "LONG" | |
607 "LOWORD" | |
608 "NUMBER" | |
609 "POINTER" | |
610 "QUAD" | |
611 "RGB" | |
612 "SHORT" | |
613 "STRINGLIST" | |
614 "STRING" | |
615 ) | |
616 'font-lock-type-face) | |
617 ;;; system variables | |
618 (generic-make-keywords-list | |
619 (list | |
620 "CMDLINE" | |
621 "ERRORFILENAME" | |
622 "INFOFILENAME" | |
623 "ISRES" | |
624 "ISUSER" | |
625 "ISVERSION" | |
626 "SRCDIR" | |
627 "SRCDISK" | |
628 "SUPPORTDIR" | |
629 "TARGETDIR" | |
630 "TARGETDISK" | |
631 "WINDIR" | |
632 "WINDISK" | |
633 "WINSYSDIR" | |
634 "WINSYSDISK" | |
635 ) | |
636 'font-lock-variable-name-face) | |
637 ;; pre-defined constants (not exhaustive -- just my favorites) | |
638 (generic-make-keywords-list | |
639 (list | |
640 "AFTER" | |
641 "APPEND" | |
642 "BACKGROUNDCAPTION" | |
643 "BACKGROUND" | |
644 "BACK" | |
645 "BEFORE" | |
646 "BK_BLUE" | |
647 "BK_GREEN" | |
648 "BK_RED" | |
649 "CANCEL" | |
650 "COMMANDEX" | |
651 "COMMAND" | |
652 "CONTINUE" | |
653 "DEFWINDOWMODE" | |
654 "DISABLE" | |
655 "DLG_ERR" | |
656 "ENABLE" | |
657 "END_OF_LIST" | |
658 "EXCLUSIVE" | |
659 "EXISTS" | |
660 "EXIT" | |
661 "FAILIFEXISTS" | |
662 "FALSE" | |
663 "FULL" | |
664 "INDVFILESTATUS" | |
665 "INFORMATION" | |
666 "LIST_NULL" | |
667 "LISTFIRST" | |
668 "LISTNEXT" | |
669 "LOGGING" | |
670 "NEXT" | |
671 "NONEXCLUSIVE" | |
672 "NOSET" | |
673 "NO" | |
674 "OFF" | |
675 "ON" | |
676 "PARTIAL" | |
677 "REPLACE_ITEM" | |
678 "REPLACE" | |
679 "RESET" | |
680 "RESTART" | |
681 "SET" | |
682 "SEVERE" | |
683 "SRCTARGETDIR" | |
684 "STATUS" | |
685 "TRUE" | |
686 "YES" | |
687 "WARNING" | |
688 ) | |
689 'font-lock-variable-name-face) ; is this face the best choice? | |
690 ) | |
691 (list "\\.[rR][uU][lL]$") | |
692 (list | |
693 (function | |
694 (lambda () | |
695 (setq imenu-generic-expression | |
696 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1))) | |
697 ))) | |
698 "Generic mode for InstallShield RUL files") | |
699 | |
700 (define-skeleton rul-if | |
701 "Insert an if statement." | |
702 "condition: " | |
703 "if(" str ") then" \n | |
704 > _ \n | |
705 ( "other condition, %s: " | |
706 > "elseif(" str ") then" \n | |
707 > \n) | |
708 > "else" \n | |
709 > \n | |
710 resume: | |
711 > "endif;" | |
712 ) | |
713 | |
714 (define-skeleton rul-function | |
715 "Insert a function statement." | |
716 "function: " | |
717 "function " str " ()" \n | |
718 ( "local variables, %s: " | |
719 > " " str ";" \n) | |
720 > "begin" \n | |
721 > _ \n | |
722 resume: | |
723 > "end;") | |
724 | |
725 ) | |
726 | |
727 ;;; Info-Mac abstracts | |
728 ;; Contributed by Jacques Duthen Prestataire (duthen@cegelec-red.fr) | |
729 ;; | |
730 ;; For an example of such a file, you can download (the small): | |
731 ;; http://hyperarchive.lcs.mit.edu/HyperArchive/Archive/_Font/00font-abstracts.txt | |
732 (and | |
733 (memq 'info-mac-abstract-generic-mode generic-extras-enable-list) | |
734 | |
735 (define-generic-mode 'info-mac-abstract-generic-mode | |
736 () | |
737 (list "Date" "From" "Subject") | |
738 '(("^#### [^\n\r]*" . font-lock-function-name-face)) | |
739 (list "00.*-abstracts\\.txt") | |
740 nil | |
741 "Generic mode for info-mac abstract files.")) | |
742 | |
743 ;;; Mailagent | |
744 ;; Mailagent is a Unix mail filtering program. Anyone wanna do a generic mode | |
745 ;; for procmail? | |
746 (and | |
747 (memq 'mailagent-rules-generic-mode generic-extras-enable-list) | |
748 | |
749 (define-generic-mode 'mailagent-rules-generic-mode | |
750 (list ?#) | |
751 (list "SAVE" "DELETE" "PIPE" "ANNOTATE" "REJECT") | |
752 '(("^\\(\\sw+\\)\\s-*=" 1 'font-lock-variable-name-face) | |
753 ("\\s-/\\([^/]+\\)/[i, \t\n]" 1 'font-lock-reference-face)) | |
754 (list "\\.rules$") | |
755 (list 'mailagent-rules-setup-function) | |
756 "Mode for Mailagent rules files.") | |
757 | |
758 (defun mailagent-rules-setup-function () | |
759 (make-local-variable 'imenu-generic-expression) | |
760 (setq imenu-generic-expression | |
761 '((nil "\\s-/\\([^/]+\\)/[i, \t\n]" 1)))) | |
762 ) | |
763 | |
764 ;;; Crontab | |
765 ;; I didn't write this, I only adapted it for generic-mode | |
766 ;; If anyone knows who wrote it originally, I'd be glad to credit them | |
767 (and | |
768 (memq 'crontab-generic-mode generic-extras-enable-list) | |
769 | |
770 (define-generic-mode 'crontab-generic-mode | |
771 (list ?#) | |
772 nil | |
773 (list | |
774 (list | |
775 (concat "^\\(" | |
776 ;; Repeated 5 times for minute, hour, day of month, | |
777 ;; month and day of week fields | |
778 (mapconcat 'identity (make-list 5 "[*0-9,]+[ \t]+") "") | |
779 "\\)\\([^\n\r]*\\)") | |
780 (list 1 'font-lock-reference-face) | |
781 (list 2 'font-lock-function-name-face))) | |
782 nil | |
783 (list 'crontab-setup-function) | |
784 "Mode for Crontab files.") | |
785 | |
786 (defun crontab-setup-function () | |
787 (local-set-key "\C-c\C-c" 'crontab-update) | |
788 (local-set-key "\C-x\C-s" 'crontab-update) | |
789 ) | |
790 | |
791 (defun crontab () | |
792 "Edit a crontab file. | |
793 Type \\[save-buffer] to feed the buffer to the crontab command." | |
794 (interactive) | |
795 (switch-to-buffer "*Crontab*") | |
796 (erase-buffer) | |
797 (message "Reading crontab file ... ")(sit-for 0) ; redisplay | |
798 (if (eq (call-process-region (point) (point) "crontab" nil t t "-l") 0) | |
799 (message "Reading crontab file ... done") | |
800 (message "No crontab file") | |
801 (erase-buffer) | |
802 (insert "#min hour dom mon dow (0=Sun) cmd\n")) | |
803 (set-buffer-modified-p nil) | |
804 (crontab-generic-mode)) | |
805 | |
806 (defun crontab-update () | |
807 "Use the current buffer to update the crontab file." | |
808 (interactive) | |
809 (message "Updating crontab file ... ")(sit-for 0) ; redisplay | |
810 (shell-command-on-region (point-min) (point-max) "crontab" nil) | |
811 (message "Updating crontab file ... done") | |
812 (set-buffer-modified-p nil)) | |
813 ) | |
814 | |
815 ;; Contributed by Jacques Duthen Prestataire (duthen@cegelec-red.fr) | |
816 (and | |
817 (memq 'ps-generic-mode generic-extras-enable-list) | |
818 | |
819 (define-generic-mode 'ps-generic-mode | |
820 () ;; (list ?%) would not permit to differentiate DSC comments. | |
821 (list "def" "if" "ifelse" "forall") ; some keywords | |
822 '(("^%%[^ \n]*" . font-lock-reference-face) ; DSC comments | |
823 ("^/[^ \n]*" . font-lock-function-name-face) ; func or glob var def | |
824 ("%.*" . font-lock-comment-face) ; normal comments | |
825 ("(.*)" . font-lock-string-face) ; ps strings | |
826 ("/[^ \n]*" . font-lock-variable-name-face) ; symbols | |
827 ) | |
828 (list "\\.ps") ;; extension of Postscript files | |
829 nil ;; no hook | |
830 "Generic mode for PostScript files") | |
831 ) | |
832 | |
833 ;; Solaris/Sys V prototype files | |
834 (and | |
835 (memq 'prototype-generic-mode generic-extras-enable-list) | |
836 | |
837 (define-generic-mode 'prototype-generic-mode | |
838 (list ?#) | |
839 nil | |
840 '( | |
841 ("^\\([0-9]\\)?\\s-*\\([a-z]\\)\\s-+\\([A-Za-z_]+\\)\\s-+\\([^\n\r]*\\)$" | |
842 (2 font-lock-reference-face) | |
843 (3 font-lock-keyword-face)) | |
844 ("^\\([a-z]\\) \\([A-Za-z_]+\\)=\\([^\n\r]*\\)$" | |
845 (1 font-lock-reference-face) | |
846 (2 font-lock-keyword-face) | |
847 (3 font-lock-variable-name-face)) | |
848 ("^\\(!\\s-*\\(search\\|include\\|default\\)\\)\\s-*\\([^\n\r]*\\)$" | |
849 (1 font-lock-keyword-face) | |
850 (3 font-lock-variable-name-face)) | |
851 ("^\\(!\\s-*\\sw+\\)=\\([^\n\r]*\\)$" | |
852 (1 font-lock-keyword-face) | |
853 (2 font-lock-variable-name-face)) | |
854 ) | |
855 (list "prototype$") | |
856 nil | |
857 "Mode for Sys V prototype files")) | |
858 | |
859 ;; Solaris/Sys V pkginfo files | |
860 (and | |
861 (memq 'pkginfo-generic-mode generic-extras-enable-list) | |
862 | |
863 (define-generic-mode 'pkginfo-generic-mode | |
864 (list ?#) | |
865 nil | |
866 '( | |
867 ("^\\([A-Za-z_]+\\)=\\([^\n\r]*\\)$" | |
868 (1 font-lock-keyword-face) | |
869 (2 font-lock-variable-name-face)) | |
870 ) | |
871 (list "pkginfo$") | |
872 nil | |
873 "Mode for Sys V pkginfo files")) | |
874 | |
875 (define-generic-mode 'javascript-generic-mode | |
876 (list "//") | |
877 (list | |
878 "document" | |
879 "else" | |
880 "function" | |
881 "function" | |
882 "if" | |
883 "then" | |
884 "var" | |
885 ) | |
886 (list | |
887 (list "^\\s-*function\\s-+\\([A-Za-z0-9]+\\)" | |
888 '(1 font-lock-function-name-face)) | |
889 (list "^\\s-*var\\s-+\\([A-Za-z0-9]+\\)" | |
890 '(1 font-lock-variable-name-face)) | |
891 ) | |
892 (list "\\.js$") | |
893 (list | |
894 (function | |
895 (lambda () | |
896 (setq imenu-generic-expression | |
897 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1))) | |
898 ))) | |
899 "Mode for JavaScript files.") | |
900 | |
901 (define-generic-mode 'vrml-generic-mode | |
902 (list ?#) | |
903 (list | |
904 "DEF" | |
905 "NULL" | |
906 "USE" | |
907 "Viewpoint" | |
908 "ambientIntensity" | |
909 "appearance" | |
910 "children" | |
911 "color" | |
912 "coord" | |
913 "coordIndex" | |
914 "creaseAngle" | |
915 "diffuseColor" | |
916 "emissiveColor" | |
917 "fieldOfView" | |
918 "geometry" | |
919 "info" | |
920 "material" | |
921 "normal" | |
922 "orientation" | |
923 "position" | |
924 "shininess" | |
925 "specularColor" | |
926 "texCoord" | |
927 "texture" | |
928 "textureTransform" | |
929 "title" | |
930 "transparency" | |
931 "type" | |
932 ) | |
933 (list | |
934 (list "USE\\s-+\\([-A-Za-z0-9_]+\\)" | |
935 '(1 font-lock-reference-face)) | |
936 (list "DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{" | |
937 '(1 font-lock-type-face) | |
938 '(2 font-lock-reference-face)) | |
939 (list "^\\s-*\\([-A-Za-z0-9_]+\\)\\s-*{" | |
940 '(1 font-lock-function-name-face)) | |
941 (list | |
942 "^\\s-*\\(geometry\\|appearance\\|material\\)\\s-+\\([-A-Za-z0-9_]+\\)" | |
943 '(2 font-lock-variable-name-face)) | |
944 ) | |
945 (list "\\.wrl$") | |
946 (list | |
947 (function | |
948 (lambda () | |
949 (setq imenu-generic-expression | |
950 '((nil "^\\([A-Za-z0-9_]+\\)\\s-*{" 1) | |
951 ("*Definitions*" | |
952 "DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{" | |
953 1))) | |
954 ))) | |
955 "Generic Mode for VRML files.") | |
956 | |
957 (define-generic-mode 'mailrc-generic-mode | |
958 (list ?#) | |
959 (list "alias" "group" "set") | |
960 '(("^\\s-*\\(alias\\|group\\)\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([^\n\r]*\\)$" | |
961 (2 font-lock-reference-face) (3 font-lock-variable-name-face)) | |
962 ("^\\s-*set\\s-+\\([-A-Za-z0-9_]+\\)=\\([^\n\r]*\\)$" | |
963 (1 font-lock-reference-face) (2 font-lock-variable-name-face))) | |
964 (list "\\.mailrc$") | |
965 nil | |
966 "Mode for mailrc files") | |
967 | |
968 (define-generic-mode 'java-manifest-generic-mode | |
969 (list ?#) | |
970 (list "Name" | |
971 "Digest-Algorithms" | |
972 "Manifest-Version" | |
973 "Required-Version" | |
974 "Signature-Version" | |
975 "Magic") | |
976 '(("^Name:\\s-+\\([^\n\r]*\\)$" | |
977 (1 font-lock-variable-name-face)) | |
978 ("^\\(Manifest\\|Required\\|Signature\\)-Version:\\s-+\\([^\n\r]*\\)$" | |
979 (2 font-lock-reference-face)) | |
980 ) | |
981 (list "manifest\\.mf$") | |
982 nil | |
983 "Mode for Java Manifest files") | |
984 | |
985 (provide 'generic-extras) | |
986 | |
987 ;;; generic-extras.el ends here | |
988 | |
989 ;; Local Variables: | |
990 ;; autocompile: t | |
991 ;; End: |