(follow-mode): Don't run hooks twice. Use `when'.
[bpt/emacs.git] / lisp / generic-x.el
CommitLineData
1fffafda 1;;; generic-x.el --- A collection of generic modes
ca1e63a5 2
c90f2757 3;; Copyright (C) 1997, 1998, 2001, 2002, 2003, 2004,
d7a0267c 4;; 2005, 2006, 2007 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
b4aa6026 14;; the Free Software Foundation; either version 3, or (at your option)
ca1e63a5
RS
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;;
76ee7bd5 29;; This file contains a collection of 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
76ee7bd5 247only affects 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
76ee7bd5 257affects 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
76ee7bd5 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")
ddb72af9 436 '(("\\(\\[.*\\]\\)" 1 font-lock-constant-face)
82e38f3e 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]\\'"
6453a10e 515 "\\.[cC][mM][dD]\\'"
82e38f3e
LK
516 "\\`[cC][oO][nN][fF][iI][gG]\\."
517 "\\`[aA][uU][tT][oO][eE][xX][eE][cC]\\.")
518 '(generic-bat-mode-setup-function)
6453a10e 519 "Generic mode for MS-Windows batch files.")
d8677156
LK
520
521(defvar bat-generic-mode-syntax-table nil
1fffafda 522 "Syntax table in use in `bat-generic-mode' buffers.")
d8677156
LK
523
524(defvar bat-generic-mode-keymap (make-sparse-keymap)
76ee7bd5 525 "Keymap for `bat-generic-mode'.")
d8677156
LK
526
527(defun bat-generic-mode-compile ()
528 "Run the current BAT file in a compilation buffer."
529 (interactive)
530 (let ((compilation-buffer-name-function
531 (function
532 (lambda(ign)
533 (concat "*" (buffer-file-name) "*")))))
534 (compile
535 (concat (w32-shell-name) " -c " (buffer-file-name)))))
536
a2d66c78 537(eval-when-compile (require 'comint))
d8677156
LK
538(defun bat-generic-mode-run-as-comint ()
539 "Run the current BAT file in a comint buffer."
540 (interactive)
541 (require 'comint)
542 (let* ((file (buffer-file-name))
543 (buf-name (concat "*" file "*")))
544 (save-excursion
545 (set-buffer
546 (get-buffer-create buf-name))
547 (erase-buffer)
548 (comint-mode)
549 (comint-exec
550 buf-name
551 file
552 (w32-shell-name)
553 nil
554 (list "-c" file))
555 (display-buffer buf-name))))
556
557(define-key bat-generic-mode-keymap "\C-c\C-c" 'bat-generic-mode-compile)
558
559;; Make underscores count as words
560(unless bat-generic-mode-syntax-table
561 (setq bat-generic-mode-syntax-table (make-syntax-table))
16a013c2 562 (modify-syntax-entry ?_ "w" bat-generic-mode-syntax-table))
d8677156 563
16a013c2
LK
564;; bat-generic-mode doesn't use the comment functionality of
565;; define-generic-mode because it has a three-letter comment-string,
566;; so we do it here manually instead
d8677156 567(defun generic-bat-mode-setup-function ()
82e38f3e
LK
568 (make-local-variable 'parse-sexp-ignore-comments)
569 (make-local-variable 'comment-start)
570 (make-local-variable 'comment-start-skip)
571 (make-local-variable 'comment-end)
572 (setq imenu-generic-expression '((nil "^:\\(\\sw+\\)" 1))
d8677156 573 parse-sexp-ignore-comments t
82e38f3e
LK
574 comment-end ""
575 comment-start "REM "
576 comment-start-skip "[Rr][Ee][Mm] *")
577 (set-syntax-table bat-generic-mode-syntax-table)
d8677156 578 ;; Make keywords case-insensitive
16a013c2 579 (setq font-lock-defaults '(generic-font-lock-keywords nil t))
d8677156 580 (use-local-map bat-generic-mode-keymap)))
ca1e63a5
RS
581
582;;; Mailagent
82e38f3e
LK
583;; Mailagent is a Unix mail filtering program. Anyone wanna do a
584;; generic mode for procmail?
d8677156
LK
585(when (memq 'mailagent-rules-generic-mode generic-extras-enable-list)
586
587(define-generic-mode mailagent-rules-generic-mode
82e38f3e
LK
588 '(?#)
589 '("SAVE" "DELETE" "PIPE" "ANNOTATE" "REJECT")
590 '(("^\\(\\sw+\\)\\s-*=" 1 font-lock-variable-name-face)
591 ("\\s-/\\([^/]+\\)/[i, \t\n]" 1 font-lock-constant-face))
592 '("\\.rules\\'")
16a013c2
LK
593 (list
594 (function
595 (lambda ()
596 (setq imenu-generic-expression
597 '((nil "\\s-/\\([^/]+\\)/[i, \t\n]" 1))))))
d4fb185d 598 "Mode for Mailagent rules files."))
ca1e63a5
RS
599
600;; Solaris/Sys V prototype files
d8677156
LK
601(when (memq 'prototype-generic-mode generic-extras-enable-list)
602
603(define-generic-mode prototype-generic-mode
82e38f3e 604 '(?#)
d8677156
LK
605 nil
606 '(("^\\([0-9]\\)?\\s-*\\([a-z]\\)\\s-+\\([A-Za-z_]+\\)\\s-+\\([^\n\r]*\\)$"
607 (2 font-lock-constant-face)
608 (3 font-lock-keyword-face))
609 ("^\\([a-z]\\) \\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
610 (1 font-lock-constant-face)
611 (2 font-lock-keyword-face)
612 (3 font-lock-variable-name-face))
613 ("^\\(!\\s-*\\(search\\|include\\|default\\)\\)\\s-*\\([^\n\r]*\\)$"
614 (1 font-lock-keyword-face)
615 (3 font-lock-variable-name-face))
616 ("^\\(!\\s-*\\sw+\\)=\\([^\n\r]*\\)$"
617 (1 font-lock-keyword-face)
618 (2 font-lock-variable-name-face)))
82e38f3e 619 '("prototype\\'")
d8677156 620 nil
d4fb185d 621 "Mode for Sys V prototype files."))
ca1e63a5
RS
622
623;; Solaris/Sys V pkginfo files
d8677156
LK
624(when (memq 'pkginfo-generic-mode generic-extras-enable-list)
625
626(define-generic-mode pkginfo-generic-mode
82e38f3e 627 '(?#)
d8677156
LK
628 nil
629 '(("^\\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
630 (1 font-lock-keyword-face)
631 (2 font-lock-variable-name-face)))
82e38f3e 632 '("pkginfo\\'")
d8677156 633 nil
d4fb185d 634 "Mode for Sys V pkginfo files."))
ca1e63a5
RS
635
636;; Javascript mode
ffe0c7ef 637;; Includes extra keywords from Armando Singer [asinger@MAIL.COLGATE.EDU]
1fffafda
LK
638(when (memq 'javascript-generic-mode generic-extras-enable-list)
639
d8677156 640(define-generic-mode javascript-generic-mode
82e38f3e
LK
641 '("//" ("/*" . "*/"))
642 '("break"
643 "case"
644 "continue"
645 "default"
646 "delete"
647 "do"
648 "else"
649 "export"
650 "for"
651 "function"
652 "if"
653 "import"
654 "in"
655 "new"
656 "return"
657 "switch"
658 "this"
659 "typeof"
660 "var"
661 "void"
662 "while"
663 "with"
664 ;; words reserved for ECMA extensions below
665 "catch"
666 "class"
667 "const"
668 "debugger"
669 "enum"
670 "extends"
671 "finally"
672 "super"
673 "throw"
674 "try"
675 ;; Java Keywords reserved by JavaScript
676 "abstract"
677 "boolean"
678 "byte"
679 "char"
680 "double"
681 "false"
682 "final"
683 "float"
684 "goto"
685 "implements"
686 "instanceof"
687 "int"
688 "interface"
689 "long"
690 "native"
691 "null"
692 "package"
693 "private"
694 "protected"
695 "public"
696 "short"
697 "static"
698 "synchronized"
699 "throws"
700 "transient"
701 "true")
702 '(("^\\s-*function\\s-+\\([A-Za-z0-9_]+\\)"
703 (1 font-lock-function-name-face))
704 ("^\\s-*var\\s-+\\([A-Za-z0-9_]+\\)"
705 (1 font-lock-variable-name-face)))
706 '("\\.js\\'")
ca1e63a5 707 (list
ffe0c7ef 708 (function
ca1e63a5 709 (lambda ()
ffe0c7ef
PB
710 (setq imenu-generic-expression
711 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1)
d8677156 712 ("*Variables*" "^var\\s-+\\([A-Za-z0-9_]+\\)" 1))))))
d4fb185d 713 "Mode for JavaScript files."))
ca1e63a5
RS
714
715;; VRML files
1fffafda
LK
716(when (memq 'vrml-generic-mode generic-extras-enable-list)
717
d8677156 718(define-generic-mode vrml-generic-mode
82e38f3e
LK
719 '(?#)
720 '("DEF"
721 "NULL"
722 "USE"
723 "Viewpoint"
724 "ambientIntensity"
725 "appearance"
726 "children"
727 "color"
728 "coord"
729 "coordIndex"
730 "creaseAngle"
731 "diffuseColor"
732 "emissiveColor"
733 "fieldOfView"
734 "geometry"
735 "info"
736 "material"
737 "normal"
738 "orientation"
739 "position"
740 "shininess"
741 "specularColor"
742 "texCoord"
743 "texture"
744 "textureTransform"
745 "title"
746 "transparency"
747 "type")
748 '(("USE\\s-+\\([-A-Za-z0-9_]+\\)"
749 (1 font-lock-constant-face))
750 ("DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
751 (1 font-lock-type-face)
752 (2 font-lock-constant-face))
753 ("^\\s-*\\([-A-Za-z0-9_]+\\)\\s-*{"
754 (1 font-lock-function-name-face))
755 ("^\\s-*\\(geometry\\|appearance\\|material\\)\\s-+\\([-A-Za-z0-9_]+\\)"
756 (2 font-lock-variable-name-face)))
757 '("\\.wrl\\'")
ca1e63a5 758 (list
ffe0c7ef 759 (function
ca1e63a5 760 (lambda ()
ffe0c7ef 761 (setq imenu-generic-expression
ca1e63a5 762 '((nil "^\\([A-Za-z0-9_]+\\)\\s-*{" 1)
ffe0c7ef 763 ("*Definitions*"
ca1e63a5 764 "DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
d8677156 765 1))))))
d4fb185d 766 "Generic Mode for VRML files."))
ca1e63a5
RS
767
768;; Java Manifests
1fffafda
LK
769(when (memq 'java-manifest-generic-mode generic-extras-enable-list)
770
d8677156 771(define-generic-mode java-manifest-generic-mode
82e38f3e
LK
772 '(?#)
773 '("Name"
774 "Digest-Algorithms"
775 "Manifest-Version"
776 "Required-Version"
777 "Signature-Version"
778 "Magic"
779 "Java-Bean"
780 "Depends-On")
ca1e63a5
RS
781 '(("^Name:\\s-+\\([^\n\r]*\\)$"
782 (1 font-lock-variable-name-face))
783 ("^\\(Manifest\\|Required\\|Signature\\)-Version:\\s-+\\([^\n\r]*\\)$"
d8677156 784 (2 font-lock-constant-face)))
82e38f3e 785 '("[mM][aA][nN][iI][fF][eE][sS][tT]\\.[mM][fF]\\'")
ca1e63a5 786 nil
76ee7bd5 787 "Mode for Java Manifest files."))
ca1e63a5
RS
788
789;; Java properties files
1fffafda
LK
790(when (memq 'java-properties-generic-mode generic-extras-enable-list)
791
d8677156 792(define-generic-mode java-properties-generic-mode
82e38f3e 793 '(?! ?#)
ca1e63a5 794 nil
82e38f3e
LK
795 (eval-when-compile
796 (let ((java-properties-key
797 "\\(\\([-A-Za-z0-9_\\./]\\|\\(\\\\[ =:]\\)\\)+\\)")
798 (java-properties-value
799 "\\([^\r\n]*\\)"))
800 ;; Property and value can be separated in a number of different ways:
801 ;; * whitespace
802 ;; * an equal sign
803 ;; * a colon
804 (mapcar
805 (function
806 (lambda (elt)
807 (list
808 (concat "^" java-properties-key elt java-properties-value "$")
809 '(1 font-lock-constant-face)
810 '(4 font-lock-variable-name-face))))
811 ;; These are the separators
812 '(":\\s-*" "\\s-+" "\\s-*=\\s-*"))))
ca1e63a5 813 nil
bb53e1ee
RS
814 (list
815 (function
816 (lambda ()
ffe0c7ef 817 (setq imenu-generic-expression
d8677156 818 '((nil "^\\([^#! \t\n\r=:]+\\)" 1))))))
d4fb185d 819 "Mode for Java properties files."))
ca1e63a5
RS
820
821;; C shell alias definitions
d8677156 822(when (memq 'alias-generic-mode generic-extras-enable-list)
ef1c5063 823
d8677156 824(define-generic-mode alias-generic-mode
82e38f3e
LK
825 '(?#)
826 '("alias" "unalias")
ca1e63a5
RS
827 '(("^alias\\s-+\\([-A-Za-z0-9_]+\\)\\s-+"
828 (1 font-lock-variable-name-face))
829 ("^unalias\\s-+\\([-A-Za-z0-9_]+\\)\\s-*$"
d8677156 830 (1 font-lock-variable-name-face)))
82e38f3e 831 '("alias\\'")
ca1e63a5
RS
832 (list
833 (function
834 (lambda ()
ffe0c7ef 835 (setq imenu-generic-expression
d8677156 836 '((nil "^\\(alias\\|unalias\\)\\s-+\\([-a-zA-Z0-9_]+\\)" 2))))))
d4fb185d 837 "Mode for C Shell alias files."))
ca1e63a5
RS
838
839;;; Windows RC files
840;; Contributed by ACorreir@pervasive-sw.com (Alfred Correira)
d8677156
LK
841(when (memq 'rc-generic-mode generic-extras-enable-list)
842
843(define-generic-mode rc-generic-mode
82e38f3e
LK
844 ;; '(?\/)
845 '("//")
d8677156
LK
846 '("ACCELERATORS"
847 "AUTO3STATE"
848 "AUTOCHECKBOX"
849 "AUTORADIOBUTTON"
850 "BITMAP"
851 "BOTTOMMARGIN"
852 "BUTTON"
853 "CAPTION"
854 "CHARACTERISTICS"
855 "CHECKBOX"
856 "CLASS"
857 "COMBOBOX"
858 "CONTROL"
859 "CTEXT"
860 "CURSOR"
861 "DEFPUSHBUTTON"
862 "DESIGNINFO"
863 "DIALOG"
864 "DISCARDABLE"
865 "EDITTEXT"
866 "EXSTYLE"
867 "FONT"
868 "GROUPBOX"
869 "GUIDELINES"
870 "ICON"
871 "LANGUAGE"
872 "LEFTMARGIN"
873 "LISTBOX"
874 "LTEXT"
875 "MENUITEM SEPARATOR"
876 "MENUITEM"
877 "MENU"
878 "MOVEABLE"
879 "POPUP"
880 "PRELOAD"
881 "PURE"
882 "PUSHBOX"
883 "PUSHBUTTON"
884 "RADIOBUTTON"
885 "RCDATA"
886 "RIGHTMARGIN"
887 "RTEXT"
888 "SCROLLBAR"
889 "SEPARATOR"
890 "STATE3"
891 "STRINGTABLE"
892 "STYLE"
893 "TEXTINCLUDE"
894 "TOOLBAR"
895 "TOPMARGIN"
896 "VERSIONINFO"
897 "VERSION")
898 ;; the choice of what tokens go where is somewhat arbitrary,
899 ;; as is the choice of which value tokens are included, as
900 ;; the choice of face for each token group
82e38f3e
LK
901 (eval-when-compile
902 (list
d8677156 903 (generic-make-keywords-list
82e38f3e
LK
904 '("FILEFLAGSMASK"
905 "FILEFLAGS"
906 "FILEOS"
907 "FILESUBTYPE"
908 "FILETYPE"
909 "FILEVERSION"
910 "PRODUCTVERSION")
16a013c2 911 font-lock-type-face)
d8677156 912 (generic-make-keywords-list
82e38f3e
LK
913 '("BEGIN"
914 "BLOCK"
915 "END"
916 "VALUE")
16a013c2 917 font-lock-function-name-face)
82e38f3e
LK
918 '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face)
919 '("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face)
920 '("^#[ \t]*\\(elif\\|if\\)\\>"
921 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil
922 (1 font-lock-constant-face)
923 (2 font-lock-variable-name-face nil t)))
924 '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
925 (1 font-lock-constant-face)
926 (2 font-lock-variable-name-face nil t))))
60c19d5e 927 '("\\.[rR][cC]\\'")
82e38f3e 928 nil
d4fb185d 929 "Generic mode for MS-Windows Resource files."))
ca1e63a5 930
ef1c5063 931;; InstallShield RUL files
ca1e63a5 932;; Contributed by Alfred.Correira@Pervasive.Com
9845e669 933;; Bugfixes by "Rolf Sandau" <Rolf.Sandau@marconi.com>
d8677156
LK
934(when (memq 'rul-generic-mode generic-extras-enable-list)
935
82e38f3e
LK
936(eval-when-compile
937
ef1c5063 938;;; build the regexp strings using regexp-opt
82e38f3e
LK
939(defconst installshield-statement-keyword-list
940 '("abort"
941 "begin"
942 "call"
943 "case"
944 "declare"
945 "default"
946 "downto"
947 "elseif"
948 "else"
949 "endfor"
950 "endif"
951 "endswitch"
952 "endwhile"
953 "end"
954 "exit"
955 "external"
956 "for"
957 "function"
958 ;; "goto" -- handled elsewhere
959 "if"
960 "program"
961 "prototype"
962 "repeat"
963 "return"
964 "step"
965 "switch"
966 "then"
967 "to"
968 "typedef"
969 "until"
970 "void"
971 "while")
ef1c5063
RS
972 "Statement keywords used in InstallShield 3 and 5.")
973
82e38f3e
LK
974(defconst installshield-system-functions-list
975 '("AddFolderIcon"
976 "AddProfString"
977 "AddressString"
978 "AppCommand"
979 "AskDestPath"
980 "AskOptions"
981 "AskPath"
982 "AskText"
983 "AskYesNo"
984 "BatchDeleteEx"
985 "BatchFileLoad"
986 "BatchFileSave"
987 "BatchFind"
988 "BatchGetFileName"
989 "BatchMoveEx"
990 "BatchSetFileName"
991 "ChangeDirectory"
992 "CloseFile"
993 "CmdGetHwndDlg"
994 "ComponentAddItem" ; differs between IS3 and IS5
995 "ComponentCompareSizeRequired" ; IS5 only
996 "ComponentDialog"
997 "ComponentError" ; IS5 only
998 "ComponentFileEnum" ; IS5 only
999 "ComponentFileInfo" ; IS5 only
1000 "ComponentFilterLanguage" ; IS5 only
1001 "ComponentFilterOS" ; IS5 only
1002 "ComponentGetData" ; IS5 only
1003 "ComponentGetItemInfo" ; IS3 only
1004 "ComponentGetItemSize" ; differs between IS3 and IS5
1005 "ComponentIsItemSelected" ; differs between IS3 and IS5
1006 "ComponentListItems"
1007 "ComponentMoveData" ; IS5 only
1008 "ComponentSelectItem" ; differs between IS3 and IS5
1009 "ComponentSetData" ; IS5 only
1010 "ComponentSetItemInfo" ; IS3 only
1011 "ComponentSetTarget" ; IS5 only
1012 "ComponentSetupTypeEnum" ; IS5 only
1013 "ComponentSetupTypeGetData" ; IS5 only
1014 "ComponentSetupTypeSet" ; IS5 only
1015 "ComponentTotalSize"
1016 "ComponentValidate" ; IS5 only
1017 "CompressAdd" ; IS3 only
1018 "CompressDel" ; IS3 only
1019 "CompressEnum" ; IS3 only
1020 "CompressGet" ; IS3 only
1021 "CompressInfo" ; IS3 only
1022 "CopyFile"
1023 "CreateDir"
1024 "CreateFile"
1025 "CreateProgramFolder"
1026 "DeinstallSetReference" ; IS5 only
1027 "DeinstallStart"
1028 "Delay"
1029 "DeleteDir"
1030 "DeleteFile"
1031 "DialogSetInfo"
1032 "Disable"
1033 "DoInstall"
1034 "Do"
1035 "Enable"
1036 "EnterDisk"
1037 "ExistsDir"
1038 "ExistsDisk"
1039 "ExitProgMan"
1040 "EzBatchAddPath"
1041 "EzBatchAddString"
1042 "EzBatchReplace"
1043 "EzConfigAddDriver"
1044 "EzConfigAddString"
1045 "EzConfigGetValue"
1046 "EzConfigSetValue"
1047 "EzDefineDialog"
1048 "FileCompare"
1049 "FileDeleteLine"
1050 "FileGrep"
1051 "FileInsertLine"
1052 "FileSetBeginDefine" ; IS3 only
1053 "FileSetEndDefine" ; IS3 only
1054 "FileSetPerformEz" ; IS3 only
1055 "FileSetPerform" ; IS3 only
1056 "FileSetReset" ; IS3 only
1057 "FileSetRoot" ; IS3 only
1058 "FindAllDirs"
1059 "FindAllFiles"
1060 "FindFile"
1061 "FindWindow"
1062 "GetDiskSpace"
1063 "GetDisk"
1064 "GetEnvVar"
1065 "GetExtents"
1066 "GetFileInfo"
1067 "GetLine"
1068 "GetProfInt"
1069 "GetProfString"
1070 "GetSystemInfo"
1071 "GetValidDrivesList"
1072 "GetVersion"
1073 "GetWindowHandle"
1074 "InstallationInfo"
1075 "Is"
1076 "LaunchApp"
1077 "LaunchAppAndWait"
1078 "ListAddItem"
1079 "ListAddString"
1080 "ListCount"
1081 "ListCreate"
1082 "ListDestroy"
1083 "ListFindItem"
1084 "ListFindString"
1085 "ListGetFirstItem"
1086 "ListGetFirstString"
1087 "ListGetNextItem"
1088 "ListGetNextString"
1089 "ListReadFromFile"
1090 "ListSetCurrentItem"
1091 "ListSetNextItem"
1092 "ListSetNextString"
1093 "ListSetIndex"
1094 "ListWriteToFile"
1095 "LongPathToQuote"
1096 "LongPathToShortPath"
1097 "MessageBox"
1098 "NumToStr"
1099 "OpenFileMode"
1100 "OpenFile"
1101 "ParsePath"
1102 "PathAdd"
1103 "PathDelete"
1104 "PathFind"
1105 "PathGet"
1106 "PathMove"
1107 "PathSet"
1108 "Path"
1109 "PlaceBitmap"
1110 "PlaceWindow"
1111 "PlayMMedia" ; IS5 only
1112 "ProgDefGroupType"
1113 "RegDBCreateKeyEx"
1114 "RegDBDeleteValue"
1115 "RegDBGetItem"
1116 "RegDBKeyExist"
1117 "RegDBSetItem"
1118 "RegDBGetKeyValueEx"
1119 "RegDBSetKeyValueEx"
1120 "RegDBSetDefaultRoot"
1121 "RenameFile"
1122 "ReplaceFolderIcon"
1123 "ReplaceProfString"
1124 "SdAskDestPath"
1125 "SdAskOptions"
1126 "SdAskOptionsList"
1127 "SdBitmap"
1128 "SdCloseDlg"
1129 "SdComponentAdvCheckSpace"
1130 "SdComponentAdvInit"
1131 "SdComponentAdvUpdateSpace"
1132 "SdComponentDialog"
1133 "SdComponentDialog2"
1134 "SdComponentDialogAdv"
1135 "SdComponentDialogEx"
1136 "SdComponentDlgCheckSpace"
1137 "SdComponentMult"
1138 "SdConfirmNewDir"
1139 "SdConfirmRegistration"
1140 "SdDiskSpace"
1141 "SdDisplayTopics"
1142 "SdDoStdButton"
1143 "SdEnablement"
1144 "SdError"
1145 "SdFinish"
1146 "SdFinishInit32"
1147 "SdFinishReboot"
1148 "SdGeneralInit"
1149 "SdGetItemName"
1150 "SdGetTextExtent"
1151 "SdGetUserCompanyInfo"
1152 "SdInit"
1153 "SdIsShellExplorer"
1154 "SdIsStdButton"
1155 "SdLicense"
1156 "SdMakeName"
1157 "SdOptionInit"
1158 "SdOptionSetState"
1159 "SdOptionsButtons"
1160 "SdOptionsButtonsInit"
1161 "SdPlugInProductName"
1162 "SdProductName"
1163 "SdRegEnableButton"
1164 "SdRegExEnableButton"
1165 "SdRegisterUser"
1166 "SdRegisterUserEx"
1167 "SdRemoveEndSpace"
1168 "SdSelectFolder"
1169 "SdSetSequentialItems"
1170 "SdSetStatic"
1171 "SdSetupTypeEx" ; IS5 only
1172 "SdSetupType"
1173 "SdShowAnyDialog"
1174 "SdShowDlgEdit1"
1175 "SdShowDlgEdit2"
1176 "SdShowDlgEdit3"
1177 "SdShowFileMods"
1178 "SdShowInfoList"
1179 "SdShowMsg"
1180 "SdStartCopy"
1181 "SdUnInit"
1182 "SdUpdateComponentSelection"
1183 "SdWelcome"
1184 "SendMessage"
1185 "SetColor"
1186 "SetFont"
1187 "SetDialogTitle"
1188 "SetDisplayEffect" ; IS5 only
1189 "SetFileInfo"
1190 "SetForegroundWindow"
1191 "SetStatusWindow"
1192 "SetTitle"
1193 "SetupType"
1194 "ShowProgramFolder"
1195 "Split" ; IS3 only
1196 "SprintfBox"
1197 "Sprintf"
1198 "StatusUpdate"
1199 "StrCompare"
1200 "StrFind"
1201 "StrGetTokens"
1202 "StrLength"
1203 "StrRemoveLastSlash"
1204 "StrToLower"
1205 "StrToNum"
1206 "StrToUpper"
1207 "StrSub"
1208 "VarRestore"
1209 "VarSave"
1210 "VerCompare"
1211 "VerGetFileVersion"
1212 "WaitOnDialog"
1213 "Welcome"
1214 "WriteLine"
1215 "WriteProfString"
1216 "XCopyFile")
ef1c5063
RS
1217 "System functions defined in InstallShield 3 and 5.")
1218
82e38f3e
LK
1219(defconst installshield-system-variables-list
1220 '("BATCH_INSTALL"
1221 "CMDLINE"
1222 "COMMONFILES"
1223 "CORECOMPONENTHANDLING"
1224 "DIALOGCACHE"
1225 "ERRORFILENAME"
1226 "FOLDER_DESKTOP"
1227 "FOLDER_PROGRAMS"
1228 "FOLDER_STARTMENU"
1229 "FOLDER_STARTUP"
1230 "INFOFILENAME"
1231 "ISRES"
1232 "ISUSER"
1233 "ISVERSION"
1234 "MEDIA"
1235 "MODE"
1236 "PROGRAMFILES"
1237 "SELECTED_LANGUAGE"
1238 "SRCDIR"
1239 "SRCDISK"
1240 "SUPPORTDIR"
1241 "TARGETDIR"
1242 "TARGETDISK"
1243 "UNINST"
1244 "WINDIR"
1245 "WINDISK"
1246 "WINMAJOR"
1247 "WINSYSDIR"
1248 "WINSYSDISK")
ef1c5063
RS
1249 "System variables used in InstallShield 3 and 5.")
1250
82e38f3e
LK
1251(defconst installshield-types-list
1252 '("BOOL"
1253 "BYREF"
1254 "CHAR"
1255 "HIWORD"
1256 "HWND"
1257 "INT"
1258 "LIST"
1259 "LONG"
1260 "LOWORD"
1261 "LPSTR"
1262 "NUMBER"
1263 "NUMBERLIST"
1264 "POINTER"
1265 "QUAD"
1266 "RGB"
1267 "SHORT"
1268 "STRINGLIST"
1269 "STRING")
ef1c5063
RS
1270 "Type keywords used in InstallShield 3 and 5.")
1271
1272;;; some might want to skip highlighting these to improve performance
82e38f3e
LK
1273(defconst installshield-funarg-constants-list
1274 '("AFTER"
1275 "APPEND"
1276 "ALLCONTENTS"
1277 "BACKBUTTON"
1278 "BACKGROUNDCAPTION"
1279 "BACKGROUND"
1280 "BACK"
1281 "BASEMEMORY"
1282 "BEFORE"
1283 "BIOS"
1284 "BITMAPICON"
1285 "BK_BLUE"
1286 "BK_GREEN"
1287 "BK_RED"
1288 "BLUE"
1289 "BOOTUPDRIVE"
1290 "CANCEL"
1291 "CDROM_DRIVE"
1292 "CDROM"
1293 "CHECKBOX95"
1294 "CHECKBOX"
1295 "CHECKLINE"
1296 "CHECKMARK"
1297 "COLORS"
1298 "COMMANDEX"
1299 "COMMAND"
1300 "COMP_NORMAL"
1301 "COMP_UPDATE_DATE"
1302 "COMP_UPDATE_SAME"
1303 "COMP_UPDATE_VERSION"
1304 "COMPACT"
1305 "CONTINUE"
1306 "CPU"
1307 "CUSTOM"
1308 "DATE"
1309 "DEFWINDOWMODE"
1310 "DIR_WRITEABLE"
1311 "DIRECTORY"
1312 "DISABLE"
1313 "DISK_TOTALSPACE"
1314 "DISK"
1315 "DLG_OPTIONS"
1316 "DLG_PATH"
1317 "DLG_TEXT"
1318 "DLG_ASK_YESNO"
1319 "DLG_ENTER_DISK"
1320 "DLG_ERR"
1321 "DLG_INFO_ALTIMAGE"
1322 "DLG_INFO_CHECKSELECTION"
1323 "DLG_INFO_KUNITS"
1324 "DLG_INFO_USEDECIMAL"
1325 "DLG_MSG_INFORMATION"
1326 "DLG_MSG_SEVERE"
1327 "DLG_MSG_WARNING"
1328 "DLG_STATUS"
1329 "DLG_WARNING"
1330 "DLG_USER_CAPTION"
1331 "DRIVE"
1332 "ENABLE"
1333 "END_OF_FILE"
1334 "END_OF_LIST"
1335 "ENVSPACE"
1336 "EQUALS"
1337 "EXCLUDE_SUBDIR"
1338 "EXCLUSIVE"
1339 "EXISTS"
1340 "EXIT"
1341 "EXTENDED_MEMORY"
1342 "EXTENSION_ONLY"
1343 "FAILIFEXISTS"
1344 "FALSE"
1345 "FEEDBACK_FULL"
1346 "FILE_ATTR_ARCHIVED"
1347 "FILE_ATTR_DIRECTORY"
1348 "FILE_ATTR_HIDDEN"
1349 "FILE_ATTR_NORMAL"
1350 "FILE_ATTR_READONLY"
1351 "FILE_ATTR_SYSTEM"
1352 "FILE_ATTRIBUTE"
1353 "FILE_DATE"
1354 "FILE_LINE_LENGTH"
1355 "FILE_MODE_APPEND"
1356 "FILE_MODE_BINARYREADONLY"
1357 "FILE_MODE_BINARY"
1358 "FILE_MODE_NORMAL"
1359 "FILE_NO_VERSION"
1360 "FILE_NOT_FOUND"
1361 "FILE_SIZE"
1362 "FILE_TIME"
1363 "FILENAME_ONLY"
1364 "FILENAME"
1365 "FIXED_DRIVE"
1366 "FOLDER_DESKTOP"
1367 "FOLDER_PROGRAMS"
1368 "FOLDER_STARTMENU"
1369 "FOLDER_STARTUP"
1370 "FREEENVSPACE"
1371 "FULLWINDOWMODE"
1372 "FULL"
1373 "FONT_TITLE"
1374 "GREATER_THAN"
1375 "GREEN"
1376 "HKEY_CLASSES_ROOT"
1377 "HKEY_CURRENT_USER"
1378 "HKEY_LOCAL_MACHINE"
1379 "HKEY_USERS"
1380 "HOURGLASS"
1381 "INCLUDE_SUBDIR"
1382 "INDVFILESTATUS"
1383 "INFORMATION"
1384 "IS_WINDOWSNT"
1385 "IS_WINDOWS95"
1386 "IS_WINDOWS"
1387 "IS_WIN32S"
1388 "ISTYPE"
1389 "LANGUAGE_DRV"
1390 "LANGUAGE"
1391 "LESS_THAN"
1392 "LIST_NULL"
1393 "LISTFIRST"
1394 "LISTNEXT"
1395 "LOCKEDFILE"
1396 "LOGGING"
1397 "LOWER_LEFT"
1398 "LOWER_RIGHT"
1399 "MAGENTA"
1400 "MOUSE_DRV"
1401 "MOUSE"
1402 "NETWORK_DRV"
1403 "NETWORK"
1404 "NEXT"
1405 "NONEXCLUSIVE"
1406 "NORMALMODE"
1407 "NOSET"
1408 "NOTEXISTS"
1409 "NOWAIT"
1410 "NO"
1411 "OFF"
1412 "ONLYDIR"
1413 "ON"
1414 "OSMAJOR"
1415 "OSMINOR"
1416 "OS"
1417 "OTHER_FAILURE"
1418 "PARALLEL"
1419 "PARTIAL"
1420 "PATH_EXISTS"
1421 "PATH"
1422 "RED"
1423 "REGDB_APPPATH_DEFAULT"
1424 "REGDB_APPPATH"
1425 "REGDB_BINARY"
1426 "REGDB_ERR_CONNECTIONEXISTS"
1427 "REGDB_ERR_CORRUPTEDREGSITRY"
1428 "REGDB_ERR_INITIALIZATION"
1429 "REGDB_ERR_INVALIDHANDLE"
1430 "REGDB_ERR_INVALIDNAME"
1431 "REGDB_NUMBER"
1432 "REGDB_STRING_EXPAND"
1433 "REGDB_STRING_MULTI"
1434 "REGDB_STRING"
1435 "REGDB_UNINSTALL_NAME"
1436 "REMOTE_DRIVE"
1437 "REMOVALE_DRIVE"
1438 "REPLACE_ITEM"
1439 "REPLACE"
1440 "RESET"
1441 "RESTART"
1442 "ROOT"
1443 "SELFREGISTER"
1444 "SERIAL"
1445 "SET"
1446 "SEVERE"
1447 "SHAREDFILE"
1448 "SHARE"
1449 "SILENTMODE"
1450 "SRCTARGETDIR"
1451 "STATUSBAR"
1452 "STATUSDLG"
1453 "STATUSOLD"
1454 "STATUS"
1455 "STYLE_NORMAL"
1456 "SW_MAXIMIZE"
1457 "SW_MINIMIZE"
1458 "SW_RESTORE"
1459 "SW_SHOW"
1460 "SYS_BOOTMACHINE"
1461 "TIME"
1462 "TRUE"
1463 "TYPICAL"
1464 "UPPER_LEFT"
1465 "UPPER_RIGHT"
1466 "VALID_PATH"
1467 "VERSION"
1468 "VIDEO"
1469 "VOLUMELABEL"
1470 "YELLOW"
1471 "YES"
1472 "WAIT"
1473 "WARNING"
1474 "WINMAJOR"
1475 "WINMINOR"
1476 "WIN32SINSTALLED"
1477 "WIN32SMAJOR"
1478 "WIN32SMINOR")
1479 "Function argument constants used in InstallShield 3 and 5."))
ca1e63a5 1480
d8677156 1481(defvar rul-generic-mode-syntax-table nil
1fffafda 1482 "Syntax table to use in `rul-generic-mode' buffers.")
d8677156
LK
1483
1484(setq rul-generic-mode-syntax-table
1485 (make-syntax-table c++-mode-syntax-table))
1486
82e38f3e
LK
1487(modify-syntax-entry ?\r "> b" rul-generic-mode-syntax-table)
1488(modify-syntax-entry ?\n "> b" rul-generic-mode-syntax-table)
d8677156
LK
1489
1490(modify-syntax-entry ?/ ". 124b" rul-generic-mode-syntax-table)
1491(modify-syntax-entry ?* ". 23" rul-generic-mode-syntax-table)
1492
1493;; here manually instead
1494(defun generic-rul-mode-setup-function ()
82e38f3e
LK
1495 (make-local-variable 'parse-sexp-ignore-comments)
1496 (make-local-variable 'comment-start)
1497 (make-local-variable 'comment-start-skip)
1498 (make-local-variable 'comment-end)
d8677156
LK
1499 (setq imenu-generic-expression
1500 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1))
1501 parse-sexp-ignore-comments t
1502 comment-end "*/"
1503 comment-start "/*"
1504;;; comment-end ""
1505;;; comment-start "//"
1506;;; comment-start-skip ""
1507 )
82e38f3e 1508 ;; (set-syntax-table rul-generic-mode-syntax-table)
d8677156
LK
1509 (setq font-lock-syntax-table rul-generic-mode-syntax-table))
1510
1511;; moved mode-definition behind defun-definition to be warning-free - 15.11.02/RSan
1512(define-generic-mode rul-generic-mode
1513 ;; Using "/*" and "*/" doesn't seem to be working right
82e38f3e
LK
1514 '("//" ("/*" . "*/" ))
1515 (eval-when-compile installshield-statement-keyword-list)
1516 (eval-when-compile
1517 (list
1518 ;; preprocessor constructs
1519 '("#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)"
1520 1 font-lock-string-face)
1521 '("#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
1522 (1 font-lock-reference-face)
1523 (2 font-lock-variable-name-face nil t))
1524 ;; indirect string constants
1525 '("\\(@[A-Za-z][A-Za-z0-9_]+\\)" 1 font-lock-builtin-face)
1526 ;; gotos
1527 '("[ \t]*\\(\\sw+:\\)" 1 font-lock-reference-face)
1528 '("\\<\\(goto\\)\\>[ \t]*\\(\\sw+\\)?"
1529 (1 font-lock-keyword-face)
1530 (2 font-lock-reference-face nil t))
1531 ;; system variables
1532 (generic-make-keywords-list
1533 installshield-system-variables-list
16a013c2 1534 font-lock-variable-name-face "[^_]" "[^_]")
82e38f3e
LK
1535 ;; system functions
1536 (generic-make-keywords-list
1537 installshield-system-functions-list
16a013c2 1538 font-lock-function-name-face "[^_]" "[^_]")
82e38f3e
LK
1539 ;; type keywords
1540 (generic-make-keywords-list
1541 installshield-types-list
16a013c2 1542 font-lock-type-face "[^_]" "[^_]")
82e38f3e
LK
1543 ;; function argument constants
1544 (generic-make-keywords-list
1545 installshield-funarg-constants-list
16a013c2 1546 font-lock-variable-name-face "[^_]" "[^_]"))) ; is this face the best choice?
60c19d5e 1547 '("\\.[rR][uU][lL]\\'")
82e38f3e 1548 '(generic-rul-mode-setup-function)
d4fb185d 1549 "Generic mode for InstallShield RUL files.")
d8677156 1550
ca1e63a5 1551(define-skeleton rul-if
d8677156
LK
1552 "Insert an if statement."
1553 "condition: "
1554 "if(" str ") then" \n
1555 > _ \n
1556 ( "other condition, %s: "
1557 > "elseif(" str ") then" \n
1558 > \n)
1559 > "else" \n
1560 > \n
1561 resume:
1562 > "endif;")
ca1e63a5
RS
1563
1564(define-skeleton rul-function
1565 "Insert a function statement."
1566 "function: "
1567 "function " str " ()" \n
1568 ( "local variables, %s: "
d8677156 1569 > " " str ";" \n)
ca1e63a5
RS
1570 > "begin" \n
1571 > _ \n
1572 resume:
d8677156 1573 > "end;"))
ca1e63a5
RS
1574
1575;; Additions by ACorreir@pervasive-sw.com (Alfred Correira)
1fffafda
LK
1576(when (memq 'mailrc-generic-mode generic-extras-enable-list)
1577
d8677156 1578(define-generic-mode mailrc-generic-mode
82e38f3e
LK
1579 '(?#)
1580 '("alias"
1581 "else"
1582 "endif"
1583 "group"
1584 "if"
1585 "ignore"
1586 "set"
1587 "source"
1588 "unset")
ca1e63a5 1589 '(("^\\s-*\\(alias\\|group\\)\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
16a013c2
LK
1590 (2 font-lock-constant-face)
1591 (3 font-lock-variable-name-face))
ca1e63a5 1592 ("^\\s-*\\(unset\\|set\\|ignore\\)\\s-+\\([-A-Za-z0-9_]+\\)=?\\([^\n\r#]*\\)\\(#.*\\)?$"
16a013c2
LK
1593 (2 font-lock-constant-face)
1594 (3 font-lock-variable-name-face))
5d1c5247
FP
1595 ("^\\s-*\\(source\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1596 (2 font-lock-variable-name-face)))
82e38f3e 1597 '("\\.mailrc\\'")
ca1e63a5 1598 nil
d4fb185d 1599 "Mode for mailrc files."))
ca1e63a5 1600
bb53e1ee 1601;; Inetd.conf
d8677156 1602(when (memq 'inetd-conf-generic-mode generic-extras-enable-list)
bb53e1ee 1603
d8677156 1604(define-generic-mode inetd-conf-generic-mode
82e38f3e
LK
1605 '(?#)
1606 '("stream"
1607 "dgram"
1608 "tcp"
1609 "udp"
1610 "wait"
1611 "nowait"
1612 "internal")
1613 '(("^\\([-A-Za-z0-9_]+\\)" 1 font-lock-type-face))
bb53e1ee 1614 '("/etc/inetd.conf\\'")
ffe0c7ef 1615 (list
bb53e1ee
RS
1616 (function
1617 (lambda ()
ffe0c7ef 1618 (setq imenu-generic-expression
d4fb185d 1619 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
bb53e1ee
RS
1620
1621;; Services
d8677156 1622(when (memq 'etc-services-generic-mode generic-extras-enable-list)
bb53e1ee 1623
d8677156 1624(define-generic-mode etc-services-generic-mode
82e38f3e
LK
1625 '(?#)
1626 '("tcp"
1627 "udp"
1628 "ddp")
d8677156 1629 '(("^\\([-A-Za-z0-9_]+\\)\\s-+\\([0-9]+\\)/"
82e38f3e
LK
1630 (1 font-lock-type-face)
1631 (2 font-lock-variable-name-face)))
bb53e1ee 1632 '("/etc/services\\'")
ffe0c7ef 1633 (list
bb53e1ee
RS
1634 (function
1635 (lambda ()
ffe0c7ef 1636 (setq imenu-generic-expression
d4fb185d 1637 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
bb53e1ee
RS
1638
1639;; Password and Group files
d8677156 1640(when (memq 'etc-passwd-generic-mode generic-extras-enable-list)
bb53e1ee 1641
d8677156 1642(define-generic-mode etc-passwd-generic-mode
bb53e1ee 1643 nil ;; No comment characters
82e38f3e
LK
1644 '("root") ;; Only one keyword
1645 (eval-when-compile
1646 (list
1647 (list
1648 (concat
1649 "^"
1650 ;; User name -- Never blank!
1651 "\\([^:]+\\)"
1652 ":"
1653 ;; Password, UID and GID
1654 (mapconcat
1655 'identity
1656 (make-list 3 "\\([^:]+\\)")
1657 ":")
1658 ":"
1659 ;; GECOS/Name -- might be blank
1660 "\\([^:]*\\)"
1661 ":"
1662 ;; Home directory and shell
1663 "\\([^:]+\\)"
1664 ":?"
1665 "\\([^:]*\\)"
1666 "$")
1667 '(1 font-lock-type-face)
1668 '(5 font-lock-variable-name-face)
1669 '(6 font-lock-constant-face)
1670 '(7 font-lock-warning-face))
1671 '("^\\([^:]+\\):\\([^:]*\\):\\([0-9]+\\):\\(.*\\)$"
1672 (1 font-lock-type-face)
1673 (4 font-lock-variable-name-face))))
bb53e1ee 1674 '("/etc/passwd\\'" "/etc/group\\'")
ffe0c7ef 1675 (list
bb53e1ee
RS
1676 (function
1677 (lambda ()
ffe0c7ef 1678 (setq imenu-generic-expression
d4fb185d 1679 '((nil "^\\([-A-Za-z0-9_]+\\):" 1))))))))
bb53e1ee 1680
7aeb9d6f 1681;; Fstab
d8677156 1682(when (memq 'etc-fstab-generic-mode generic-extras-enable-list)
7aeb9d6f 1683
d8677156 1684(define-generic-mode etc-fstab-generic-mode
82e38f3e
LK
1685 '(?#)
1686 '("adfs"
1687 "affs"
1688 "autofs"
1689 "coda"
1690 "coherent"
1691 "cramfs"
1692 "devpts"
1693 "efs"
1694 "ext2"
1695 "ext3"
1696 "hfs"
1697 "hpfs"
1698 "iso9660"
1699 "jfs"
1700 "minix"
1701 "msdos"
1702 "ncpfs"
1703 "nfs"
1704 "ntfs"
1705 "proc"
1706 "qnx4"
1707 "reiserfs"
1708 "romfs"
1709 "smbfs"
3e54ab6c
LH
1710 "cifs"
1711 "usbdevfs"
82e38f3e
LK
1712 "sysv"
1713 "tmpfs"
1714 "udf"
1715 "ufs"
1716 "umsdos"
1717 "vfat"
1718 "xenix"
1719 "xfs"
1720 "swap"
1721 "auto"
1722 "ignore")
3e54ab6c 1723 '(("^\\([^# \t]+\\)\\s-+\\([^# \t]+\\)"
60c19d5e
LK
1724 (1 font-lock-type-face t)
1725 (2 font-lock-variable-name-face t)))
7aeb9d6f
PB
1726 '("/etc/[v]*fstab\\'")
1727 (list
1728 (function
1729 (lambda ()
1730 (setq imenu-generic-expression
3e54ab6c 1731 '((nil "^\\([^# \t]+\\)\\s-+" 1))))))))
bb53e1ee
RS
1732
1733;; From Jacques Duthen <jacques.duthen@sncf.fr>
1fffafda
LK
1734(when (memq 'show-tabs-generic-mode generic-extras-enable-list)
1735
16a013c2
LK
1736(eval-when-compile
1737
1738(defconst show-tabs-generic-mode-font-lock-defaults-1
82e38f3e 1739 '(;; trailing spaces must come before...
f0b3dcbf 1740 ("[ \t]+$" . 'show-tabs-space)
d8677156 1741 ;; ...embedded tabs
f0b3dcbf 1742 ("[^\n\t]\\(\t+\\)" (1 'show-tabs-tab))))
bb53e1ee 1743
16a013c2 1744(defconst show-tabs-generic-mode-font-lock-defaults-2
82e38f3e 1745 '(;; trailing spaces must come before...
f0b3dcbf 1746 ("[ \t]+$" . 'show-tabs-space)
d8677156 1747 ;; ...tabs
f0b3dcbf 1748 ("\t+" . 'show-tabs-tab))))
bb53e1ee 1749
f0b3dcbf 1750(defface show-tabs-tab
16a013c2
LK
1751 '((((class grayscale) (background light)) (:background "DimGray" :weight bold))
1752 (((class grayscale) (background dark)) (:background "LightGray" :weight bold))
ea81d57e
DN
1753 (((class color) (min-colors 88)) (:background "red1"))
1754 (((class color)) (:background "red"))
1fd714a4 1755 (t (:weight bold)))
bb53e1ee 1756 "Font Lock mode face used to highlight TABs."
d4fb185d 1757 :group 'generic-x)
f0b3dcbf
MB
1758;; backward-compatibility alias
1759(put 'show-tabs-tab-face 'face-alias 'show-tabs-tab)
bb53e1ee 1760
f0b3dcbf 1761(defface show-tabs-space
16a013c2
LK
1762 '((((class grayscale) (background light)) (:background "DimGray" :weight bold))
1763 (((class grayscale) (background dark)) (:background "LightGray" :weight bold))
ea81d57e
DN
1764 (((class color) (min-colors 88)) (:background "yellow1"))
1765 (((class color)) (:background "yellow"))
1fd714a4 1766 (t (:weight bold)))
bb53e1ee 1767 "Font Lock mode face used to highlight spaces."
d4fb185d 1768 :group 'generic-x)
f0b3dcbf
MB
1769;; backward-compatibility alias
1770(put 'show-tabs-space-face 'face-alias 'show-tabs-space)
bb53e1ee 1771
d8677156 1772(define-generic-mode show-tabs-generic-mode
82e38f3e
LK
1773 nil ;; no comment char
1774 nil ;; no keywords
16a013c2 1775 (eval-when-compile show-tabs-generic-mode-font-lock-defaults-1)
82e38f3e
LK
1776 nil ;; no auto-mode-alist
1777 ;; '(show-tabs-generic-mode-hook-fun)
bb53e1ee 1778 nil
76ee7bd5 1779 "Generic mode to show tabs and trailing spaces."))
bb53e1ee 1780
ffe0c7ef
PB
1781;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1782;; DNS modes
1783;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1784
1fffafda
LK
1785(when (memq 'named-boot-generic-mode generic-extras-enable-list)
1786
d8677156
LK
1787(define-generic-mode named-boot-generic-mode
1788 ;; List of comment characters
82e38f3e 1789 '(?\;)
d8677156 1790 ;; List of keywords
82e38f3e
LK
1791 '("cache" "primary" "secondary" "forwarders" "limit" "options"
1792 "directory" "check-names")
d8677156 1793 ;; List of additional font-lock-expressions
82e38f3e
LK
1794 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face)
1795 ("^directory\\s-+\\(.*\\)" 1 font-lock-variable-name-face)
1796 ("^\\(primary\\|cache\\)\\s-+\\([.A-Za-z]+\\)\\s-+\\(.*\\)"
1797 (2 font-lock-variable-name-face)
1798 (3 font-lock-constant-face)))
d8677156 1799 ;; List of additional automode-alist expressions
82e38f3e 1800 '("/etc/named.boot\\'")
d8677156 1801 ;; List of set up functions to call
d4fb185d 1802 nil))
1fffafda
LK
1803
1804(when (memq 'named-database-generic-mode generic-extras-enable-list)
ffe0c7ef 1805
d8677156
LK
1806(define-generic-mode named-database-generic-mode
1807 ;; List of comment characters
82e38f3e 1808 '(?\;)
d8677156 1809 ;; List of keywords
82e38f3e 1810 '("IN" "NS" "CNAME" "SOA" "PTR" "MX" "A")
d8677156 1811 ;; List of additional font-lock-expressions
82e38f3e
LK
1812 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face)
1813 ("^\\([.A-Za-z0-9]+\\)" 1 font-lock-variable-name-face))
60c19d5e 1814 ;; List of additional auto-mode-alist expressions
ffe0c7ef 1815 nil
d8677156 1816 ;; List of set up functions to call
d4fb185d 1817 nil)
ffe0c7ef
PB
1818
1819(defvar named-database-time-string "%Y%m%d%H"
1820 "Timestring for named serial numbers.")
1821
1822(defun named-database-print-serial ()
1823 "Print a serial number based on the current date."
1824 (interactive)
1fffafda
LK
1825 (insert (format-time-string named-database-time-string (current-time)))))
1826
1827(when (memq 'resolve-conf-generic-mode generic-extras-enable-list)
ffe0c7ef 1828
d8677156
LK
1829(define-generic-mode resolve-conf-generic-mode
1830 ;; List of comment characters
82e38f3e 1831 '(?#)
d8677156 1832 ;; List of keywords
82e38f3e 1833 '("nameserver" "domain" "search" "sortlist" "options")
d8677156 1834 ;; List of additional font-lock-expressions
ffe0c7ef 1835 nil
60c19d5e 1836 ;; List of additional auto-mode-alist expressions
82e38f3e 1837 '("/etc/resolv[e]?.conf\\'")
d8677156 1838 ;; List of set up functions to call
d4fb185d 1839 nil))
ffe0c7ef
PB
1840
1841;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1842;; Modes for spice and common electrical engineering circuit netlist formats
1843;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1844
1fffafda
LK
1845(when (memq 'spice-generic-mode generic-extras-enable-list)
1846
d8677156 1847(define-generic-mode spice-generic-mode
ffe0c7ef 1848 nil
82e38f3e
LK
1849 '("and"
1850 "cccs"
1851 "ccvs"
1852 "delay"
1853 "nand"
1854 "nor"
1855 "npwl"
1856 "or"
1857 "par"
1858 "ppwl"
1859 "pwl"
1860 "vccap"
1861 "vccs"
1862 "vcr"
1863 "vcvs")
1864 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face)
1865 (" \\(\\$ .*\\)$" 1 font-lock-comment-face)
1866 ("^\\(\\$ .*\\)$" 1 font-lock-comment-face)
1867 ("\\([*].*\\)" 1 font-lock-comment-face)
1868 ("^\\([+]\\)" 1 font-lock-string-face)
1869 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face)
1870 ("\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face)
1871 ("\\('[^']+'\\)" 1 font-lock-string-face)
1872 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face))
1873 '("\\.[sS][pP]\\'"
1874 "\\.[sS][pP][iI]\\'"
1875 "\\.[sS][pP][iI][cC][eE]\\'"
1876 "\\.[iI][nN][cC]\\'")
ffe0c7ef
PB
1877 (list
1878 'generic-bracket-support
1879 ;; Make keywords case-insensitive
1880 (function
1881 (lambda()
16a013c2 1882 (setq font-lock-defaults '(generic-font-lock-keywords nil t)))))
d4fb185d 1883 "Generic mode for SPICE circuit netlist files."))
1fffafda
LK
1884
1885(when (memq 'ibis-generic-mode generic-extras-enable-list)
ffe0c7ef 1886
d8677156 1887(define-generic-mode ibis-generic-mode
82e38f3e 1888 '(?|)
ffe0c7ef 1889 nil
82e38f3e
LK
1890 '(("[[]\\([^]]*\\)[]]" 1 font-lock-keyword-face)
1891 ("\\(\\(_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face))
1892 '("\\.[iI][bB][sS]\\'")
1893 '(generic-bracket-support)
d4fb185d 1894 "Generic mode for IBIS circuit netlist files."))
1fffafda
LK
1895
1896(when (memq 'astap-generic-mode generic-extras-enable-list)
ffe0c7ef 1897
d8677156 1898(define-generic-mode astap-generic-mode
ffe0c7ef 1899 nil
82e38f3e
LK
1900 '("analyze"
1901 "description"
1902 "elements"
1903 "execution"
1904 "features"
1905 "functions"
1906 "ground"
1907 "model"
1908 "outputs"
1909 "print"
1910 "run"
1911 "controls"
1912 "table")
1913 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face)
1914 (";\\s-*\\([*].*\\)" 1 font-lock-comment-face)
1915 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face)
1916 ("\\('[^']+'\\)" 1 font-lock-string-face)
1917 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face)
1918 ("[(,]\\s-*\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face))
1919 '("\\.[aA][pP]\\'"
1920 "\\.[aA][sS][xX]\\'"
1921 "\\.[aA][sS][tT][aA][pP]\\'"
1922 "\\.[pP][sS][pP]\\'"
1923 "\\.[dD][eE][cC][kK]\\'"
1924 "\\.[gG][oO][dD][aA][tT][aA]")
ffe0c7ef
PB
1925 (list
1926 'generic-bracket-support
1927 ;; Make keywords case-insensitive
1928 (function
1929 (lambda()
16a013c2 1930 (setq font-lock-defaults '(generic-font-lock-keywords nil t)))))
d4fb185d 1931 "Generic mode for ASTAP circuit netlist files."))
1fffafda
LK
1932
1933(when (memq 'etc-modules-conf-generic-mode generic-extras-enable-list)
ffe0c7ef 1934
d8677156
LK
1935(define-generic-mode etc-modules-conf-generic-mode
1936 ;; List of comment characters
82e38f3e 1937 '(?#)
d8677156 1938 ;; List of keywords
82e38f3e
LK
1939 '("above"
1940 "alias"
1941 "below"
1942 "define"
1943 "depfile"
1944 "else"
1945 "elseif"
1946 "endif"
1947 "if"
1948 "include"
1949 "insmod_opt"
1950 "install"
1951 "keep"
1952 "options"
1953 "path"
1954 "generic_stringfile"
1955 "pcimapfile"
1956 "isapnpmapfile"
1957 "usbmapfile"
1958 "parportmapfile"
1959 "ieee1394mapfile"
1960 "pnpbiosmapfile"
1961 "probe"
1962 "probeall"
1963 "prune"
1964 "post-install"
1965 "post-remove"
1966 "pre-install"
1967 "pre-remove"
1968 "remove"
1969 "persistdir")
d8677156 1970 ;; List of additional font-lock-expressions
9845e669 1971 nil
d8677156 1972 ;; List of additional automode-alist expressions
82e38f3e 1973 '("/etc/modules.conf" "/etc/conf.modules")
d8677156 1974 ;; List of set up functions to call
d4fb185d 1975 nil))
ffe0c7ef 1976
ca1e63a5
RS
1977(provide 'generic-x)
1978
ab5796a9 1979;;; arch-tag: cde692a5-9ff6-4506-9999-c67999c2bdb5
ca1e63a5 1980;;; generic-x.el ends here