(lisp-font-lock-keywords-2): Quote "]"s in regexps when they have no
[bpt/emacs.git] / lisp / generic-x.el
CommitLineData
1fffafda 1;;; generic-x.el --- A collection of generic modes
ca1e63a5 2
0d30b337 3;; Copyright (C) 1997, 1998, 2002, 2003, 2004,
aaef169d 4;; 2005, 2006 Free Software Foundation, Inc.
ca1e63a5
RS
5
6;; Author: Peter Breton <pbreton@cs.umb.edu>
7;; Created: Tue Oct 08 1996
8;; Keywords: generic, comment, font-lock
9
10;; This file is part of GNU Emacs.
11
12;; GNU Emacs is free software; you can redistribute it and/or modify
13;; it under the terms of the GNU General Public License as published by
14;; the Free Software Foundation; either version 2, or (at your option)
15;; any later version.
16
17;; GNU Emacs is distributed in the hope that it will be useful,
18;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;; GNU General Public License for more details.
21
22;; You should have received a copy of the GNU General Public License
23;; along with GNU Emacs; see the file COPYING. If not, write to the
086add15
LK
24;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25;; Boston, MA 02110-1301, USA.
ca1e63a5
RS
26
27;;; Commentary:
28;;
1fffafda 29;; This file contains a collection generic modes.
ffe0c7ef 30;;
ca1e63a5
RS
31;; INSTALLATION:
32;;
33;; Add this line to your .emacs file:
34;;
35;; (require 'generic-x)
36;;
37;; You can decide which modes to load by setting the variable
1fffafda
LK
38;; `generic-extras-enable-list'. Its default value is platform-
39;; specific. The recommended way to set this variable is through
40;; customize:
ffe0c7ef 41;;
1fffafda
LK
42;; M-x customize-option RET generic-extras-enable-list RET
43;;
44;; This lets you select generic modes from the list of available
45;; modes. If you manually set `generic-extras-enable-list' in your
46;; .emacs, do it BEFORE loading generic-x with (require 'generic-x).
47;;
48;; You can also send in new modes; if the file types are reasonably
49;; common, we would like to install them.
ca1e63a5 50;;
9285b8bc
LK
51;; DEFAULT GENERIC MODE:
52;;
53;; This file provides a hook which automatically puts a file into
54;; `default-generic-mode' if the first few lines of a file in
55;; fundamental mode start with a hash comment character. To disable
56;; this functionality, set the variable `generic-use-find-file-hook'
57;; to nil BEFORE loading generic-x. See the variables
58;; `generic-lines-to-scan' and `generic-find-file-regexp' for
59;; customization options.
60;;
ca1e63a5
RS
61;; PROBLEMS WHEN USED WITH FOLDING MODE:
62;;
762f539b 63;; [The following relates to the obsolete selective-display technique.
1fffafda 64;; Folding mode should use invisible text properties instead. -- Dave
762f539b
DL
65;; Love]
66;;
ca1e63a5 67;; From Anders Lindgren <andersl@csd.uu.se>
ffe0c7ef 68;;
ca1e63a5 69;; Problem summary: Wayne Adams has found a problem when using folding
1fffafda 70;; mode in conjunction with font-lock for a mode defined in
ca1e63a5
RS
71;; `generic-x.el'.
72;;
73;; The problem, as Wayne described it, was that error messages of the
74;; following form appeared when both font-lock and folding are used:
ffe0c7ef 75;;
ca1e63a5
RS
76;; > - various msgs including "Fontifying region...(error Stack
77;; > overflow in regexp matcher)" appear
ffe0c7ef 78;;
1fffafda
LK
79;; I have just tracked down the cause of the problem. The regexp's in
80;; `generic-x.el' do not take into account the way that folding hides
81;; sections of the buffer. The technique is known as
ca1e63a5 82;; `selective-display' and has been available for a very long time (I
1fffafda 83;; started using it back in the good old Emacs 18 days). Basically, a
ca1e63a5
RS
84;; section is hidden by creating one very long line were the newline
85;; character (C-j) is replaced by a linefeed (C-m) character.
ffe0c7ef 86;;
ca1e63a5
RS
87;; Many other hiding packages, besides folding, use the same technique,
88;; the problem should occur when using them as well.
ffe0c7ef 89;;
1fffafda 90;; The erroneous lines in `generic-x.el' look like the following (this
ca1e63a5 91;; example is from the `ini' section):
ffe0c7ef
PB
92;;
93;; '(("^\\(\\[.*\\]\\)" 1 'font-lock-constant-face)
ca1e63a5 94;; ("^\\(.*\\)=" 1 'font-lock-variable-name-face)
ffe0c7ef 95;;
ca1e63a5
RS
96;; The intention of these lines is to highlight lines of the following
97;; form:
ffe0c7ef 98;;
ca1e63a5
RS
99;; [foo]
100;; bar = xxx
ffe0c7ef 101;;
1fffafda
LK
102;; However, since the `.' regexp symbol matches the linefeed character
103;; the entire folded section is searched, resulting in a regexp stack
ca1e63a5 104;; overflow.
ffe0c7ef 105;;
1fffafda
LK
106;; Solution suggestion: Instead of using ".", use the sequence
107;; "[^\n\r]". This will make the rules behave just as before, but
108;; they will work together with selective-display.
ca1e63a5
RS
109
110;;; Code:
111
1fffafda 112(eval-when-compile (require 'font-lock))
ca1e63a5 113
ef1c5063 114(defgroup generic-x nil
9285b8bc 115 "A collection of generic modes."
ef1c5063 116 :prefix "generic-"
9285b8bc 117 :group 'data
10714c98 118 :version "20.3")
ef1c5063 119
9285b8bc
LK
120;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
121;; Default-Generic mode
122;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
123
124(defcustom generic-use-find-file-hook t
125 "*If non-nil, add a hook to enter `default-generic-mode' automatically.
126This is done if the first few lines of a file in fundamental mode
127start with a hash comment character."
128 :group 'generic-x
129 :type 'boolean)
130
131(defcustom generic-lines-to-scan 3
132 "*Number of lines that `generic-mode-find-file-hook' looks at.
133Relevant when deciding whether to enter Default-Generic mode automatically.
134This variable should be set to a small positive number."
135 :group 'generic-x
136 :type 'integer)
137
138(defcustom generic-find-file-regexp "^#"
139 "*Regular expression used by `generic-mode-find-file-hook'.
140Files in fundamental mode whose first few lines contain a match
141for this regexp, should be put into Default-Generic mode instead.
142The number of lines tested for the matches is specified by the
143value of the variable `generic-lines-to-scan', which see."
144 :group 'generic-x
145 :type 'regexp)
146
147(defcustom generic-ignore-files-regexp "[Tt][Aa][Gg][Ss]\\'"
148 "*Regular expression used by `generic-mode-find-file-hook'.
149Files whose names match this regular expression should not be put
150into Default-Generic mode, even if they have lines which match
151the regexp in `generic-find-file-regexp'. If the value is nil,
152`generic-mode-find-file-hook' does not check the file names."
153 :group 'generic-x
154 :type '(choice (const :tag "Don't check file names" nil) regexp))
155
156;; This generic mode is always defined
d4fb185d 157(define-generic-mode default-generic-mode (list ?#) nil nil nil nil)
9285b8bc
LK
158
159;; A more general solution would allow us to enter generic-mode for
160;; *any* comment character, but would require us to synthesize a new
161;; generic-mode on the fly. I think this gives us most of what we
162;; want.
163(defun generic-mode-find-file-hook ()
164 "Hook function to enter Default-Generic mode automatically.
165
166Done if the first few lines of a file in Fundamental mode start
167with a match for the regexp in `generic-find-file-regexp', unless
168the file's name matches the regexp which is the value of the
169variable `generic-ignore-files-regexp'.
170
171This hook will be installed if the variable
172`generic-use-find-file-hook' is non-nil. The variable
173`generic-lines-to-scan' determines the number of lines to look at."
174 (when (and (eq major-mode 'fundamental-mode)
175 (or (null generic-ignore-files-regexp)
176 (not (string-match
177 generic-ignore-files-regexp
178 (file-name-sans-versions buffer-file-name)))))
179 (save-excursion
180 (goto-char (point-min))
181 (when (re-search-forward generic-find-file-regexp
182 (save-excursion
183 (forward-line generic-lines-to-scan)
184 (point)) t)
185 (goto-char (point-min))
186 (default-generic-mode)))))
187
9285b8bc
LK
188(and generic-use-find-file-hook
189 (add-hook 'find-file-hook 'generic-mode-find-file-hook))
190
191;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
192;; Other Generic modes
193;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
194
1fffafda
LK
195;; If you add a generic mode to this file, put it in one of these four
196;; lists as well.
197
198(defconst generic-default-modes
199 '(apache-conf-generic-mode
200 apache-log-generic-mode
201 hosts-generic-mode
202 java-manifest-generic-mode
203 java-properties-generic-mode
204 javascript-generic-mode
205 show-tabs-generic-mode
206 vrml-generic-mode)
207 "List of generic modes that are defined by default.")
208
209(defconst generic-mswindows-modes
210 '(bat-generic-mode
211 inf-generic-mode
212 ini-generic-mode
213 rc-generic-mode
214 reg-generic-mode
215 rul-generic-mode)
216 "List of generic modes that are defined by default on MS-Windows.")
217
218(defconst generic-unix-modes
219 '(alias-generic-mode
220 etc-fstab-generic-mode
221 etc-modules-conf-generic-mode
222 etc-passwd-generic-mode
223 etc-services-generic-mode
224 fvwm-generic-mode
225 inetd-conf-generic-mode
226 mailagent-rules-generic-mode
227 mailrc-generic-mode
228 named-boot-generic-mode
229 named-database-generic-mode
230 prototype-generic-mode
231 resolve-conf-generic-mode
232 samba-generic-mode
233 x-resource-generic-mode)
234 "List of generic modes that are defined by default on Unix.")
235
236(defconst generic-other-modes
237 '(astap-generic-mode
238 ibis-generic-mode
239 pkginfo-generic-mode
240 spice-generic-mode)
241 "List of generic mode that are not defined by default.")
ca1e63a5 242
ffe0c7ef 243(defcustom generic-define-mswindows-modes
d8677156 244 (memq system-type '(windows-nt ms-dos))
1fffafda
LK
245 "*Non-nil means the modes in `generic-mswindows-modes' will be defined.
246This is a list of MS-Windows specific generic modes. This variable
247only effects the default value of `generic-extras-enable-list'."
ca1e63a5 248 :group 'generic-x
1fffafda
LK
249 :type 'boolean
250 :version "22.1")
251(make-obsolete-variable 'generic-define-mswindows-modes 'generic-extras-enable-list "22.1")
ca1e63a5
RS
252
253(defcustom generic-define-unix-modes
d8677156 254 (not (memq system-type '(windows-nt ms-dos)))
1fffafda
LK
255 "*Non-nil means the modes in `generic-unix-modes' will be defined.
256This is a list of Unix specific generic modes. This variable only
257effects the default value of `generic-extras-enable-list'."
ca1e63a5 258 :group 'generic-x
1fffafda
LK
259 :type 'boolean
260 :version "22.1")
261(make-obsolete-variable 'generic-define-unix-modes 'generic-extras-enable-list "22.1")
262
263(defcustom generic-extras-enable-list
264 (append generic-default-modes
265 (if generic-define-mswindows-modes generic-mswindows-modes)
266 (if generic-define-unix-modes generic-unix-modes)
267 nil)
268 "List of generic modes to define.
269Each entry in the list should be a symbol. If you set this variable
270directly, without using customize, you must reload generic-x to put
271your changes into effect."
272 :group 'generic-x
273 :type (let (list)
274 (dolist (mode
275 (sort (append generic-default-modes
276 generic-mswindows-modes
277 generic-unix-modes
278 generic-other-modes
279 nil)
280 (lambda (a b)
281 (string< (symbol-name b)
282 (symbol-name a))))
283 (cons 'set list))
284 (push `(const ,mode) list)))
285 :set (lambda (s v)
286 (set-default s v)
287 (unless load-in-progress
288 (load "generic-x")))
289 :version "22.1")
ca1e63a5 290
ca1e63a5 291;;; Apache
d8677156
LK
292(when (memq 'apache-conf-generic-mode generic-extras-enable-list)
293
294(define-generic-mode apache-conf-generic-mode
82e38f3e 295 '(?#)
d8677156 296 nil
82e38f3e
LK
297 '(("^\\s-*\\(<.*>\\)" 1 font-lock-constant-face)
298 ("^\\s-*\\(\\sw+\\)\\s-" 1 font-lock-variable-name-face))
299 '("srm\\.conf\\'" "httpd\\.conf\\'" "access\\.conf\\'")
d8677156
LK
300 (list
301 (function
302 (lambda ()
ffe0c7ef
PB
303 (setq imenu-generic-expression
304 '((nil "^\\([-A-Za-z0-9_]+\\)" 1)
305 ("*Directories*" "^\\s-*<Directory\\s-*\\([^>]+\\)>" 1)
d8677156 306 ("*Locations*" "^\\s-*<Location\\s-*\\([^>]+\\)>" 1))))))
d4fb185d 307 "Generic mode for Apache or HTTPD configuration files."))
ffe0c7ef 308
d8677156 309(when (memq 'apache-log-generic-mode generic-extras-enable-list)
ffe0c7ef 310
d8677156 311(define-generic-mode apache-log-generic-mode
ffe0c7ef
PB
312 nil
313 nil
314 ;; Hostname ? user date request return-code number-of-bytes
315 '(("^\\([-a-zA-z0-9.]+\\) - [-A-Za-z]+ \\(\\[.*\\]\\)"
316 (1 font-lock-constant-face)
d8677156 317 (2 font-lock-variable-name-face)))
82e38f3e 318 '("access_log\\'")
ffe0c7ef 319 nil
d4fb185d 320 "Mode for Apache log files"))
ffe0c7ef 321
ca1e63a5 322;;; Samba
d8677156
LK
323(when (memq 'samba-generic-mode generic-extras-enable-list)
324
325(define-generic-mode samba-generic-mode
82e38f3e 326 '(?\; ?#)
d8677156 327 nil
82e38f3e 328 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face)
d8677156 329 ("^\\s-*\\(.+\\)=\\([^\r\n]*\\)"
82e38f3e
LK
330 (1 font-lock-variable-name-face)
331 (2 font-lock-type-face)))
332 '("smb\\.conf\\'")
333 '(generic-bracket-support)
d4fb185d 334 "Generic mode for Samba configuration files."))
ca1e63a5
RS
335
336;;; Fvwm
337;; This is pretty basic. Also, modes for other window managers could
338;; be defined as well.
d8677156 339(when (memq 'fvwm-generic-mode generic-extras-enable-list)
ca1e63a5 340
d8677156 341(define-generic-mode fvwm-generic-mode
82e38f3e
LK
342 '(?#)
343 '("AddToMenu"
344 "AddToFunc"
345 "ButtonStyle"
346 "EndFunction"
347 "EndPopup"
348 "Function"
349 "IconPath"
350 "Key"
351 "ModulePath"
352 "Mouse"
353 "PixmapPath"
354 "Popup"
355 "Style")
d8677156 356 nil
82e38f3e 357 '("\\.fvwmrc\\'" "\\.fvwm2rc\\'")
d8677156 358 nil
d4fb185d 359 "Generic mode for FVWM configuration files."))
ca1e63a5
RS
360
361;;; X Resource
362;; I'm pretty sure I've seen an actual mode to do this, but I don't
363;; think it's standard with Emacs
d8677156 364(when (memq 'x-resource-generic-mode generic-extras-enable-list)
ca1e63a5 365
d8677156 366(define-generic-mode x-resource-generic-mode
82e38f3e 367 '(?!)
d8677156 368 nil
82e38f3e
LK
369 '(("^\\([^:\n]+:\\)" 1 font-lock-variable-name-face))
370 '("\\.Xdefaults\\'" "\\.Xresources\\'" "\\.Xenvironment\\'" "\\.ad\\'")
d8677156 371 nil
d4fb185d 372 "Generic mode for X Resource configuration files."))
ca1e63a5
RS
373
374;;; Hosts
d8677156 375(when (memq 'hosts-generic-mode generic-extras-enable-list)
ca1e63a5 376
d8677156 377(define-generic-mode hosts-generic-mode
82e38f3e
LK
378 '(?#)
379 '("localhost")
380 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face))
381 '("[hH][oO][sS][tT][sS]\\'")
d8677156 382 nil
d4fb185d 383 "Generic mode for HOSTS files."))
ca1e63a5
RS
384
385;;; Windows INF files
d8677156 386(when (memq 'inf-generic-mode generic-extras-enable-list)
ca1e63a5 387
d8677156 388(define-generic-mode inf-generic-mode
82e38f3e 389 '(?\;)
d8677156 390 nil
82e38f3e
LK
391 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face))
392 '("\\.[iI][nN][fF]\\'")
393 '(generic-bracket-support)
d4fb185d 394 "Generic mode for MS-Windows INF files."))
ca1e63a5
RS
395
396;;; Windows INI files
397;; Should define escape character as well!
d8677156
LK
398(when (memq 'ini-generic-mode generic-extras-enable-list)
399
400(define-generic-mode ini-generic-mode
82e38f3e 401 '(?\;)
d8677156 402 nil
82e38f3e 403 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face)
d8677156
LK
404 ("^\\([^=\n\r]*\\)=\\([^\n\r]*\\)$"
405 (1 font-lock-function-name-face)
406 (2 font-lock-variable-name-face)))
82e38f3e 407 '("\\.[iI][nN][iI]\\'")
d8677156
LK
408 (list
409 (function
410 (lambda ()
411 (setq imenu-generic-expression
412 '((nil "^\\[\\(.*\\)\\]" 1)
413 ("*Variables*" "^\\s-*\\([^=]+\\)\\s-*=" 1))))))
a2d66c78
LK
414 "Generic mode for MS-Windows INI files.
415You can use `ini-generic-mode-find-file-hook' to enter this mode
d4fb185d 416automatically for INI files whose names do not end in \".ini\".")
a2d66c78
LK
417
418(defun ini-generic-mode-find-file-hook ()
419 "Hook function to enter Ini-Generic mode automatically for INI files.
420Done if the first few lines of a file in Fundamental mode look
421like an INI file. You can add this hook to `find-file-hook'."
422 (and (eq major-mode 'fundamental-mode)
423 (save-excursion
424 (goto-char (point-min))
425 (and (looking-at "^\\s-*\\[.*\\]")
426 (ini-generic-mode)))))
427(defalias 'generic-mode-ini-file-find-file-hook 'ini-generic-mode-find-file-hook))
ca1e63a5
RS
428
429;;; Windows REG files
430;;; Unfortunately, Windows 95 and Windows NT have different REG file syntax!
d8677156
LK
431(when (memq 'reg-generic-mode generic-extras-enable-list)
432
433(define-generic-mode reg-generic-mode
434 '(?\;)
435 '("key" "classes_root" "REGEDIT" "REGEDIT4")
82e38f3e
LK
436 '(("\\(\\[.*]\\)" 1 font-lock-constant-face)
437 ("^\\([^\n\r]*\\)\\s-*=" 1 font-lock-variable-name-face))
d8677156
LK
438 '("\\.[rR][eE][gG]\\'")
439 (list
440 (function
441 (lambda ()
442 (setq imenu-generic-expression
443 '((nil "^\\s-*\\(.*\\)\\s-*=" 1))))))
d4fb185d 444 "Generic mode for MS-Windows Registry files."))
ca1e63a5 445
60bdd17f 446;;; DOS/Windows BAT files
d8677156
LK
447(when (memq 'bat-generic-mode generic-extras-enable-list)
448
449(define-generic-mode bat-generic-mode
450 nil
451 nil
82e38f3e 452 (eval-when-compile
ca1e63a5 453 (list
82e38f3e
LK
454 ;; Make this one first in the list, otherwise comments will
455 ;; be over-written by other variables
456 '("^[@ \t]*\\([rR][eE][mM][^\n\r]*\\)" 1 font-lock-comment-face t)
457 '("^[ \t]*\\(::.*\\)" 1 font-lock-comment-face t)
458 '("^[@ \t]*\\([bB][rR][eE][aA][kK]\\|[vV][eE][rR][iI][fF][yY]\\)[ \t]+\\([oO]\\([nN]\\|[fF][fF]\\)\\)"
459 (1 font-lock-builtin-face)
460 (2 font-lock-constant-face t t))
461 ;; Any text (except ON/OFF) following ECHO is a string.
462 '("^[@ \t]*\\([eE][cC][hH][oO]\\)[ \t]+\\(\\([oO]\\([nN]\\|[fF][fF]\\)\\)\\|\\([^>|\r\n]+\\)\\)"
463 (1 font-lock-builtin-face)
464 (3 font-lock-constant-face t t)
465 (5 font-lock-string-face t t))
466 ;; These keywords appear as the first word on a line. (Actually, they
467 ;; can also appear after "if ..." or "for ..." clause, but since they
468 ;; are frequently used in simple text, we punt.)
469 ;; In `generic-bat-mode-setup-function' we make the keywords
470 ;; case-insensitive
471 (generic-make-keywords-list
472 '("for"
473 "if")
16a013c2 474 font-lock-keyword-face "^[@ \t]*")
82e38f3e
LK
475 ;; These keywords can be anywhere on a line
476 ;; In `generic-bat-mode-setup-function' we make the keywords
477 ;; case-insensitive
478 (generic-make-keywords-list
479 '("do"
480 "exist"
481 "errorlevel"
482 "goto"
483 "not")
16a013c2 484 font-lock-keyword-face)
82e38f3e
LK
485 ;; These are built-in commands. Only frequently-used ones are listed.
486 (generic-make-keywords-list
487 '("CALL" "call" "Call"
488 "CD" "cd" "Cd"
489 "CLS" "cls" "Cls"
490 "COPY" "copy" "Copy"
491 "DEL" "del" "Del"
492 "ECHO" "echo" "Echo"
493 "MD" "md" "Md"
494 "PATH" "path" "Path"
495 "PAUSE" "pause" "Pause"
903ec1ba 496 "PROMPT" "prompt" "Prompt"
82e38f3e
LK
497 "RD" "rd" "Rd"
498 "REN" "ren" "Ren"
499 "SET" "set" "Set"
500 "START" "start" "Start"
501 "SHIFT" "shift" "Shift")
16a013c2 502 font-lock-builtin-face "[ \t|\n]")
82e38f3e
LK
503 '("^[ \t]*\\(:\\sw+\\)" 1 font-lock-function-name-face t)
504 '("\\(%\\sw+%\\)" 1 font-lock-variable-name-face t)
505 '("\\(%[0-9]\\)" 1 font-lock-variable-name-face t)
506 '("\\(/[^/ \"\t\n]+\\)" 1 font-lock-type-face)
507 '("[\t ]+\\([+-][^\t\n\" ]+\\)" 1 font-lock-type-face)
508 '("[ \t\n|]\\<\\([gG][oO][tT][oO]\\)\\>[ \t]*\\(\\sw+\\)?"
509 (1 font-lock-keyword-face)
510 (2 font-lock-function-name-face nil t))
511 '("[ \t\n|]\\<\\([sS][eE][tT]\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*=?"
512 (1 font-lock-builtin-face)
513 (2 font-lock-variable-name-face t t))))
514 '("\\.[bB][aA][tT]\\'"
515 "\\`[cC][oO][nN][fF][iI][gG]\\."
516 "\\`[aA][uU][tT][oO][eE][xX][eE][cC]\\.")
517 '(generic-bat-mode-setup-function)
d4fb185d 518 "Generic mode for MS-Windows BAT files.")
d8677156
LK
519
520(defvar bat-generic-mode-syntax-table nil
1fffafda 521 "Syntax table in use in `bat-generic-mode' buffers.")
d8677156
LK
522
523(defvar bat-generic-mode-keymap (make-sparse-keymap)
524 "Keymap for bet-generic-mode.")
525
526(defun bat-generic-mode-compile ()
527 "Run the current BAT file in a compilation buffer."
528 (interactive)
529 (let ((compilation-buffer-name-function
530 (function
531 (lambda(ign)
532 (concat "*" (buffer-file-name) "*")))))
533 (compile
534 (concat (w32-shell-name) " -c " (buffer-file-name)))))
535
a2d66c78 536(eval-when-compile (require 'comint))
d8677156
LK
537(defun bat-generic-mode-run-as-comint ()
538 "Run the current BAT file in a comint buffer."
539 (interactive)
540 (require 'comint)
541 (let* ((file (buffer-file-name))
542 (buf-name (concat "*" file "*")))
543 (save-excursion
544 (set-buffer
545 (get-buffer-create buf-name))
546 (erase-buffer)
547 (comint-mode)
548 (comint-exec
549 buf-name
550 file
551 (w32-shell-name)
552 nil
553 (list "-c" file))
554 (display-buffer buf-name))))
555
556(define-key bat-generic-mode-keymap "\C-c\C-c" 'bat-generic-mode-compile)
557
558;; Make underscores count as words
559(unless bat-generic-mode-syntax-table
560 (setq bat-generic-mode-syntax-table (make-syntax-table))
16a013c2 561 (modify-syntax-entry ?_ "w" bat-generic-mode-syntax-table))
d8677156 562
16a013c2
LK
563;; bat-generic-mode doesn't use the comment functionality of
564;; define-generic-mode because it has a three-letter comment-string,
565;; so we do it here manually instead
d8677156 566(defun generic-bat-mode-setup-function ()
82e38f3e
LK
567 (make-local-variable 'parse-sexp-ignore-comments)
568 (make-local-variable 'comment-start)
569 (make-local-variable 'comment-start-skip)
570 (make-local-variable 'comment-end)
571 (setq imenu-generic-expression '((nil "^:\\(\\sw+\\)" 1))
d8677156 572 parse-sexp-ignore-comments t
82e38f3e
LK
573 comment-end ""
574 comment-start "REM "
575 comment-start-skip "[Rr][Ee][Mm] *")
576 (set-syntax-table bat-generic-mode-syntax-table)
d8677156 577 ;; Make keywords case-insensitive
16a013c2 578 (setq font-lock-defaults '(generic-font-lock-keywords nil t))
d8677156 579 (use-local-map bat-generic-mode-keymap)))
ca1e63a5
RS
580
581;;; Mailagent
82e38f3e
LK
582;; Mailagent is a Unix mail filtering program. Anyone wanna do a
583;; generic mode for procmail?
d8677156
LK
584(when (memq 'mailagent-rules-generic-mode generic-extras-enable-list)
585
586(define-generic-mode mailagent-rules-generic-mode
82e38f3e
LK
587 '(?#)
588 '("SAVE" "DELETE" "PIPE" "ANNOTATE" "REJECT")
589 '(("^\\(\\sw+\\)\\s-*=" 1 font-lock-variable-name-face)
590 ("\\s-/\\([^/]+\\)/[i, \t\n]" 1 font-lock-constant-face))
591 '("\\.rules\\'")
16a013c2
LK
592 (list
593 (function
594 (lambda ()
595 (setq imenu-generic-expression
596 '((nil "\\s-/\\([^/]+\\)/[i, \t\n]" 1))))))
d4fb185d 597 "Mode for Mailagent rules files."))
ca1e63a5
RS
598
599;; Solaris/Sys V prototype files
d8677156
LK
600(when (memq 'prototype-generic-mode generic-extras-enable-list)
601
602(define-generic-mode prototype-generic-mode
82e38f3e 603 '(?#)
d8677156
LK
604 nil
605 '(("^\\([0-9]\\)?\\s-*\\([a-z]\\)\\s-+\\([A-Za-z_]+\\)\\s-+\\([^\n\r]*\\)$"
606 (2 font-lock-constant-face)
607 (3 font-lock-keyword-face))
608 ("^\\([a-z]\\) \\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
609 (1 font-lock-constant-face)
610 (2 font-lock-keyword-face)
611 (3 font-lock-variable-name-face))
612 ("^\\(!\\s-*\\(search\\|include\\|default\\)\\)\\s-*\\([^\n\r]*\\)$"
613 (1 font-lock-keyword-face)
614 (3 font-lock-variable-name-face))
615 ("^\\(!\\s-*\\sw+\\)=\\([^\n\r]*\\)$"
616 (1 font-lock-keyword-face)
617 (2 font-lock-variable-name-face)))
82e38f3e 618 '("prototype\\'")
d8677156 619 nil
d4fb185d 620 "Mode for Sys V prototype files."))
ca1e63a5
RS
621
622;; Solaris/Sys V pkginfo files
d8677156
LK
623(when (memq 'pkginfo-generic-mode generic-extras-enable-list)
624
625(define-generic-mode pkginfo-generic-mode
82e38f3e 626 '(?#)
d8677156
LK
627 nil
628 '(("^\\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
629 (1 font-lock-keyword-face)
630 (2 font-lock-variable-name-face)))
82e38f3e 631 '("pkginfo\\'")
d8677156 632 nil
d4fb185d 633 "Mode for Sys V pkginfo files."))
ca1e63a5
RS
634
635;; Javascript mode
ffe0c7ef 636;; Includes extra keywords from Armando Singer [asinger@MAIL.COLGATE.EDU]
1fffafda
LK
637(when (memq 'javascript-generic-mode generic-extras-enable-list)
638
d8677156 639(define-generic-mode javascript-generic-mode
82e38f3e
LK
640 '("//" ("/*" . "*/"))
641 '("break"
642 "case"
643 "continue"
644 "default"
645 "delete"
646 "do"
647 "else"
648 "export"
649 "for"
650 "function"
651 "if"
652 "import"
653 "in"
654 "new"
655 "return"
656 "switch"
657 "this"
658 "typeof"
659 "var"
660 "void"
661 "while"
662 "with"
663 ;; words reserved for ECMA extensions below
664 "catch"
665 "class"
666 "const"
667 "debugger"
668 "enum"
669 "extends"
670 "finally"
671 "super"
672 "throw"
673 "try"
674 ;; Java Keywords reserved by JavaScript
675 "abstract"
676 "boolean"
677 "byte"
678 "char"
679 "double"
680 "false"
681 "final"
682 "float"
683 "goto"
684 "implements"
685 "instanceof"
686 "int"
687 "interface"
688 "long"
689 "native"
690 "null"
691 "package"
692 "private"
693 "protected"
694 "public"
695 "short"
696 "static"
697 "synchronized"
698 "throws"
699 "transient"
700 "true")
701 '(("^\\s-*function\\s-+\\([A-Za-z0-9_]+\\)"
702 (1 font-lock-function-name-face))
703 ("^\\s-*var\\s-+\\([A-Za-z0-9_]+\\)"
704 (1 font-lock-variable-name-face)))
705 '("\\.js\\'")
ca1e63a5 706 (list
ffe0c7ef 707 (function
ca1e63a5 708 (lambda ()
ffe0c7ef
PB
709 (setq imenu-generic-expression
710 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1)
d8677156 711 ("*Variables*" "^var\\s-+\\([A-Za-z0-9_]+\\)" 1))))))
d4fb185d 712 "Mode for JavaScript files."))
ca1e63a5
RS
713
714;; VRML files
1fffafda
LK
715(when (memq 'vrml-generic-mode generic-extras-enable-list)
716
d8677156 717(define-generic-mode vrml-generic-mode
82e38f3e
LK
718 '(?#)
719 '("DEF"
720 "NULL"
721 "USE"
722 "Viewpoint"
723 "ambientIntensity"
724 "appearance"
725 "children"
726 "color"
727 "coord"
728 "coordIndex"
729 "creaseAngle"
730 "diffuseColor"
731 "emissiveColor"
732 "fieldOfView"
733 "geometry"
734 "info"
735 "material"
736 "normal"
737 "orientation"
738 "position"
739 "shininess"
740 "specularColor"
741 "texCoord"
742 "texture"
743 "textureTransform"
744 "title"
745 "transparency"
746 "type")
747 '(("USE\\s-+\\([-A-Za-z0-9_]+\\)"
748 (1 font-lock-constant-face))
749 ("DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
750 (1 font-lock-type-face)
751 (2 font-lock-constant-face))
752 ("^\\s-*\\([-A-Za-z0-9_]+\\)\\s-*{"
753 (1 font-lock-function-name-face))
754 ("^\\s-*\\(geometry\\|appearance\\|material\\)\\s-+\\([-A-Za-z0-9_]+\\)"
755 (2 font-lock-variable-name-face)))
756 '("\\.wrl\\'")
ca1e63a5 757 (list
ffe0c7ef 758 (function
ca1e63a5 759 (lambda ()
ffe0c7ef 760 (setq imenu-generic-expression
ca1e63a5 761 '((nil "^\\([A-Za-z0-9_]+\\)\\s-*{" 1)
ffe0c7ef 762 ("*Definitions*"
ca1e63a5 763 "DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
d8677156 764 1))))))
d4fb185d 765 "Generic Mode for VRML files."))
ca1e63a5
RS
766
767;; Java Manifests
1fffafda
LK
768(when (memq 'java-manifest-generic-mode generic-extras-enable-list)
769
d8677156 770(define-generic-mode java-manifest-generic-mode
82e38f3e
LK
771 '(?#)
772 '("Name"
773 "Digest-Algorithms"
774 "Manifest-Version"
775 "Required-Version"
776 "Signature-Version"
777 "Magic"
778 "Java-Bean"
779 "Depends-On")
ca1e63a5
RS
780 '(("^Name:\\s-+\\([^\n\r]*\\)$"
781 (1 font-lock-variable-name-face))
782 ("^\\(Manifest\\|Required\\|Signature\\)-Version:\\s-+\\([^\n\r]*\\)$"
d8677156 783 (2 font-lock-constant-face)))
82e38f3e 784 '("[mM][aA][nN][iI][fF][eE][sS][tT]\\.[mM][fF]\\'")
ca1e63a5 785 nil
d4fb185d 786 "Mode for Java Manifest files"))
ca1e63a5
RS
787
788;; Java properties files
1fffafda
LK
789(when (memq 'java-properties-generic-mode generic-extras-enable-list)
790
d8677156 791(define-generic-mode java-properties-generic-mode
82e38f3e 792 '(?! ?#)
ca1e63a5 793 nil
82e38f3e
LK
794 (eval-when-compile
795 (let ((java-properties-key
796 "\\(\\([-A-Za-z0-9_\\./]\\|\\(\\\\[ =:]\\)\\)+\\)")
797 (java-properties-value
798 "\\([^\r\n]*\\)"))
799 ;; Property and value can be separated in a number of different ways:
800 ;; * whitespace
801 ;; * an equal sign
802 ;; * a colon
803 (mapcar
804 (function
805 (lambda (elt)
806 (list
807 (concat "^" java-properties-key elt java-properties-value "$")
808 '(1 font-lock-constant-face)
809 '(4 font-lock-variable-name-face))))
810 ;; These are the separators
811 '(":\\s-*" "\\s-+" "\\s-*=\\s-*"))))
ca1e63a5 812 nil
bb53e1ee
RS
813 (list
814 (function
815 (lambda ()
ffe0c7ef 816 (setq imenu-generic-expression
d8677156 817 '((nil "^\\([^#! \t\n\r=:]+\\)" 1))))))
d4fb185d 818 "Mode for Java properties files."))
ca1e63a5
RS
819
820;; C shell alias definitions
d8677156 821(when (memq 'alias-generic-mode generic-extras-enable-list)
ef1c5063 822
d8677156 823(define-generic-mode alias-generic-mode
82e38f3e
LK
824 '(?#)
825 '("alias" "unalias")
ca1e63a5
RS
826 '(("^alias\\s-+\\([-A-Za-z0-9_]+\\)\\s-+"
827 (1 font-lock-variable-name-face))
828 ("^unalias\\s-+\\([-A-Za-z0-9_]+\\)\\s-*$"
d8677156 829 (1 font-lock-variable-name-face)))
82e38f3e 830 '("alias\\'")
ca1e63a5
RS
831 (list
832 (function
833 (lambda ()
ffe0c7ef 834 (setq imenu-generic-expression
d8677156 835 '((nil "^\\(alias\\|unalias\\)\\s-+\\([-a-zA-Z0-9_]+\\)" 2))))))
d4fb185d 836 "Mode for C Shell alias files."))
ca1e63a5
RS
837
838;;; Windows RC files
839;; Contributed by ACorreir@pervasive-sw.com (Alfred Correira)
d8677156
LK
840(when (memq 'rc-generic-mode generic-extras-enable-list)
841
842(define-generic-mode rc-generic-mode
82e38f3e
LK
843 ;; '(?\/)
844 '("//")
d8677156
LK
845 '("ACCELERATORS"
846 "AUTO3STATE"
847 "AUTOCHECKBOX"
848 "AUTORADIOBUTTON"
849 "BITMAP"
850 "BOTTOMMARGIN"
851 "BUTTON"
852 "CAPTION"
853 "CHARACTERISTICS"
854 "CHECKBOX"
855 "CLASS"
856 "COMBOBOX"
857 "CONTROL"
858 "CTEXT"
859 "CURSOR"
860 "DEFPUSHBUTTON"
861 "DESIGNINFO"
862 "DIALOG"
863 "DISCARDABLE"
864 "EDITTEXT"
865 "EXSTYLE"
866 "FONT"
867 "GROUPBOX"
868 "GUIDELINES"
869 "ICON"
870 "LANGUAGE"
871 "LEFTMARGIN"
872 "LISTBOX"
873 "LTEXT"
874 "MENUITEM SEPARATOR"
875 "MENUITEM"
876 "MENU"
877 "MOVEABLE"
878 "POPUP"
879 "PRELOAD"
880 "PURE"
881 "PUSHBOX"
882 "PUSHBUTTON"
883 "RADIOBUTTON"
884 "RCDATA"
885 "RIGHTMARGIN"
886 "RTEXT"
887 "SCROLLBAR"
888 "SEPARATOR"
889 "STATE3"
890 "STRINGTABLE"
891 "STYLE"
892 "TEXTINCLUDE"
893 "TOOLBAR"
894 "TOPMARGIN"
895 "VERSIONINFO"
896 "VERSION")
897 ;; the choice of what tokens go where is somewhat arbitrary,
898 ;; as is the choice of which value tokens are included, as
899 ;; the choice of face for each token group
82e38f3e
LK
900 (eval-when-compile
901 (list
d8677156 902 (generic-make-keywords-list
82e38f3e
LK
903 '("FILEFLAGSMASK"
904 "FILEFLAGS"
905 "FILEOS"
906 "FILESUBTYPE"
907 "FILETYPE"
908 "FILEVERSION"
909 "PRODUCTVERSION")
16a013c2 910 font-lock-type-face)
d8677156 911 (generic-make-keywords-list
82e38f3e
LK
912 '("BEGIN"
913 "BLOCK"
914 "END"
915 "VALUE")
16a013c2 916 font-lock-function-name-face)
82e38f3e
LK
917 '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face)
918 '("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face)
919 '("^#[ \t]*\\(elif\\|if\\)\\>"
920 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil
921 (1 font-lock-constant-face)
922 (2 font-lock-variable-name-face nil t)))
923 '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
924 (1 font-lock-constant-face)
925 (2 font-lock-variable-name-face nil t))))
60c19d5e 926 '("\\.[rR][cC]\\'")
82e38f3e 927 nil
d4fb185d 928 "Generic mode for MS-Windows Resource files."))
ca1e63a5 929
ef1c5063 930;; InstallShield RUL files
ca1e63a5 931;; Contributed by Alfred.Correira@Pervasive.Com
9845e669 932;; Bugfixes by "Rolf Sandau" <Rolf.Sandau@marconi.com>
d8677156
LK
933(when (memq 'rul-generic-mode generic-extras-enable-list)
934
82e38f3e
LK
935(eval-when-compile
936
ef1c5063 937;;; build the regexp strings using regexp-opt
82e38f3e
LK
938(defconst installshield-statement-keyword-list
939 '("abort"
940 "begin"
941 "call"
942 "case"
943 "declare"
944 "default"
945 "downto"
946 "elseif"
947 "else"
948 "endfor"
949 "endif"
950 "endswitch"
951 "endwhile"
952 "end"
953 "exit"
954 "external"
955 "for"
956 "function"
957 ;; "goto" -- handled elsewhere
958 "if"
959 "program"
960 "prototype"
961 "repeat"
962 "return"
963 "step"
964 "switch"
965 "then"
966 "to"
967 "typedef"
968 "until"
969 "void"
970 "while")
ef1c5063
RS
971 "Statement keywords used in InstallShield 3 and 5.")
972
82e38f3e
LK
973(defconst installshield-system-functions-list
974 '("AddFolderIcon"
975 "AddProfString"
976 "AddressString"
977 "AppCommand"
978 "AskDestPath"
979 "AskOptions"
980 "AskPath"
981 "AskText"
982 "AskYesNo"
983 "BatchDeleteEx"
984 "BatchFileLoad"
985 "BatchFileSave"
986 "BatchFind"
987 "BatchGetFileName"
988 "BatchMoveEx"
989 "BatchSetFileName"
990 "ChangeDirectory"
991 "CloseFile"
992 "CmdGetHwndDlg"
993 "ComponentAddItem" ; differs between IS3 and IS5
994 "ComponentCompareSizeRequired" ; IS5 only
995 "ComponentDialog"
996 "ComponentError" ; IS5 only
997 "ComponentFileEnum" ; IS5 only
998 "ComponentFileInfo" ; IS5 only
999 "ComponentFilterLanguage" ; IS5 only
1000 "ComponentFilterOS" ; IS5 only
1001 "ComponentGetData" ; IS5 only
1002 "ComponentGetItemInfo" ; IS3 only
1003 "ComponentGetItemSize" ; differs between IS3 and IS5
1004 "ComponentIsItemSelected" ; differs between IS3 and IS5
1005 "ComponentListItems"
1006 "ComponentMoveData" ; IS5 only
1007 "ComponentSelectItem" ; differs between IS3 and IS5
1008 "ComponentSetData" ; IS5 only
1009 "ComponentSetItemInfo" ; IS3 only
1010 "ComponentSetTarget" ; IS5 only
1011 "ComponentSetupTypeEnum" ; IS5 only
1012 "ComponentSetupTypeGetData" ; IS5 only
1013 "ComponentSetupTypeSet" ; IS5 only
1014 "ComponentTotalSize"
1015 "ComponentValidate" ; IS5 only
1016 "CompressAdd" ; IS3 only
1017 "CompressDel" ; IS3 only
1018 "CompressEnum" ; IS3 only
1019 "CompressGet" ; IS3 only
1020 "CompressInfo" ; IS3 only
1021 "CopyFile"
1022 "CreateDir"
1023 "CreateFile"
1024 "CreateProgramFolder"
1025 "DeinstallSetReference" ; IS5 only
1026 "DeinstallStart"
1027 "Delay"
1028 "DeleteDir"
1029 "DeleteFile"
1030 "DialogSetInfo"
1031 "Disable"
1032 "DoInstall"
1033 "Do"
1034 "Enable"
1035 "EnterDisk"
1036 "ExistsDir"
1037 "ExistsDisk"
1038 "ExitProgMan"
1039 "EzBatchAddPath"
1040 "EzBatchAddString"
1041 "EzBatchReplace"
1042 "EzConfigAddDriver"
1043 "EzConfigAddString"
1044 "EzConfigGetValue"
1045 "EzConfigSetValue"
1046 "EzDefineDialog"
1047 "FileCompare"
1048 "FileDeleteLine"
1049 "FileGrep"
1050 "FileInsertLine"
1051 "FileSetBeginDefine" ; IS3 only
1052 "FileSetEndDefine" ; IS3 only
1053 "FileSetPerformEz" ; IS3 only
1054 "FileSetPerform" ; IS3 only
1055 "FileSetReset" ; IS3 only
1056 "FileSetRoot" ; IS3 only
1057 "FindAllDirs"
1058 "FindAllFiles"
1059 "FindFile"
1060 "FindWindow"
1061 "GetDiskSpace"
1062 "GetDisk"
1063 "GetEnvVar"
1064 "GetExtents"
1065 "GetFileInfo"
1066 "GetLine"
1067 "GetProfInt"
1068 "GetProfString"
1069 "GetSystemInfo"
1070 "GetValidDrivesList"
1071 "GetVersion"
1072 "GetWindowHandle"
1073 "InstallationInfo"
1074 "Is"
1075 "LaunchApp"
1076 "LaunchAppAndWait"
1077 "ListAddItem"
1078 "ListAddString"
1079 "ListCount"
1080 "ListCreate"
1081 "ListDestroy"
1082 "ListFindItem"
1083 "ListFindString"
1084 "ListGetFirstItem"
1085 "ListGetFirstString"
1086 "ListGetNextItem"
1087 "ListGetNextString"
1088 "ListReadFromFile"
1089 "ListSetCurrentItem"
1090 "ListSetNextItem"
1091 "ListSetNextString"
1092 "ListSetIndex"
1093 "ListWriteToFile"
1094 "LongPathToQuote"
1095 "LongPathToShortPath"
1096 "MessageBox"
1097 "NumToStr"
1098 "OpenFileMode"
1099 "OpenFile"
1100 "ParsePath"
1101 "PathAdd"
1102 "PathDelete"
1103 "PathFind"
1104 "PathGet"
1105 "PathMove"
1106 "PathSet"
1107 "Path"
1108 "PlaceBitmap"
1109 "PlaceWindow"
1110 "PlayMMedia" ; IS5 only
1111 "ProgDefGroupType"
1112 "RegDBCreateKeyEx"
1113 "RegDBDeleteValue"
1114 "RegDBGetItem"
1115 "RegDBKeyExist"
1116 "RegDBSetItem"
1117 "RegDBGetKeyValueEx"
1118 "RegDBSetKeyValueEx"
1119 "RegDBSetDefaultRoot"
1120 "RenameFile"
1121 "ReplaceFolderIcon"
1122 "ReplaceProfString"
1123 "SdAskDestPath"
1124 "SdAskOptions"
1125 "SdAskOptionsList"
1126 "SdBitmap"
1127 "SdCloseDlg"
1128 "SdComponentAdvCheckSpace"
1129 "SdComponentAdvInit"
1130 "SdComponentAdvUpdateSpace"
1131 "SdComponentDialog"
1132 "SdComponentDialog2"
1133 "SdComponentDialogAdv"
1134 "SdComponentDialogEx"
1135 "SdComponentDlgCheckSpace"
1136 "SdComponentMult"
1137 "SdConfirmNewDir"
1138 "SdConfirmRegistration"
1139 "SdDiskSpace"
1140 "SdDisplayTopics"
1141 "SdDoStdButton"
1142 "SdEnablement"
1143 "SdError"
1144 "SdFinish"
1145 "SdFinishInit32"
1146 "SdFinishReboot"
1147 "SdGeneralInit"
1148 "SdGetItemName"
1149 "SdGetTextExtent"
1150 "SdGetUserCompanyInfo"
1151 "SdInit"
1152 "SdIsShellExplorer"
1153 "SdIsStdButton"
1154 "SdLicense"
1155 "SdMakeName"
1156 "SdOptionInit"
1157 "SdOptionSetState"
1158 "SdOptionsButtons"
1159 "SdOptionsButtonsInit"
1160 "SdPlugInProductName"
1161 "SdProductName"
1162 "SdRegEnableButton"
1163 "SdRegExEnableButton"
1164 "SdRegisterUser"
1165 "SdRegisterUserEx"
1166 "SdRemoveEndSpace"
1167 "SdSelectFolder"
1168 "SdSetSequentialItems"
1169 "SdSetStatic"
1170 "SdSetupTypeEx" ; IS5 only
1171 "SdSetupType"
1172 "SdShowAnyDialog"
1173 "SdShowDlgEdit1"
1174 "SdShowDlgEdit2"
1175 "SdShowDlgEdit3"
1176 "SdShowFileMods"
1177 "SdShowInfoList"
1178 "SdShowMsg"
1179 "SdStartCopy"
1180 "SdUnInit"
1181 "SdUpdateComponentSelection"
1182 "SdWelcome"
1183 "SendMessage"
1184 "SetColor"
1185 "SetFont"
1186 "SetDialogTitle"
1187 "SetDisplayEffect" ; IS5 only
1188 "SetFileInfo"
1189 "SetForegroundWindow"
1190 "SetStatusWindow"
1191 "SetTitle"
1192 "SetupType"
1193 "ShowProgramFolder"
1194 "Split" ; IS3 only
1195 "SprintfBox"
1196 "Sprintf"
1197 "StatusUpdate"
1198 "StrCompare"
1199 "StrFind"
1200 "StrGetTokens"
1201 "StrLength"
1202 "StrRemoveLastSlash"
1203 "StrToLower"
1204 "StrToNum"
1205 "StrToUpper"
1206 "StrSub"
1207 "VarRestore"
1208 "VarSave"
1209 "VerCompare"
1210 "VerGetFileVersion"
1211 "WaitOnDialog"
1212 "Welcome"
1213 "WriteLine"
1214 "WriteProfString"
1215 "XCopyFile")
ef1c5063
RS
1216 "System functions defined in InstallShield 3 and 5.")
1217
82e38f3e
LK
1218(defconst installshield-system-variables-list
1219 '("BATCH_INSTALL"
1220 "CMDLINE"
1221 "COMMONFILES"
1222 "CORECOMPONENTHANDLING"
1223 "DIALOGCACHE"
1224 "ERRORFILENAME"
1225 "FOLDER_DESKTOP"
1226 "FOLDER_PROGRAMS"
1227 "FOLDER_STARTMENU"
1228 "FOLDER_STARTUP"
1229 "INFOFILENAME"
1230 "ISRES"
1231 "ISUSER"
1232 "ISVERSION"
1233 "MEDIA"
1234 "MODE"
1235 "PROGRAMFILES"
1236 "SELECTED_LANGUAGE"
1237 "SRCDIR"
1238 "SRCDISK"
1239 "SUPPORTDIR"
1240 "TARGETDIR"
1241 "TARGETDISK"
1242 "UNINST"
1243 "WINDIR"
1244 "WINDISK"
1245 "WINMAJOR"
1246 "WINSYSDIR"
1247 "WINSYSDISK")
ef1c5063
RS
1248 "System variables used in InstallShield 3 and 5.")
1249
82e38f3e
LK
1250(defconst installshield-types-list
1251 '("BOOL"
1252 "BYREF"
1253 "CHAR"
1254 "HIWORD"
1255 "HWND"
1256 "INT"
1257 "LIST"
1258 "LONG"
1259 "LOWORD"
1260 "LPSTR"
1261 "NUMBER"
1262 "NUMBERLIST"
1263 "POINTER"
1264 "QUAD"
1265 "RGB"
1266 "SHORT"
1267 "STRINGLIST"
1268 "STRING")
ef1c5063
RS
1269 "Type keywords used in InstallShield 3 and 5.")
1270
1271;;; some might want to skip highlighting these to improve performance
82e38f3e
LK
1272(defconst installshield-funarg-constants-list
1273 '("AFTER"
1274 "APPEND"
1275 "ALLCONTENTS"
1276 "BACKBUTTON"
1277 "BACKGROUNDCAPTION"
1278 "BACKGROUND"
1279 "BACK"
1280 "BASEMEMORY"
1281 "BEFORE"
1282 "BIOS"
1283 "BITMAPICON"
1284 "BK_BLUE"
1285 "BK_GREEN"
1286 "BK_RED"
1287 "BLUE"
1288 "BOOTUPDRIVE"
1289 "CANCEL"
1290 "CDROM_DRIVE"
1291 "CDROM"
1292 "CHECKBOX95"
1293 "CHECKBOX"
1294 "CHECKLINE"
1295 "CHECKMARK"
1296 "COLORS"
1297 "COMMANDEX"
1298 "COMMAND"
1299 "COMP_NORMAL"
1300 "COMP_UPDATE_DATE"
1301 "COMP_UPDATE_SAME"
1302 "COMP_UPDATE_VERSION"
1303 "COMPACT"
1304 "CONTINUE"
1305 "CPU"
1306 "CUSTOM"
1307 "DATE"
1308 "DEFWINDOWMODE"
1309 "DIR_WRITEABLE"
1310 "DIRECTORY"
1311 "DISABLE"
1312 "DISK_TOTALSPACE"
1313 "DISK"
1314 "DLG_OPTIONS"
1315 "DLG_PATH"
1316 "DLG_TEXT"
1317 "DLG_ASK_YESNO"
1318 "DLG_ENTER_DISK"
1319 "DLG_ERR"
1320 "DLG_INFO_ALTIMAGE"
1321 "DLG_INFO_CHECKSELECTION"
1322 "DLG_INFO_KUNITS"
1323 "DLG_INFO_USEDECIMAL"
1324 "DLG_MSG_INFORMATION"
1325 "DLG_MSG_SEVERE"
1326 "DLG_MSG_WARNING"
1327 "DLG_STATUS"
1328 "DLG_WARNING"
1329 "DLG_USER_CAPTION"
1330 "DRIVE"
1331 "ENABLE"
1332 "END_OF_FILE"
1333 "END_OF_LIST"
1334 "ENVSPACE"
1335 "EQUALS"
1336 "EXCLUDE_SUBDIR"
1337 "EXCLUSIVE"
1338 "EXISTS"
1339 "EXIT"
1340 "EXTENDED_MEMORY"
1341 "EXTENSION_ONLY"
1342 "FAILIFEXISTS"
1343 "FALSE"
1344 "FEEDBACK_FULL"
1345 "FILE_ATTR_ARCHIVED"
1346 "FILE_ATTR_DIRECTORY"
1347 "FILE_ATTR_HIDDEN"
1348 "FILE_ATTR_NORMAL"
1349 "FILE_ATTR_READONLY"
1350 "FILE_ATTR_SYSTEM"
1351 "FILE_ATTRIBUTE"
1352 "FILE_DATE"
1353 "FILE_LINE_LENGTH"
1354 "FILE_MODE_APPEND"
1355 "FILE_MODE_BINARYREADONLY"
1356 "FILE_MODE_BINARY"
1357 "FILE_MODE_NORMAL"
1358 "FILE_NO_VERSION"
1359 "FILE_NOT_FOUND"
1360 "FILE_SIZE"
1361 "FILE_TIME"
1362 "FILENAME_ONLY"
1363 "FILENAME"
1364 "FIXED_DRIVE"
1365 "FOLDER_DESKTOP"
1366 "FOLDER_PROGRAMS"
1367 "FOLDER_STARTMENU"
1368 "FOLDER_STARTUP"
1369 "FREEENVSPACE"
1370 "FULLWINDOWMODE"
1371 "FULL"
1372 "FONT_TITLE"
1373 "GREATER_THAN"
1374 "GREEN"
1375 "HKEY_CLASSES_ROOT"
1376 "HKEY_CURRENT_USER"
1377 "HKEY_LOCAL_MACHINE"
1378 "HKEY_USERS"
1379 "HOURGLASS"
1380 "INCLUDE_SUBDIR"
1381 "INDVFILESTATUS"
1382 "INFORMATION"
1383 "IS_WINDOWSNT"
1384 "IS_WINDOWS95"
1385 "IS_WINDOWS"
1386 "IS_WIN32S"
1387 "ISTYPE"
1388 "LANGUAGE_DRV"
1389 "LANGUAGE"
1390 "LESS_THAN"
1391 "LIST_NULL"
1392 "LISTFIRST"
1393 "LISTNEXT"
1394 "LOCKEDFILE"
1395 "LOGGING"
1396 "LOWER_LEFT"
1397 "LOWER_RIGHT"
1398 "MAGENTA"
1399 "MOUSE_DRV"
1400 "MOUSE"
1401 "NETWORK_DRV"
1402 "NETWORK"
1403 "NEXT"
1404 "NONEXCLUSIVE"
1405 "NORMALMODE"
1406 "NOSET"
1407 "NOTEXISTS"
1408 "NOWAIT"
1409 "NO"
1410 "OFF"
1411 "ONLYDIR"
1412 "ON"
1413 "OSMAJOR"
1414 "OSMINOR"
1415 "OS"
1416 "OTHER_FAILURE"
1417 "PARALLEL"
1418 "PARTIAL"
1419 "PATH_EXISTS"
1420 "PATH"
1421 "RED"
1422 "REGDB_APPPATH_DEFAULT"
1423 "REGDB_APPPATH"
1424 "REGDB_BINARY"
1425 "REGDB_ERR_CONNECTIONEXISTS"
1426 "REGDB_ERR_CORRUPTEDREGSITRY"
1427 "REGDB_ERR_INITIALIZATION"
1428 "REGDB_ERR_INVALIDHANDLE"
1429 "REGDB_ERR_INVALIDNAME"
1430 "REGDB_NUMBER"
1431 "REGDB_STRING_EXPAND"
1432 "REGDB_STRING_MULTI"
1433 "REGDB_STRING"
1434 "REGDB_UNINSTALL_NAME"
1435 "REMOTE_DRIVE"
1436 "REMOVALE_DRIVE"
1437 "REPLACE_ITEM"
1438 "REPLACE"
1439 "RESET"
1440 "RESTART"
1441 "ROOT"
1442 "SELFREGISTER"
1443 "SERIAL"
1444 "SET"
1445 "SEVERE"
1446 "SHAREDFILE"
1447 "SHARE"
1448 "SILENTMODE"
1449 "SRCTARGETDIR"
1450 "STATUSBAR"
1451 "STATUSDLG"
1452 "STATUSOLD"
1453 "STATUS"
1454 "STYLE_NORMAL"
1455 "SW_MAXIMIZE"
1456 "SW_MINIMIZE"
1457 "SW_RESTORE"
1458 "SW_SHOW"
1459 "SYS_BOOTMACHINE"
1460 "TIME"
1461 "TRUE"
1462 "TYPICAL"
1463 "UPPER_LEFT"
1464 "UPPER_RIGHT"
1465 "VALID_PATH"
1466 "VERSION"
1467 "VIDEO"
1468 "VOLUMELABEL"
1469 "YELLOW"
1470 "YES"
1471 "WAIT"
1472 "WARNING"
1473 "WINMAJOR"
1474 "WINMINOR"
1475 "WIN32SINSTALLED"
1476 "WIN32SMAJOR"
1477 "WIN32SMINOR")
1478 "Function argument constants used in InstallShield 3 and 5."))
ca1e63a5 1479
d8677156 1480(defvar rul-generic-mode-syntax-table nil
1fffafda 1481 "Syntax table to use in `rul-generic-mode' buffers.")
d8677156
LK
1482
1483(setq rul-generic-mode-syntax-table
1484 (make-syntax-table c++-mode-syntax-table))
1485
82e38f3e
LK
1486(modify-syntax-entry ?\r "> b" rul-generic-mode-syntax-table)
1487(modify-syntax-entry ?\n "> b" rul-generic-mode-syntax-table)
d8677156
LK
1488
1489(modify-syntax-entry ?/ ". 124b" rul-generic-mode-syntax-table)
1490(modify-syntax-entry ?* ". 23" rul-generic-mode-syntax-table)
1491
1492;; here manually instead
1493(defun generic-rul-mode-setup-function ()
82e38f3e
LK
1494 (make-local-variable 'parse-sexp-ignore-comments)
1495 (make-local-variable 'comment-start)
1496 (make-local-variable 'comment-start-skip)
1497 (make-local-variable 'comment-end)
d8677156
LK
1498 (setq imenu-generic-expression
1499 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1))
1500 parse-sexp-ignore-comments t
1501 comment-end "*/"
1502 comment-start "/*"
1503;;; comment-end ""
1504;;; comment-start "//"
1505;;; comment-start-skip ""
1506 )
82e38f3e 1507 ;; (set-syntax-table rul-generic-mode-syntax-table)
d8677156
LK
1508 (setq font-lock-syntax-table rul-generic-mode-syntax-table))
1509
1510;; moved mode-definition behind defun-definition to be warning-free - 15.11.02/RSan
1511(define-generic-mode rul-generic-mode
1512 ;; Using "/*" and "*/" doesn't seem to be working right
82e38f3e
LK
1513 '("//" ("/*" . "*/" ))
1514 (eval-when-compile installshield-statement-keyword-list)
1515 (eval-when-compile
1516 (list
1517 ;; preprocessor constructs
1518 '("#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)"
1519 1 font-lock-string-face)
1520 '("#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
1521 (1 font-lock-reference-face)
1522 (2 font-lock-variable-name-face nil t))
1523 ;; indirect string constants
1524 '("\\(@[A-Za-z][A-Za-z0-9_]+\\)" 1 font-lock-builtin-face)
1525 ;; gotos
1526 '("[ \t]*\\(\\sw+:\\)" 1 font-lock-reference-face)
1527 '("\\<\\(goto\\)\\>[ \t]*\\(\\sw+\\)?"
1528 (1 font-lock-keyword-face)
1529 (2 font-lock-reference-face nil t))
1530 ;; system variables
1531 (generic-make-keywords-list
1532 installshield-system-variables-list
16a013c2 1533 font-lock-variable-name-face "[^_]" "[^_]")
82e38f3e
LK
1534 ;; system functions
1535 (generic-make-keywords-list
1536 installshield-system-functions-list
16a013c2 1537 font-lock-function-name-face "[^_]" "[^_]")
82e38f3e
LK
1538 ;; type keywords
1539 (generic-make-keywords-list
1540 installshield-types-list
16a013c2 1541 font-lock-type-face "[^_]" "[^_]")
82e38f3e
LK
1542 ;; function argument constants
1543 (generic-make-keywords-list
1544 installshield-funarg-constants-list
16a013c2 1545 font-lock-variable-name-face "[^_]" "[^_]"))) ; is this face the best choice?
60c19d5e 1546 '("\\.[rR][uU][lL]\\'")
82e38f3e 1547 '(generic-rul-mode-setup-function)
d4fb185d 1548 "Generic mode for InstallShield RUL files.")
d8677156 1549
ca1e63a5 1550(define-skeleton rul-if
d8677156
LK
1551 "Insert an if statement."
1552 "condition: "
1553 "if(" str ") then" \n
1554 > _ \n
1555 ( "other condition, %s: "
1556 > "elseif(" str ") then" \n
1557 > \n)
1558 > "else" \n
1559 > \n
1560 resume:
1561 > "endif;")
ca1e63a5
RS
1562
1563(define-skeleton rul-function
1564 "Insert a function statement."
1565 "function: "
1566 "function " str " ()" \n
1567 ( "local variables, %s: "
d8677156 1568 > " " str ";" \n)
ca1e63a5
RS
1569 > "begin" \n
1570 > _ \n
1571 resume:
d8677156 1572 > "end;"))
ca1e63a5
RS
1573
1574;; Additions by ACorreir@pervasive-sw.com (Alfred Correira)
1fffafda
LK
1575(when (memq 'mailrc-generic-mode generic-extras-enable-list)
1576
d8677156 1577(define-generic-mode mailrc-generic-mode
82e38f3e
LK
1578 '(?#)
1579 '("alias"
1580 "else"
1581 "endif"
1582 "group"
1583 "if"
1584 "ignore"
1585 "set"
1586 "source"
1587 "unset")
ca1e63a5 1588 '(("^\\s-*\\(alias\\|group\\)\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
16a013c2
LK
1589 (2 font-lock-constant-face)
1590 (3 font-lock-variable-name-face))
ca1e63a5 1591 ("^\\s-*\\(unset\\|set\\|ignore\\)\\s-+\\([-A-Za-z0-9_]+\\)=?\\([^\n\r#]*\\)\\(#.*\\)?$"
16a013c2
LK
1592 (2 font-lock-constant-face)
1593 (3 font-lock-variable-name-face))
5d1c5247
FP
1594 ("^\\s-*\\(source\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1595 (2 font-lock-variable-name-face)))
82e38f3e 1596 '("\\.mailrc\\'")
ca1e63a5 1597 nil
d4fb185d 1598 "Mode for mailrc files."))
ca1e63a5 1599
bb53e1ee 1600;; Inetd.conf
d8677156 1601(when (memq 'inetd-conf-generic-mode generic-extras-enable-list)
bb53e1ee 1602
d8677156 1603(define-generic-mode inetd-conf-generic-mode
82e38f3e
LK
1604 '(?#)
1605 '("stream"
1606 "dgram"
1607 "tcp"
1608 "udp"
1609 "wait"
1610 "nowait"
1611 "internal")
1612 '(("^\\([-A-Za-z0-9_]+\\)" 1 font-lock-type-face))
bb53e1ee 1613 '("/etc/inetd.conf\\'")
ffe0c7ef 1614 (list
bb53e1ee
RS
1615 (function
1616 (lambda ()
ffe0c7ef 1617 (setq imenu-generic-expression
d4fb185d 1618 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
bb53e1ee
RS
1619
1620;; Services
d8677156 1621(when (memq 'etc-services-generic-mode generic-extras-enable-list)
bb53e1ee 1622
d8677156 1623(define-generic-mode etc-services-generic-mode
82e38f3e
LK
1624 '(?#)
1625 '("tcp"
1626 "udp"
1627 "ddp")
d8677156 1628 '(("^\\([-A-Za-z0-9_]+\\)\\s-+\\([0-9]+\\)/"
82e38f3e
LK
1629 (1 font-lock-type-face)
1630 (2 font-lock-variable-name-face)))
bb53e1ee 1631 '("/etc/services\\'")
ffe0c7ef 1632 (list
bb53e1ee
RS
1633 (function
1634 (lambda ()
ffe0c7ef 1635 (setq imenu-generic-expression
d4fb185d 1636 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
bb53e1ee
RS
1637
1638;; Password and Group files
d8677156 1639(when (memq 'etc-passwd-generic-mode generic-extras-enable-list)
bb53e1ee 1640
d8677156 1641(define-generic-mode etc-passwd-generic-mode
bb53e1ee 1642 nil ;; No comment characters
82e38f3e
LK
1643 '("root") ;; Only one keyword
1644 (eval-when-compile
1645 (list
1646 (list
1647 (concat
1648 "^"
1649 ;; User name -- Never blank!
1650 "\\([^:]+\\)"
1651 ":"
1652 ;; Password, UID and GID
1653 (mapconcat
1654 'identity
1655 (make-list 3 "\\([^:]+\\)")
1656 ":")
1657 ":"
1658 ;; GECOS/Name -- might be blank
1659 "\\([^:]*\\)"
1660 ":"
1661 ;; Home directory and shell
1662 "\\([^:]+\\)"
1663 ":?"
1664 "\\([^:]*\\)"
1665 "$")
1666 '(1 font-lock-type-face)
1667 '(5 font-lock-variable-name-face)
1668 '(6 font-lock-constant-face)
1669 '(7 font-lock-warning-face))
1670 '("^\\([^:]+\\):\\([^:]*\\):\\([0-9]+\\):\\(.*\\)$"
1671 (1 font-lock-type-face)
1672 (4 font-lock-variable-name-face))))
bb53e1ee 1673 '("/etc/passwd\\'" "/etc/group\\'")
ffe0c7ef 1674 (list
bb53e1ee
RS
1675 (function
1676 (lambda ()
ffe0c7ef 1677 (setq imenu-generic-expression
d4fb185d 1678 '((nil "^\\([-A-Za-z0-9_]+\\):" 1))))))))
bb53e1ee 1679
7aeb9d6f 1680;; Fstab
d8677156 1681(when (memq 'etc-fstab-generic-mode generic-extras-enable-list)
7aeb9d6f 1682
d8677156 1683(define-generic-mode etc-fstab-generic-mode
82e38f3e
LK
1684 '(?#)
1685 '("adfs"
1686 "affs"
1687 "autofs"
1688 "coda"
1689 "coherent"
1690 "cramfs"
1691 "devpts"
1692 "efs"
1693 "ext2"
1694 "ext3"
1695 "hfs"
1696 "hpfs"
1697 "iso9660"
1698 "jfs"
1699 "minix"
1700 "msdos"
1701 "ncpfs"
1702 "nfs"
1703 "ntfs"
1704 "proc"
1705 "qnx4"
1706 "reiserfs"
1707 "romfs"
1708 "smbfs"
3e54ab6c
LH
1709 "cifs"
1710 "usbdevfs"
82e38f3e
LK
1711 "sysv"
1712 "tmpfs"
1713 "udf"
1714 "ufs"
1715 "umsdos"
1716 "vfat"
1717 "xenix"
1718 "xfs"
1719 "swap"
1720 "auto"
1721 "ignore")
3e54ab6c 1722 '(("^\\([^# \t]+\\)\\s-+\\([^# \t]+\\)"
60c19d5e
LK
1723 (1 font-lock-type-face t)
1724 (2 font-lock-variable-name-face t)))
7aeb9d6f
PB
1725 '("/etc/[v]*fstab\\'")
1726 (list
1727 (function
1728 (lambda ()
1729 (setq imenu-generic-expression
3e54ab6c 1730 '((nil "^\\([^# \t]+\\)\\s-+" 1))))))))
bb53e1ee
RS
1731
1732;; From Jacques Duthen <jacques.duthen@sncf.fr>
1fffafda
LK
1733(when (memq 'show-tabs-generic-mode generic-extras-enable-list)
1734
16a013c2
LK
1735(eval-when-compile
1736
1737(defconst show-tabs-generic-mode-font-lock-defaults-1
82e38f3e 1738 '(;; trailing spaces must come before...
f0b3dcbf 1739 ("[ \t]+$" . 'show-tabs-space)
d8677156 1740 ;; ...embedded tabs
f0b3dcbf 1741 ("[^\n\t]\\(\t+\\)" (1 'show-tabs-tab))))
bb53e1ee 1742
16a013c2 1743(defconst show-tabs-generic-mode-font-lock-defaults-2
82e38f3e 1744 '(;; trailing spaces must come before...
f0b3dcbf 1745 ("[ \t]+$" . 'show-tabs-space)
d8677156 1746 ;; ...tabs
f0b3dcbf 1747 ("\t+" . 'show-tabs-tab))))
bb53e1ee 1748
f0b3dcbf 1749(defface show-tabs-tab
16a013c2
LK
1750 '((((class grayscale) (background light)) (:background "DimGray" :weight bold))
1751 (((class grayscale) (background dark)) (:background "LightGray" :weight bold))
ea81d57e
DN
1752 (((class color) (min-colors 88)) (:background "red1"))
1753 (((class color)) (:background "red"))
1fd714a4 1754 (t (:weight bold)))
bb53e1ee 1755 "Font Lock mode face used to highlight TABs."
d4fb185d 1756 :group 'generic-x)
f0b3dcbf
MB
1757;; backward-compatibility alias
1758(put 'show-tabs-tab-face 'face-alias 'show-tabs-tab)
bb53e1ee 1759
f0b3dcbf 1760(defface show-tabs-space
16a013c2
LK
1761 '((((class grayscale) (background light)) (:background "DimGray" :weight bold))
1762 (((class grayscale) (background dark)) (:background "LightGray" :weight bold))
ea81d57e
DN
1763 (((class color) (min-colors 88)) (:background "yellow1"))
1764 (((class color)) (:background "yellow"))
1fd714a4 1765 (t (:weight bold)))
bb53e1ee 1766 "Font Lock mode face used to highlight spaces."
d4fb185d 1767 :group 'generic-x)
f0b3dcbf
MB
1768;; backward-compatibility alias
1769(put 'show-tabs-space-face 'face-alias 'show-tabs-space)
bb53e1ee 1770
d8677156 1771(define-generic-mode show-tabs-generic-mode
82e38f3e
LK
1772 nil ;; no comment char
1773 nil ;; no keywords
16a013c2 1774 (eval-when-compile show-tabs-generic-mode-font-lock-defaults-1)
82e38f3e
LK
1775 nil ;; no auto-mode-alist
1776 ;; '(show-tabs-generic-mode-hook-fun)
bb53e1ee 1777 nil
d4fb185d 1778 "Generic mode to show tabs and trailing spaces"))
bb53e1ee 1779
ffe0c7ef
PB
1780;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1781;; DNS modes
1782;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1783
1fffafda
LK
1784(when (memq 'named-boot-generic-mode generic-extras-enable-list)
1785
d8677156
LK
1786(define-generic-mode named-boot-generic-mode
1787 ;; List of comment characters
82e38f3e 1788 '(?\;)
d8677156 1789 ;; List of keywords
82e38f3e
LK
1790 '("cache" "primary" "secondary" "forwarders" "limit" "options"
1791 "directory" "check-names")
d8677156 1792 ;; List of additional font-lock-expressions
82e38f3e
LK
1793 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face)
1794 ("^directory\\s-+\\(.*\\)" 1 font-lock-variable-name-face)
1795 ("^\\(primary\\|cache\\)\\s-+\\([.A-Za-z]+\\)\\s-+\\(.*\\)"
1796 (2 font-lock-variable-name-face)
1797 (3 font-lock-constant-face)))
d8677156 1798 ;; List of additional automode-alist expressions
82e38f3e 1799 '("/etc/named.boot\\'")
d8677156 1800 ;; List of set up functions to call
d4fb185d 1801 nil))
1fffafda
LK
1802
1803(when (memq 'named-database-generic-mode generic-extras-enable-list)
ffe0c7ef 1804
d8677156
LK
1805(define-generic-mode named-database-generic-mode
1806 ;; List of comment characters
82e38f3e 1807 '(?\;)
d8677156 1808 ;; List of keywords
82e38f3e 1809 '("IN" "NS" "CNAME" "SOA" "PTR" "MX" "A")
d8677156 1810 ;; List of additional font-lock-expressions
82e38f3e
LK
1811 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face)
1812 ("^\\([.A-Za-z0-9]+\\)" 1 font-lock-variable-name-face))
60c19d5e 1813 ;; List of additional auto-mode-alist expressions
ffe0c7ef 1814 nil
d8677156 1815 ;; List of set up functions to call
d4fb185d 1816 nil)
ffe0c7ef
PB
1817
1818(defvar named-database-time-string "%Y%m%d%H"
1819 "Timestring for named serial numbers.")
1820
1821(defun named-database-print-serial ()
1822 "Print a serial number based on the current date."
1823 (interactive)
1fffafda
LK
1824 (insert (format-time-string named-database-time-string (current-time)))))
1825
1826(when (memq 'resolve-conf-generic-mode generic-extras-enable-list)
ffe0c7ef 1827
d8677156
LK
1828(define-generic-mode resolve-conf-generic-mode
1829 ;; List of comment characters
82e38f3e 1830 '(?#)
d8677156 1831 ;; List of keywords
82e38f3e 1832 '("nameserver" "domain" "search" "sortlist" "options")
d8677156 1833 ;; List of additional font-lock-expressions
ffe0c7ef 1834 nil
60c19d5e 1835 ;; List of additional auto-mode-alist expressions
82e38f3e 1836 '("/etc/resolv[e]?.conf\\'")
d8677156 1837 ;; List of set up functions to call
d4fb185d 1838 nil))
ffe0c7ef
PB
1839
1840;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1841;; Modes for spice and common electrical engineering circuit netlist formats
1842;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1843
1fffafda
LK
1844(when (memq 'spice-generic-mode generic-extras-enable-list)
1845
d8677156 1846(define-generic-mode spice-generic-mode
ffe0c7ef 1847 nil
82e38f3e
LK
1848 '("and"
1849 "cccs"
1850 "ccvs"
1851 "delay"
1852 "nand"
1853 "nor"
1854 "npwl"
1855 "or"
1856 "par"
1857 "ppwl"
1858 "pwl"
1859 "vccap"
1860 "vccs"
1861 "vcr"
1862 "vcvs")
1863 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face)
1864 (" \\(\\$ .*\\)$" 1 font-lock-comment-face)
1865 ("^\\(\\$ .*\\)$" 1 font-lock-comment-face)
1866 ("\\([*].*\\)" 1 font-lock-comment-face)
1867 ("^\\([+]\\)" 1 font-lock-string-face)
1868 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face)
1869 ("\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face)
1870 ("\\('[^']+'\\)" 1 font-lock-string-face)
1871 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face))
1872 '("\\.[sS][pP]\\'"
1873 "\\.[sS][pP][iI]\\'"
1874 "\\.[sS][pP][iI][cC][eE]\\'"
1875 "\\.[iI][nN][cC]\\'")
ffe0c7ef
PB
1876 (list
1877 'generic-bracket-support
1878 ;; Make keywords case-insensitive
1879 (function
1880 (lambda()
16a013c2 1881 (setq font-lock-defaults '(generic-font-lock-keywords nil t)))))
d4fb185d 1882 "Generic mode for SPICE circuit netlist files."))
1fffafda
LK
1883
1884(when (memq 'ibis-generic-mode generic-extras-enable-list)
ffe0c7ef 1885
d8677156 1886(define-generic-mode ibis-generic-mode
82e38f3e 1887 '(?|)
ffe0c7ef 1888 nil
82e38f3e
LK
1889 '(("[[]\\([^]]*\\)[]]" 1 font-lock-keyword-face)
1890 ("\\(\\(_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face))
1891 '("\\.[iI][bB][sS]\\'")
1892 '(generic-bracket-support)
d4fb185d 1893 "Generic mode for IBIS circuit netlist files."))
1fffafda
LK
1894
1895(when (memq 'astap-generic-mode generic-extras-enable-list)
ffe0c7ef 1896
d8677156 1897(define-generic-mode astap-generic-mode
ffe0c7ef 1898 nil
82e38f3e
LK
1899 '("analyze"
1900 "description"
1901 "elements"
1902 "execution"
1903 "features"
1904 "functions"
1905 "ground"
1906 "model"
1907 "outputs"
1908 "print"
1909 "run"
1910 "controls"
1911 "table")
1912 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face)
1913 (";\\s-*\\([*].*\\)" 1 font-lock-comment-face)
1914 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face)
1915 ("\\('[^']+'\\)" 1 font-lock-string-face)
1916 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face)
1917 ("[(,]\\s-*\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face))
1918 '("\\.[aA][pP]\\'"
1919 "\\.[aA][sS][xX]\\'"
1920 "\\.[aA][sS][tT][aA][pP]\\'"
1921 "\\.[pP][sS][pP]\\'"
1922 "\\.[dD][eE][cC][kK]\\'"
1923 "\\.[gG][oO][dD][aA][tT][aA]")
ffe0c7ef
PB
1924 (list
1925 'generic-bracket-support
1926 ;; Make keywords case-insensitive
1927 (function
1928 (lambda()
16a013c2 1929 (setq font-lock-defaults '(generic-font-lock-keywords nil t)))))
d4fb185d 1930 "Generic mode for ASTAP circuit netlist files."))
1fffafda
LK
1931
1932(when (memq 'etc-modules-conf-generic-mode generic-extras-enable-list)
ffe0c7ef 1933
d8677156
LK
1934(define-generic-mode etc-modules-conf-generic-mode
1935 ;; List of comment characters
82e38f3e 1936 '(?#)
d8677156 1937 ;; List of keywords
82e38f3e
LK
1938 '("above"
1939 "alias"
1940 "below"
1941 "define"
1942 "depfile"
1943 "else"
1944 "elseif"
1945 "endif"
1946 "if"
1947 "include"
1948 "insmod_opt"
1949 "install"
1950 "keep"
1951 "options"
1952 "path"
1953 "generic_stringfile"
1954 "pcimapfile"
1955 "isapnpmapfile"
1956 "usbmapfile"
1957 "parportmapfile"
1958 "ieee1394mapfile"
1959 "pnpbiosmapfile"
1960 "probe"
1961 "probeall"
1962 "prune"
1963 "post-install"
1964 "post-remove"
1965 "pre-install"
1966 "pre-remove"
1967 "remove"
1968 "persistdir")
d8677156 1969 ;; List of additional font-lock-expressions
9845e669 1970 nil
d8677156 1971 ;; List of additional automode-alist expressions
82e38f3e 1972 '("/etc/modules.conf" "/etc/conf.modules")
d8677156 1973 ;; List of set up functions to call
d4fb185d 1974 nil))
ffe0c7ef 1975
ca1e63a5
RS
1976(provide 'generic-x)
1977
ab5796a9 1978;;; arch-tag: cde692a5-9ff6-4506-9999-c67999c2bdb5
ca1e63a5 1979;;; generic-x.el ends here