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