comparison lisp/generic-x.el @ 21205:f63ba9821988

Initial revision
author Richard M. Stallman <rms@gnu.org>
date Tue, 17 Mar 1998 23:49:33 +0000
parents
children 89cdcab46969
comparison
equal deleted inserted replaced
21204:822da6b28265 21205:f63ba9821988
1 ;;; generic-x.el --- Extra Modes for generic-mode
2
3 ;; Copyright (C) 1997, 1998 Free Software Foundation, Inc.
4
5 ;; Author: Peter Breton <pbreton@cs.umb.edu>
6 ;; Created: Tue Oct 08 1996
7 ;; Keywords: generic, comment, font-lock
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs 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 ;; GNU Emacs 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
19 ;; GNU 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 the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Commentary:
27 ;;
28 ;; This file contains some pre-defined generic-modes.
29 ;;
30 ;; INSTALLATION:
31 ;;
32 ;; Add this line to your .emacs file:
33 ;;
34 ;; (require 'generic-x)
35 ;;
36 ;; You can decide which modes to load by setting the variable
37 ;; `generic-extras-enable-list'. Some platform-specific modes are
38 ;; affected by the variables `generic-define-mswindows-modes' and
39 ;; `generic-define-unix-modes' (which see).
40 ;;
41 ;; You can also send in new modes; if the file types a reasonably common,
42 ;; we would like to install them.
43 ;;
44 ;; PROBLEMS WHEN USED WITH FOLDING MODE:
45 ;;
46 ;; From Anders Lindgren <andersl@csd.uu.se>
47 ;;
48 ;; Problem summary: Wayne Adams has found a problem when using folding
49 ;; mode in conjuction with font-lock for a mode defined in
50 ;; `generic-x.el'.
51 ;;
52 ;; The problem, as Wayne described it, was that error messages of the
53 ;; following form appeared when both font-lock and folding are used:
54 ;;
55 ;; > - various msgs including "Fontifying region...(error Stack
56 ;; > overflow in regexp matcher)" appear
57 ;;
58 ;; I have just tracked down the cause of the problem. The regexp:s in
59 ;; `generic-x.el' does not take into account the way that folding
60 ;; hides sections of the buffer. The technique is known as
61 ;; `selective-display' and has been available for a very long time (I
62 ;; started using it back in the good old' Emacs 18 days). Basically, a
63 ;; section is hidden by creating one very long line were the newline
64 ;; character (C-j) is replaced by a linefeed (C-m) character.
65 ;;
66 ;; Many other hiding packages, besides folding, use the same technique,
67 ;; the problem should occur when using them as well.
68 ;;
69 ;; The erroronous lines in `generic-extras' look like the following (this
70 ;; example is from the `ini' section):
71 ;;
72 ;; '(("^\\(\\[.*\\]\\)" 1 'font-lock-reference-face)
73 ;; ("^\\(.*\\)=" 1 'font-lock-variable-name-face)
74 ;;
75 ;; The intention of these lines is to highlight lines of the following
76 ;; form:
77 ;;
78 ;; [foo]
79 ;; bar = xxx
80 ;;
81 ;; However, since the `.' regexp symbol match the linefeed character the
82 ;; entire folded section is searched, resulting in a regexp stack
83 ;; overflow.
84 ;;
85 ;; Solution suggestion 2: Instead of using ".", use the sequence
86 ;; "[^\n\r]". This will make the rules behave just as before, but they
87 ;; will work together with selective-display.
88
89 ;;; Code:
90
91 (require 'generic)
92 (require 'font-lock)
93
94 (defcustom generic-extras-enable-list nil
95 "*List of generic modes to enable by default.
96 Each entry in the list should be a symbol.
97 The variables `generic-define-mswindows-modes' and `generic-define-unix-modes'
98 also affect which generic modes are defined.
99 Please note that if you set this variable after generic-x is loaded,
100 you must reload generic-x to enable the specified modes."
101 :group 'generic-x
102 :type '(repeat sexp)
103 )
104
105 (defcustom generic-define-mswindows-modes
106 (memq system-type (list 'windows-nt 'ms-dos))
107 "*If non-nil, some MS-Windows specific generic modes will be defined."
108 :group 'generic-x
109 :type 'boolean
110 )
111
112 (defcustom generic-define-unix-modes
113 (not (memq system-type (list 'windows-nt 'ms-dos)))
114 "*If non-nil, some Unix specific generic modes will be defined."
115 :group 'generic-x
116 :type 'boolean
117 )
118
119 (and generic-define-mswindows-modes
120 (setq generic-extras-enable-list
121 (append (list 'bat-generic-mode 'ini-generic-mode
122 'inf-generic-mode 'rc-generic-mode
123 'reg-generic-mode 'rul-generic-mode)
124 generic-extras-enable-list)))
125
126 (and generic-define-unix-modes
127 (setq generic-extras-enable-list
128 (append (list 'apache-generic-mode 'samba-generic-mode
129 'hosts-generic-mode 'fvwm-generic-mode
130 'x-resource-generic-mode
131 )
132 generic-extras-enable-list)))
133
134 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
135 ;; Generic-modes
136 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
137
138 ;;; Apache
139 (and
140 (memq 'apache-generic-mode generic-extras-enable-list)
141
142 (define-generic-mode 'apache-generic-mode
143 (list ?#)
144 nil
145 '(("^\\(<.*>\\)" 1 'font-lock-reference-face)
146 ("^\\(\\sw+\\)\\s-" 1 'font-lock-variable-name-face))
147 (list "srm\\.conf\\'" "httpd\\.conf\\'" "access\\.conf\\'")
148 nil
149 "Generic mode for Apache or HTTPD configuration files."))
150
151 ;;; Samba
152 (and
153 (memq 'samba-generic-mode generic-extras-enable-list)
154
155 (define-generic-mode 'samba-generic-mode
156 (list ?\;)
157 nil
158 '(("^\\(\\[.*\\]\\)" 1 'font-lock-reference-face))
159 (list "smb\\.conf\\'")
160 (list 'generic-bracket-support)
161 "Generic mode for Samba configuration files."))
162
163 ;;; Fvwm
164 ;; This is pretty basic. Also, modes for other window managers could
165 ;; be defined as well.
166 (and
167 (memq 'fvwm-generic-mode generic-extras-enable-list)
168
169 (define-generic-mode 'fvwm-generic-mode
170 (list ?#)
171 (list
172 "AddToMenu"
173 "AddToFunc"
174 "ButtonStyle"
175 "EndFunction"
176 "EndPopup"
177 "Function"
178 "IconPath"
179 "Key"
180 "ModulePath"
181 "Mouse"
182 "PixmapPath"
183 "Popup"
184 "Style"
185 )
186 nil
187 (list "\\.fvwmrc\\'" "\\.fvwm2rc\\'")
188 nil
189 "Generic mode for FVWM configuration files."))
190
191 ;;; X Resource
192 ;; I'm pretty sure I've seen an actual mode to do this, but I don't
193 ;; think it's standard with Emacs
194 (and
195 (memq 'x-resource-generic-mode generic-extras-enable-list)
196
197 (define-generic-mode 'x-resource-generic-mode
198 (list ?!)
199 nil
200 '(("^\\([^:\n]+:\\)" 1 'font-lock-variable-name-face))
201 (list "\\.Xdefaults\\'" "\\.Xresources\\'")
202 nil
203 "Generic mode for X Resource configuration files."))
204
205 ;;; Hosts
206 (and
207 (memq 'hosts-generic-mode generic-extras-enable-list)
208
209 (define-generic-mode 'hosts-generic-mode
210 (list ?#)
211 (list "localhost")
212 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 'font-lock-reference-face))
213 (list "[hH][oO][sS][tT][sS]\\'")
214 nil
215 "Generic mode for HOSTS files."))
216
217 ;;; Windows INF files
218 (and
219 (memq 'inf-generic-mode generic-extras-enable-list)
220
221 (define-generic-mode 'inf-generic-mode
222 (list ?\;)
223 nil
224 '(("^\\(\\[.*\\]\\)" 1 'font-lock-reference-face))
225 (list "\\.[iI][nN][fF]\\'")
226 (list 'generic-bracket-support)
227 "Generic mode for MS-Windows INF files."))
228
229 ;;; Windows INI files
230 ;; Should define escape character as well!
231 (and
232 (memq 'ini-generic-mode generic-extras-enable-list)
233
234 (define-generic-mode 'ini-generic-mode
235 (list ?\;)
236 nil
237 '(("^\\(\\[.*\\]\\)" 1 'font-lock-reference-face)
238 ("^\\([^=\n\r]*\\)=\\([^\n\r]*\\)$"
239 (1 font-lock-function-name-face)
240 (2 font-lock-variable-name-face)))
241 (list "\\.[iI][nN][iI]\\'")
242 (list
243 (function
244 (lambda ()
245 (setq imenu-generic-expression
246 '((nil "^\\[\\(.*\\)\\]" 1)
247 ("*Variables*" "^\\s-*\\([^=]+\\)\\s-*=" 1)))
248 )))
249 "Generic mode for MS-Windows INI files."))
250
251 ;;; Windows REG files
252 ;;; Unfortunately, Windows 95 and Windows NT have different REG file syntax!
253 (and
254 (memq 'reg-generic-mode generic-extras-enable-list)
255
256 (define-generic-mode 'reg-generic-mode
257 '(?\;)
258 '("key" "classes_root" "REGEDIT" "REGEDIT4")
259 '(("\\(\\[.*]\\)" 1 'font-lock-reference-face)
260 ("^\\([^\n\r]*\\)\\s-*=" 1 'font-lock-variable-name-face))
261 '("\\.[rR][eE][gG]\\'")
262 (list
263 (function
264 (lambda ()
265 (setq imenu-generic-expression
266 '((nil "^\\s-*\\(.*\\)\\s-*=" 1))))))
267 "Generic mode for MS-Windows Registry files."))
268
269 ;;; Windows BAT files
270 (if (not (memq 'bat-generic-mode generic-extras-enable-list))
271 nil
272 (define-generic-mode 'bat-generic-mode
273 nil
274 nil
275 (list
276 ;; Make this one first in the list, otherwise comments will
277 ;; be over-written by other variables
278 (list "^[@ \t]*\\([rR][eE][mM][^\n\r]*\\)" 1 'font-lock-comment-face t)
279 (list "^[ \t]*\\(::-.*\\)" 1 'font-lock-comment-face t)
280 ;; These keywords appear as the first word on a line
281 (generic-make-keywords-list
282 (list
283 "[cC][aA][lL][lL]"
284 "[eE][cC][hH][oO]"
285 "[fF][oO][rR]"
286 "[iI][fF]"
287 "[pP][aA][tT][hH]"
288 "[pP][aA][uU][sS][eE]"
289 "[pP][rR][oO][mM][pP][tT]"
290 "[sS][eE][tT]"
291 "[sS][tT][aA][rR][tT]"
292 )
293 'font-lock-keyword-face "^[@ \t]*")
294 ;; These keywords can be anywhere on a line
295 (generic-make-keywords-list
296 (list
297 "[eE][xX][iI][sS][tT]"
298 "[eE][rR][rR][oO][rR][lL][eE][vV][eE][lL]"
299 "[gG][oO][tT][oO]"
300 "[nN][oO][tT]"
301 ) 'font-lock-keyword-face)
302 (list "^[ \t]*\\(:\\sw+\\)" 1 'font-lock-function-name-face t)
303 (list "\\(%\\sw+%\\)" 1 'font-lock-reference-face)
304 (list "\\(%[0-9]\\)" 1 'font-lock-reference-face)
305 (list "\\(/[^/ \"\t\n]+\\)" 1 'font-lock-type-face)
306 (list "[\t ]+\\([+-][^\t\n\" ]+\\)" 1 'font-lock-type-face)
307 (list "\\<\\([gG][oO][tT][oO]\\)\\>[ \t]*\\(\\sw+\\)?"
308 '(1 font-lock-keyword-face)
309 '(2 font-lock-function-name-face nil t))
310
311 )
312 (list "\\.[bB][aA][tT]\\'" "CONFIG\\." "AUTOEXEC\\." )
313 (list 'generic-bat-mode-setup-function)
314 "Generic mode for MS-Windows BAT files.")
315
316 (defvar bat-generic-mode-syntax-table nil
317 "Syntax table in use in bat-generic-mode buffers.")
318
319 ;; Make underscores count as words
320 (if bat-generic-mode-syntax-table
321 nil
322 (setq bat-generic-mode-syntax-table (make-syntax-table))
323 (modify-syntax-entry ?_ "w" bat-generic-mode-syntax-table))
324
325 ;; bat-generic-mode doesn't use the comment functionality of generic-mode
326 ;; because it has a three-letter comment-string, so we do it
327 ;; here manually instead
328 (defun generic-bat-mode-setup-function ()
329 (make-local-variable 'parse-sexp-ignore-comments)
330 (make-local-variable 'comment-start)
331 (make-local-variable 'comment-start-skip)
332 (make-local-variable 'comment-end)
333 (setq imenu-generic-expression '((nil "^:\\(\\sw+\\)" 1))
334 parse-sexp-ignore-comments t
335 comment-end ""
336 comment-start "[Rr][Ee][Mm] "
337 comment-start-skip "[Rr][Ee][Mm] *"
338 )
339 (set-syntax-table bat-generic-mode-syntax-table)
340 )
341 )
342
343 ;;; Mailagent
344 ;; Mailagent is a Unix mail filtering program. Anyone wanna do a generic mode
345 ;; for procmail?
346 (and
347 (memq 'mailagent-rules-generic-mode generic-extras-enable-list)
348
349 (define-generic-mode 'mailagent-rules-generic-mode
350 (list ?#)
351 (list "SAVE" "DELETE" "PIPE" "ANNOTATE" "REJECT")
352 '(("^\\(\\sw+\\)\\s-*=" 1 'font-lock-variable-name-face)
353 ("\\s-/\\([^/]+\\)/[i, \t\n]" 1 'font-lock-reference-face))
354 (list "\\.rules\\'")
355 (list 'mailagent-rules-setup-function)
356 "Mode for Mailagent rules files.")
357
358 (defun mailagent-rules-setup-function ()
359 (make-local-variable 'imenu-generic-expression)
360 (setq imenu-generic-expression
361 '((nil "\\s-/\\([^/]+\\)/[i, \t\n]" 1))))
362 )
363
364 ;; Solaris/Sys V prototype files
365 (and
366 (memq 'prototype-generic-mode generic-extras-enable-list)
367
368 (define-generic-mode 'prototype-generic-mode
369 (list ?#)
370 nil
371 '(
372 ("^\\([0-9]\\)?\\s-*\\([a-z]\\)\\s-+\\([A-Za-z_]+\\)\\s-+\\([^\n\r]*\\)$"
373 (2 font-lock-reference-face)
374 (3 font-lock-keyword-face))
375 ("^\\([a-z]\\) \\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
376 (1 font-lock-reference-face)
377 (2 font-lock-keyword-face)
378 (3 font-lock-variable-name-face))
379 ("^\\(!\\s-*\\(search\\|include\\|default\\)\\)\\s-*\\([^\n\r]*\\)$"
380 (1 font-lock-keyword-face)
381 (3 font-lock-variable-name-face))
382 ("^\\(!\\s-*\\sw+\\)=\\([^\n\r]*\\)$"
383 (1 font-lock-keyword-face)
384 (2 font-lock-variable-name-face))
385 )
386 (list "prototype\\'")
387 nil
388 "Mode for Sys V prototype files."))
389
390 ;; Solaris/Sys V pkginfo files
391 (and
392 (memq 'pkginfo-generic-mode generic-extras-enable-list)
393
394 (define-generic-mode 'pkginfo-generic-mode
395 (list ?#)
396 nil
397 '(
398 ("^\\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
399 (1 font-lock-keyword-face)
400 (2 font-lock-variable-name-face))
401 )
402 (list "pkginfo\\'")
403 nil
404 "Mode for Sys V pkginfo files."))
405
406 ;; Javascript mode
407 (define-generic-mode 'javascript-generic-mode
408 (list "//")
409 (list
410 "document"
411 "else"
412 "function"
413 "function"
414 "if"
415 "then"
416 "var"
417 )
418 (list
419 (list "^\\s-*function\\s-+\\([A-Za-z0-9]+\\)"
420 '(1 font-lock-function-name-face))
421 (list "^\\s-*var\\s-+\\([A-Za-z0-9]+\\)"
422 '(1 font-lock-variable-name-face))
423 )
424 (list "\\.js\\'")
425 (list
426 (function
427 (lambda ()
428 (setq imenu-generic-expression
429 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1)))
430 )))
431 "Mode for JavaScript files.")
432
433 ;; VRML files
434 (define-generic-mode 'vrml-generic-mode
435 (list ?#)
436 (list
437 "DEF"
438 "NULL"
439 "USE"
440 "Viewpoint"
441 "ambientIntensity"
442 "appearance"
443 "children"
444 "color"
445 "coord"
446 "coordIndex"
447 "creaseAngle"
448 "diffuseColor"
449 "emissiveColor"
450 "fieldOfView"
451 "geometry"
452 "info"
453 "material"
454 "normal"
455 "orientation"
456 "position"
457 "shininess"
458 "specularColor"
459 "texCoord"
460 "texture"
461 "textureTransform"
462 "title"
463 "transparency"
464 "type"
465 )
466 (list
467 (list "USE\\s-+\\([-A-Za-z0-9_]+\\)"
468 '(1 font-lock-reference-face))
469 (list "DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
470 '(1 font-lock-type-face)
471 '(2 font-lock-reference-face))
472 (list "^\\s-*\\([-A-Za-z0-9_]+\\)\\s-*{"
473 '(1 font-lock-function-name-face))
474 (list
475 "^\\s-*\\(geometry\\|appearance\\|material\\)\\s-+\\([-A-Za-z0-9_]+\\)"
476 '(2 font-lock-variable-name-face))
477 )
478 (list "\\.wrl\\'")
479 (list
480 (function
481 (lambda ()
482 (setq imenu-generic-expression
483 '((nil "^\\([A-Za-z0-9_]+\\)\\s-*{" 1)
484 ("*Definitions*"
485 "DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
486 1)))
487 )))
488 "Generic Mode for VRML files.")
489
490 ;; Java Manifests
491 (define-generic-mode 'java-manifest-generic-mode
492 (list ?#)
493 (list
494 "Name"
495 "Digest-Algorithms"
496 "Manifest-Version"
497 "Required-Version"
498 "Signature-Version"
499 "Magic"
500 "Java-Bean"
501 "Depends-On"
502 )
503 '(("^Name:\\s-+\\([^\n\r]*\\)$"
504 (1 font-lock-variable-name-face))
505 ("^\\(Manifest\\|Required\\|Signature\\)-Version:\\s-+\\([^\n\r]*\\)$"
506 (2 font-lock-reference-face))
507 )
508 (list "manifest\\.mf\\'")
509 nil
510 "Mode for Java Manifest files")
511
512 ;; Java properties files
513 (define-generic-mode 'java-properties-generic-mode
514 (list ?#)
515 nil
516 ;; Property and value can be separated with whitespace or an equal sign
517 '(("^\\([A-Za-z0-9_]+\\)\\(\\s-+\\|\\s-*=\\s-*\\)\\([^\r\n]*\\)\\'"
518 (1 font-lock-reference-face) (3 font-lock-variable-name-face)))
519 nil
520 nil
521 "Mode for Java properties files.")
522
523 ;; C shell alias definitions
524 (define-generic-mode 'alias-generic-mode
525 (list ?#)
526 (list "alias" "unalias")
527 '(("^alias\\s-+\\([-A-Za-z0-9_]+\\)\\s-+"
528 (1 font-lock-variable-name-face))
529 ("^unalias\\s-+\\([-A-Za-z0-9_]+\\)\\s-*$"
530 (1 font-lock-variable-name-face))
531 )
532 (list "alias\\'")
533 (list
534 (function
535 (lambda ()
536 (setq imenu-generic-expression
537 '((nil "^\\(alias\\|unalias\\)\\s-+\\([-a-zA-Z0-9_]+\\)" 2)))
538 )))
539 "Mode for C Shell alias files.")
540
541 ;;; Windows RC files
542 ;; Contributed by ACorreir@pervasive-sw.com (Alfred Correira)
543 (and
544 (memq 'rc-generic-mode generic-extras-enable-list)
545
546 (define-generic-mode 'rc-generic-mode
547 ;; (list ?\/)
548 (list "//")
549 '("ACCELERATORS"
550 "AUTO3STATE"
551 "AUTOCHECKBOX"
552 "AUTORADIOBUTTON"
553 "BITMAP"
554 "BOTTOMMARGIN"
555 "BUTTON"
556 "CAPTION"
557 "CHARACTERISTICS"
558 "CHECKBOX"
559 "CLASS"
560 "COMBOBOX"
561 "CONTROL"
562 "CTEXT"
563 "CURSOR"
564 "DEFPUSHBUTTON"
565 "DESIGNINFO"
566 "DIALOG"
567 "DISCARDABLE"
568 "EDITTEXT"
569 "EXSTYLE"
570 "FONT"
571 "GROUPBOX"
572 "GUIDELINES"
573 "ICON"
574 "LANGUAGE"
575 "LEFTMARGIN"
576 "LISTBOX"
577 "LTEXT"
578 "MENUITEM SEPARATOR"
579 "MENUITEM"
580 "MENU"
581 "MOVEABLE"
582 "POPUP"
583 "PRELOAD"
584 "PURE"
585 "PUSHBOX"
586 "PUSHBUTTON"
587 "RADIOBUTTON"
588 "RCDATA"
589 "RIGHTMARGIN"
590 "RTEXT"
591 "SCROLLBAR"
592 "SEPARATOR"
593 "STATE3"
594 "STRINGTABLE"
595 "STYLE"
596 "TEXTINCLUDE"
597 "TOOLBAR"
598 "TOPMARGIN"
599 "VERSIONINFO"
600 "VERSION"
601 )
602 ;; the choice of what tokens go where is somewhat arbitrary,
603 ;; as is the choice of which value tokens are included, as
604 ;; the choice of face for each token group
605 (list
606 (generic-make-keywords-list
607 (list
608 "FILEFLAGSMASK"
609 "FILEFLAGS"
610 "FILEOS"
611 "FILESUBTYPE"
612 "FILETYPE"
613 "FILEVERSION"
614 "PRODUCTVERSION"
615 ) 'font-lock-type-face)
616 (generic-make-keywords-list
617 (list
618 "BEGIN"
619 "BLOCK"
620 "END"
621 "VALUE"
622 ) 'font-lock-function-name-face)
623 '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face)
624 '("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face)
625 '("^#[ \t]*\\(elif\\|if\\)\\>"
626 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil
627 (1 font-lock-reference-face) (2 font-lock-variable-name-face nil t)))
628 '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
629 (1 font-lock-reference-face) (2 font-lock-variable-name-face nil t)))
630 (list "\\.[rR][cC]$")
631 nil
632 "Generic mode for MS-Windows Resource files."))
633
634 ;;; InstallShield RUL files
635 ;; Contributed by Alfred.Correira@Pervasive.Com
636 (and
637 (memq 'rul-generic-mode generic-extras-enable-list)
638
639 (define-generic-mode 'rul-generic-mode
640 ;; Using "/*" and "*/" doesn't seem to be working right
641 (list "//")
642 '("abort"
643 "begin"
644 "call"
645 "case"
646 "declare"
647 "default"
648 "downto"
649 "elseif"
650 "else"
651 "endfor"
652 "endif"
653 "endswitch"
654 "endwhile"
655 "end"
656 "exit"
657 "external"
658 "for"
659 "function"
660 ;; "goto" -- handled elsewhere
661 "if"
662 "program"
663 "prototype"
664 "repeat"
665 "return"
666 "step"
667 "switch"
668 "then"
669 "to"
670 "typedef"
671 "until"
672 "void"
673 "while")
674 (list
675 ;; preprocessor constructs
676 '("#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)"
677 1 font-lock-string-face)
678 '("#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
679 (1 font-lock-reference-face)
680 (2 font-lock-variable-name-face nil t))
681 ;; indirect string constants
682 '("\\(@[A-Za-z][A-Za-z0-9_]+\\)" 1 font-lock-emphasized-face)
683 ;; gotos
684 '("[ \t]*\\(\\sw+:\\)" 1 font-lock-reference-face)
685 '("\\<\\(goto\\)\\>[ \t]*\\(\\sw+\\)?"
686 (1 font-lock-keyword-face)
687 (2 font-lock-reference-face nil t))
688 ;; system variables
689 (generic-make-keywords-list
690 (list
691 "CMDLINE"
692 "ERRORFILENAME"
693 "INFOFILENAME"
694 "ISRES"
695 "ISUSER"
696 "ISVERSION"
697 "SRCDIR"
698 "SRCDISK"
699 "SUPPORTDIR"
700 "TARGETDIR"
701 "TARGETDISK"
702 "WINDIR"
703 "WINDISK"
704 "WINMAJOR"
705 "WINSYSDIR"
706 "WINSYSDISK"
707 )
708 'font-lock-variable-name-face)
709 ;; system functions
710 (generic-make-keywords-list
711 (list
712 "AddFolderIcon"
713 "AddProfString"
714 "AddressString"
715 "AppCommand"
716 "AskDestPath"
717 "AskOptions"
718 "AskPath"
719 "AskText"
720 "AskYesNo"
721 "BatchDeleteEx"
722 "BatchFileLoad"
723 "BatchFileSave"
724 "BatchFind"
725 "BatchGetFileName"
726 "BatchMoveEx"
727 "BatchSetFileName"
728 "CloseFile"
729 "CmdGetHwndDlg"
730 "ComponentAddItem" ; differs between IS3 and IS5
731 "ComponentCompareSizeRequired" ; IS5 only
732 "ComponentDialog"
733 "ComponentError" ; IS5 only
734 "ComponentFileEnum" ; IS5 only
735 "ComponentFileInfo" ; IS5 only
736 "ComponentFilterLanguage" ; IS5 only
737 "ComponentFilterOS" ; IS5 only
738 "ComponentGetData" ; IS5 only
739 "ComponentGetItemInfo" ; IS3 only
740 "ComponentGetItemSize" ; differs between IS3 and IS5
741 "ComponentIsItemSelected" ; differs between IS3 and IS5
742 "ComponentListItems"
743 "ComponentMoveData" ; IS5 only
744 "ComponentSelectItem" ; differs between IS3 and IS5
745 "ComponentSetData" ; IS5 only
746 "ComponentSetItemInfo" ; IS3 only
747 "ComponentSetTarget" ; IS5 only
748 "ComponentSetupTypeEnum" ; IS5 only
749 "ComponentSetupTypeGetData" ; IS5 only
750 "ComponentSetupTypeSet" ; IS5 only
751 "ComponentTotalSize"
752 "ComponentValidate" ; IS5 only
753 "CompressAdd" ; IS3 only
754 "CompressDel" ; IS3 only
755 "CompressEnum" ; IS3 only
756 "CompressGet" ; IS3 only
757 "CompressInfo" ; IS3 only
758 "CopyFile"
759 "CreateDir"
760 "CreateFile"
761 "CreateProgramFolder"
762 "DeinstallSetReference" ; IS5 only
763 "DeinstallStart"
764 "Delay"
765 "DeleteDir"
766 "DeleteFile"
767 "DialogSetInfo"
768 "Disable"
769 "DoInstall"
770 "Do"
771 "Enable"
772 "EnterDisk"
773 "ExistsDir"
774 "ExistsDisk"
775 "ExitProgMan"
776 "EzBatchAddPath"
777 "EzBatchAddString"
778 "EzBatchReplace"
779 "EzConfigAddDriver"
780 "EzConfigAddString"
781 "EzConfigGetValue"
782 "EzConfigSetValue"
783 "EzDefineDialog"
784 "FileCompare"
785 "FileDeleteLine"
786 "FileGrep"
787 "FileInsertLine"
788 "FileSetBeginDefine" ; IS3 only
789 "FileSetEndDefine" ; IS3 only
790 "FileSetPerformEz" ; IS3 only
791 "FileSetPerform" ; IS3 only
792 "FileSetReset" ; IS3 only
793 "FileSetRoot" ; IS3 only
794 "FindAllDirs"
795 "FindAllFiles"
796 "FindFile"
797 "FindWindow"
798 "GetDiskSpace"
799 "GetDisk"
800 "GetEnvVar"
801 "GetExtents"
802 "GetFileInfo"
803 "GetLine"
804 "GetProfString"
805 "GetSystemInfo"
806 "GetValidDrivesList"
807 "GetVersion"
808 "GetWindowHandle"
809 "InstallationInfo"
810 "Is"
811 "LaunchApp"
812 "ListCreate"
813 "ListDestroy"
814 "ListGetFirstString"
815 "ListGetNextString"
816 "ListSetIndex"
817 "LongPathToQuote"
818 "LongPathToShortPath"
819 "MessageBox"
820 "NumToStr"
821 "OpenFileMode"
822 "OpenFile"
823 "ParsePath"
824 "PathAdd"
825 "PathDelete"
826 "PathFind"
827 "PathGet"
828 "PathMove"
829 "PathSet"
830 "Path"
831 "PlaceBitmap"
832 "PlaceWindow"
833 "PlayMMedia" ; IS5 only
834 "ProgDefGroupType"
835 "RegDBCreateKeyEx"
836 "RegDBGetItem"
837 "RegDBKeyExist"
838 "RegDBSetItem"
839 "RegDBGetKeyValueEx"
840 "RegDBSetKeyValueEx"
841 "RegDBSetDefaultRoot"
842 "RenameFile"
843 "ReplaceFolderIcon"
844 "ReplaceProfString"
845 "SdAskDestPath"
846 "SdAskOptions"
847 "SdAskOptionsList"
848 "SdBitmap"
849 "SdCloseDlg"
850 "SdComponentAdvCheckSpace"
851 "SdComponentAdvInit"
852 "SdComponentAdvUpdateSpace"
853 "SdComponentDialog"
854 "SdComponentDialog2"
855 "SdComponentDialogAdv"
856 "SdComponentDialogEx"
857 "SdComponentDlgCheckSpace"
858 "SdComponentMult"
859 "SdConfirmNewDir"
860 "SdConfirmRegistration"
861 "SdDiskSpace"
862 "SdDisplayTopics"
863 "SdDoStdButton"
864 "SdEnablement"
865 "SdError"
866 "SdFinish"
867 "SdFinishInit32"
868 "SdFinishReboot"
869 "SdGeneralInit"
870 "SdGetItemName"
871 "SdGetTextExtent"
872 "SdGetUserCompanyInfo"
873 "SdInit"
874 "SdIsShellExplorer"
875 "SdIsStdButton"
876 "SdLicense"
877 "SdMakeName"
878 "SdOptionInit"
879 "SdOptionSetState"
880 "SdOptionsButtons"
881 "SdOptionsButtonsInit"
882 "SdPlugInProductName"
883 "SdProductName"
884 "SdRegEnableButton"
885 "SdRegExEnableButton"
886 "SdRegisterUser"
887 "SdRegisterUserEx"
888 "SdRemoveEndSpace"
889 "SdSelectFolder"
890 "SdSetSequentialItems"
891 "SdSetStatic"
892 "SdSetupTypeEx" ; IS5 only
893 "SdSetupType"
894 "SdShowAnyDialog"
895 "SdShowDlgEdit1"
896 "SdShowDlgEdit2"
897 "SdShowDlgEdit3"
898 "SdShowFileMods"
899 "SdShowInfoList"
900 "SdShowMsg"
901 "SdStartCopy"
902 "SdUnInit"
903 "SdUpdateComponentSelection"
904 "SdWelcome"
905 "SendMessage"
906 "SetColor"
907 "SetFont"
908 "SetDialogTitle"
909 "SetDisplayEffect" ; IS5 only
910 "SetFileInfo"
911 "SetForegroundWindow"
912 "SetStatusWindow"
913 "SetTitle"
914 "SetupType"
915 "ShowProgramFolder"
916 "Split" ; IS3 only
917 "SprintfBox"
918 "Sprintf"
919 "StatusUpdate"
920 "StrCompare"
921 "StrFind"
922 "StrGetTokens"
923 "StrLength"
924 "StrRemoveLastSlash"
925 "StrToLower"
926 "StrToUpper"
927 "StrSub"
928 "VarRestore"
929 "VarSave"
930 "VerCompare"
931 "VerGetFileVersion"
932 "WaitOnDialog"
933 "Welcome"
934 "WriteLine"
935 "WriteProfString"
936 "XCopyFile"
937 )
938 'font-lock-function-name-face)
939 ;; type keywords
940 (generic-make-keywords-list
941 (list
942 "BOOL"
943 "BYREF"
944 "CHAR"
945 "HIWORD"
946 "HWND"
947 "INT"
948 "LIST"
949 "LONG"
950 "LOWORD"
951 "NUMBER"
952 "POINTER"
953 "QUAD"
954 "RGB"
955 "SHORT"
956 "STRINGLIST"
957 "STRING"
958 )
959 'font-lock-type-face)
960 ;;; system variables
961 (generic-make-keywords-list
962 (list
963 "CMDLINE"
964 "CORECOMPONENTHANDLING"
965 "ERRORFILENAME"
966 "INFOFILENAME"
967 "ISRES"
968 "ISUSER"
969 "ISVERSION"
970 "MODE"
971 "SRCDIR"
972 "SRCDISK"
973 "SUPPORTDIR"
974 "TARGETDIR"
975 "TARGETDISK"
976 "WINDIR"
977 "WINDISK"
978 "WINSYSDIR"
979 "WINSYSDISK"
980 )
981 ;; pre-defined constants (not exhaustive -- just my favorites)
982 'font-lock-variable-name-face)
983
984 (generic-make-keywords-list
985 (list
986 "AFTER"
987 "APPEND"
988 "ALLCONTENTS"
989 "BACKBUTTON"
990 "BACKGROUNDCAPTION"
991 "BACKGROUND"
992 "BACK"
993 "BASEMEMORY"
994 "BEFORE"
995 "BIOS"
996 "BITMAPICON"
997 "BK_BLUE"
998 "BK_GREEN"
999 "BK_RED"
1000 "BLUE"
1001 "BOOTUPDRIVE"
1002 "CANCEL"
1003 "CDROM_DRIVE"
1004 "CDROM"
1005 "CHECKBOX95"
1006 "CHECKBOX"
1007 "CHECKLINE"
1008 "CHECKMARK"
1009 "COLORS"
1010 "COMMANDEX"
1011 "COMMAND"
1012 "COMP_NORMAL"
1013 "COMP_UPDATE_DATE"
1014 "COMP_UPDATE_SAME"
1015 "COMP_UPDATE_VERSION"
1016 "COMPACT"
1017 "CONTINUE"
1018 "CPU"
1019 "CUSTOM"
1020 "DATE"
1021 "DEFWINDOWMODE"
1022 "DIR_WRITEABLE"
1023 "DISABLE"
1024 "DISK_TOTALSPACE"
1025 "DISK"
1026 "DLG_OPTIONS"
1027 "DLG_PATH"
1028 "DLG_TEXT"
1029 "DLG_ASK_YESNO"
1030 "DLG_ENTER_DISK"
1031 "DLG_ERR"
1032 "DLG_INFO_ALTIMAGE"
1033 "DLG_INFO_CHECKSELECTION"
1034 "DLG_INFO_KUNITS"
1035 "DLG_INFO_USEDECIMAL"
1036 "DLG_MSG_INFORMATION"
1037 "DLG_MSG_SEVERE"
1038 "DLG_MSG_WARNING"
1039 "DLG_STATUS"
1040 "DLG_WARNING"
1041 "DLG_USER_CAPTION"
1042 "DRIVE"
1043 "ENABLE"
1044 "END_OF_FILE"
1045 "END_OF_LIST"
1046 "ENVSPACE"
1047 "EQUALS"
1048 "EXCLUDE_SUBDIR"
1049 "EXCLUSIVE"
1050 "EXISTS"
1051 "EXIT"
1052 "EXTENDED_MEMORY"
1053 "EXTENSION_ONLY"
1054 "FAILIFEXISTS"
1055 "FALSE"
1056 "FEEDBACK_FULL"
1057 "FILE_ATTR_ARCHIVED"
1058 "FILE_ATTR_DIRECTORY"
1059 "FILE_ATTR_HIDDEN"
1060 "FILE_ATTR_NORMAL"
1061 "FILE_ATTR_READONLY"
1062 "FILE_ATTR_SYSTEM"
1063 "FILE_ATTRIBUTE"
1064 "FILE_DATE"
1065 "FILE_LINE_LENGTH"
1066 "FILE_MODE_APPEND"
1067 "FILE_MODE_BINARYREADONLY"
1068 "FILE_MODE_BINARY"
1069 "FILE_MODE_NORMAL"
1070 "FILE_NO_VERSION"
1071 "FILE_NOT_FOUND"
1072 "FILE_SIZE"
1073 "FILE_TIME"
1074 "FILENAME_ONLY"
1075 "FILENAME"
1076 "FIXED_DRIVE"
1077 "FOLDER_DESKTOP"
1078 "FOLDER_STARTMENU"
1079 "FOLDER_STARTUP"
1080 "FREEENVSPACE"
1081 "FULLWINDOWMODE"
1082 "FULL"
1083 "FONT_TITLE"
1084 "GREATER_THAN"
1085 "GREEN"
1086 "HOURGLASS"
1087 "INCLUDE_SUBDIR"
1088 "INDVFILESTATUS"
1089 "INFORMATION"
1090 "IS_WINDOWSNT"
1091 "IS_WINDOWS95"
1092 "IS_WINDOWS"
1093 "IS_WIN32S"
1094 "ISTYPE"
1095 "LANGUAGE_DRV"
1096 "LANGUAGE"
1097 "LESS_THAN"
1098 "LIST_NULL"
1099 "LISTFIRST"
1100 "LISTNEXT"
1101 "LOCKEDFILE"
1102 "LOGGING"
1103 "LOWER_LEFT"
1104 "LOWER_RIGHT"
1105 "MAGENTA"
1106 "MOUSE_DRV"
1107 "MOUSE"
1108 "NETWORK_DRV"
1109 "NETWORK"
1110 "NEXT"
1111 "NONEXCLUSIVE"
1112 "NORMALMODE"
1113 "NOSET"
1114 "NOTEXISTS"
1115 "NOWAIT"
1116 "NO"
1117 "OFF"
1118 "ONLYDIR"
1119 "ON"
1120 "OSMAJOR"
1121 "OSMINOR"
1122 "OS"
1123 "OTHER_FAILURE"
1124 "PARALLEL"
1125 "PARTIAL"
1126 "PATH_EXISTS"
1127 "PATH"
1128 "RED"
1129 "REGDB_APPPATH_DEFAULT"
1130 "REGDB_APPPATH"
1131 "REGDB_BINARY"
1132 "REGDB_ERR_CONNECTIONEXISTS"
1133 "REGDB_ERR_CORRUPTEDREGSITRY"
1134 "REGDB_ERR_INITIALIZATION"
1135 "REGDB_ERR_INVALIDHANDLE"
1136 "REGDB_ERR_INVALIDNAME"
1137 "REGDB_NUMBER"
1138 "REGDB_STRING_EXPAND"
1139 "REGDB_STRING_MULTI"
1140 "REGDB_STRING"
1141 "REGDB_UNINSTALL_NAME"
1142 "REMOTE_DRIVE"
1143 "REMOVALE_DRIVE"
1144 "REPLACE_ITEM"
1145 "REPLACE"
1146 "RESET"
1147 "RESTART"
1148 "ROOT"
1149 "SELFREGISTER"
1150 "SERIAL"
1151 "SET"
1152 "SEVERE"
1153 "SHAREDFILE"
1154 "SHARE"
1155 "SILENTMODE"
1156 "SRCTARGETDIR"
1157 "STATUSBAR"
1158 "STATUSDLG"
1159 "STATUSOLD"
1160 "STATUS"
1161 "STYLE_NORMAL"
1162 "SW_MAXIMIZE"
1163 "SW_MINIMIZE"
1164 "SW_RESTORE"
1165 "SW_SHOW"
1166 "TIME"
1167 "TRUE"
1168 "TYPICAL"
1169 "UPPER_LEFT"
1170 "UPPER_RIGHT"
1171 "VALID_PATH"
1172 "VERSION"
1173 "VIDEO"
1174 "VOLUMELABEL"
1175 "YELLOW"
1176 "YES"
1177 "WAIT"
1178 "WARNING"
1179 "WINMAJOR"
1180 "WINMINOR"
1181 "WIN32SINSTALLED"
1182 "WIN32SMAJOR"
1183 "WIN32SMINOR"
1184 )
1185 'font-lock-variable-name-face) ; is this face the best choice?
1186 )
1187 (list "\\.[rR][uU][lL]$")
1188 (list
1189 (function
1190 (lambda ()
1191 (setq imenu-generic-expression
1192 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1)))
1193 )))
1194 "Generic mode for InstallShield RUL files.")
1195
1196 (define-skeleton rul-if
1197 "Insert an if statement."
1198 "condition: "
1199 "if(" str ") then" \n
1200 > _ \n
1201 ( "other condition, %s: "
1202 > "elseif(" str ") then" \n
1203 > \n)
1204 > "else" \n
1205 > \n
1206 resume:
1207 > "endif;"
1208 )
1209
1210 (define-skeleton rul-function
1211 "Insert a function statement."
1212 "function: "
1213 "function " str " ()" \n
1214 ( "local variables, %s: "
1215 > " " str ";" \n)
1216 > "begin" \n
1217 > _ \n
1218 resume:
1219 > "end;")
1220
1221 )
1222
1223 ;; Additions by ACorreir@pervasive-sw.com (Alfred Correira)
1224 (define-generic-mode 'mailrc-generic-mode
1225 (list ?#)
1226 (list
1227 "alias"
1228 "else"
1229 "endif"
1230 "group"
1231 "if"
1232 "ignore"
1233 "set"
1234 "unset"
1235 )
1236 '(("^\\s-*\\(alias\\|group\\)\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1237 (2 font-lock-reference-face) (3 font-lock-variable-name-face))
1238 ("^\\s-*\\(unset\\|set\\|ignore\\)\\s-+\\([-A-Za-z0-9_]+\\)=?\\([^\n\r#]*\\)\\(#.*\\)?$"
1239 (2 font-lock-reference-face) (3 font-lock-variable-name-face)))
1240 (list "\\.mailrc\\'")
1241 nil
1242 "Mode for mailrc files.")
1243
1244 (provide 'generic-x)
1245
1246 ;;; generic-x.el ends here