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