1 ;;; generic-x.el --- A collection of generic modes
3 ;; Copyright (C) 1997, 1998, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
4 ;; 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: Peter Breton <pbreton@cs.umb.edu>
7 ;; Created: Tue Oct 08 1996
8 ;; Keywords: generic, comment, font-lock
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28 ;; This file contains a collection of generic modes.
32 ;; Add this line to your .emacs file:
34 ;; (require 'generic-x)
36 ;; You can decide which modes to load by setting the variable
37 ;; `generic-extras-enable-list'. Its default value is platform-
38 ;; specific. The recommended way to set this variable is through
41 ;; M-x customize-option RET generic-extras-enable-list RET
43 ;; This lets you select generic modes from the list of available
44 ;; modes. If you manually set `generic-extras-enable-list' in your
45 ;; .emacs, do it BEFORE loading generic-x with (require 'generic-x).
47 ;; You can also send in new modes; if the file types are reasonably
48 ;; common, we would like to install them.
50 ;; DEFAULT GENERIC MODE:
52 ;; This file provides a hook which automatically puts a file into
53 ;; `default-generic-mode' if the first few lines of a file in
54 ;; fundamental mode start with a hash comment character. To disable
55 ;; this functionality, set the variable `generic-use-find-file-hook'
56 ;; to nil BEFORE loading generic-x. See the variables
57 ;; `generic-lines-to-scan' and `generic-find-file-regexp' for
58 ;; customization options.
60 ;; PROBLEMS WHEN USED WITH FOLDING MODE:
62 ;; [The following relates to the obsolete selective-display technique.
63 ;; Folding mode should use invisible text properties instead. -- Dave
66 ;; From Anders Lindgren <andersl@csd.uu.se>
68 ;; Problem summary: Wayne Adams has found a problem when using folding
69 ;; mode in conjunction with font-lock for a mode defined in
72 ;; The problem, as Wayne described it, was that error messages of the
73 ;; following form appeared when both font-lock and folding are used:
75 ;; > - various msgs including "Fontifying region...(error Stack
76 ;; > overflow in regexp matcher)" appear
78 ;; I have just tracked down the cause of the problem. The regexp's in
79 ;; `generic-x.el' do not take into account the way that folding hides
80 ;; sections of the buffer. The technique is known as
81 ;; `selective-display' and has been available for a very long time (I
82 ;; started using it back in the good old Emacs 18 days). Basically, a
83 ;; section is hidden by creating one very long line were the newline
84 ;; character (C-j) is replaced by a linefeed (C-m) character.
86 ;; Many other hiding packages, besides folding, use the same technique,
87 ;; the problem should occur when using them as well.
89 ;; The erroneous lines in `generic-x.el' look like the following (this
90 ;; example is from the `ini' section):
92 ;; '(("^\\(\\[.*\\]\\)" 1 'font-lock-constant-face)
93 ;; ("^\\(.*\\)=" 1 'font-lock-variable-name-face)
95 ;; The intention of these lines is to highlight lines of the following
101 ;; However, since the `.' regexp symbol matches the linefeed character
102 ;; the entire folded section is searched, resulting in a regexp stack
105 ;; Solution suggestion: Instead of using ".", use the sequence
106 ;; "[^\n\r]". This will make the rules behave just as before, but
107 ;; they will work together with selective-display.
111 (eval-when-compile (require 'font-lock
))
113 (defgroup generic-x nil
114 "A collection of generic modes."
119 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
120 ;; Default-Generic mode
121 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
123 (defcustom generic-use-find-file-hook t
124 "If non-nil, add a hook to enter `default-generic-mode' automatically.
125 This is done if the first few lines of a file in fundamental mode
126 start with a hash comment character."
130 (defcustom generic-lines-to-scan
3
131 "Number of lines that `generic-mode-find-file-hook' looks at.
132 Relevant when deciding whether to enter Default-Generic mode automatically.
133 This variable should be set to a small positive number."
137 (defcustom generic-find-file-regexp
"^#"
138 "Regular expression used by `generic-mode-find-file-hook'.
139 Files in fundamental mode whose first few lines contain a match
140 for this regexp, should be put into Default-Generic mode instead.
141 The number of lines tested for the matches is specified by the
142 value of the variable `generic-lines-to-scan', which see."
146 (defcustom generic-ignore-files-regexp
"[Tt][Aa][Gg][Ss]\\'"
147 "Regular expression used by `generic-mode-find-file-hook'.
148 Files whose names match this regular expression should not be put
149 into Default-Generic mode, even if they have lines which match
150 the regexp in `generic-find-file-regexp'. If the value is nil,
151 `generic-mode-find-file-hook' does not check the file names."
153 :type
'(choice (const :tag
"Don't check file names" nil
) regexp
))
155 ;; This generic mode is always defined
156 (define-generic-mode default-generic-mode
(list ?
#) nil nil nil nil
)
158 ;; A more general solution would allow us to enter generic-mode for
159 ;; *any* comment character, but would require us to synthesize a new
160 ;; generic-mode on the fly. I think this gives us most of what we
162 (defun generic-mode-find-file-hook ()
163 "Hook function to enter Default-Generic mode automatically.
165 Done if the first few lines of a file in Fundamental mode start
166 with a match for the regexp in `generic-find-file-regexp', unless
167 the file's name matches the regexp which is the value of the
168 variable `generic-ignore-files-regexp'.
170 This hook will be installed if the variable
171 `generic-use-find-file-hook' is non-nil. The variable
172 `generic-lines-to-scan' determines the number of lines to look at."
173 (when (and (eq major-mode
'fundamental-mode
)
174 (or (null generic-ignore-files-regexp
)
176 generic-ignore-files-regexp
177 (file-name-sans-versions buffer-file-name
)))))
179 (goto-char (point-min))
180 (when (re-search-forward generic-find-file-regexp
182 (forward-line generic-lines-to-scan
)
184 (goto-char (point-min))
185 (default-generic-mode)))))
187 (and generic-use-find-file-hook
188 (add-hook 'find-file-hook
'generic-mode-find-file-hook
))
190 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
191 ;; Other Generic modes
192 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
194 ;; If you add a generic mode to this file, put it in one of these four
197 (defconst generic-default-modes
198 '(apache-conf-generic-mode
199 apache-log-generic-mode
201 java-manifest-generic-mode
202 java-properties-generic-mode
203 javascript-generic-mode
204 show-tabs-generic-mode
206 "List of generic modes that are defined by default.")
208 (defconst generic-mswindows-modes
215 "List of generic modes that are defined by default on MS-Windows.")
217 (defconst generic-unix-modes
219 etc-fstab-generic-mode
220 etc-modules-conf-generic-mode
221 etc-passwd-generic-mode
222 etc-services-generic-mode
223 etc-sudoers-generic-mode
225 inetd-conf-generic-mode
226 mailagent-rules-generic-mode
228 named-boot-generic-mode
229 named-database-generic-mode
230 prototype-generic-mode
231 resolve-conf-generic-mode
233 x-resource-generic-mode
)
234 "List of generic modes that are defined by default on Unix.")
236 (defconst generic-other-modes
241 "List of generic modes that are not defined by default.")
243 (defcustom generic-define-mswindows-modes
244 (memq system-type
'(windows-nt ms-dos
))
245 "Non-nil means the modes in `generic-mswindows-modes' will be defined.
246 This is a list of MS-Windows specific generic modes. This variable
247 only affects the default value of `generic-extras-enable-list'."
251 (make-obsolete-variable 'generic-define-mswindows-modes
'generic-extras-enable-list
"22.1")
253 (defcustom generic-define-unix-modes
254 (not (memq system-type
'(windows-nt ms-dos
)))
255 "Non-nil means the modes in `generic-unix-modes' will be defined.
256 This is a list of Unix specific generic modes. This variable only
257 affects the default value of `generic-extras-enable-list'."
261 (make-obsolete-variable 'generic-define-unix-modes
'generic-extras-enable-list
"22.1")
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
)
268 "List of generic modes to define.
269 Each entry in the list should be a symbol. If you set this variable
270 directly, without using customize, you must reload generic-x to put
271 your changes into effect."
275 (sort (append generic-default-modes
276 generic-mswindows-modes
281 (string< (symbol-name b
)
284 (push `(const ,mode
) list
)))
287 (unless load-in-progress
292 (when (memq 'apache-conf-generic-mode generic-extras-enable-list
)
294 (define-generic-mode apache-conf-generic-mode
297 '(("^\\s-*\\(<.*>\\)" 1 font-lock-constant-face
)
298 ("^\\s-*\\(\\sw+\\)\\s-" 1 font-lock-variable-name-face
))
299 '("srm\\.conf\\'" "httpd\\.conf\\'" "access\\.conf\\'")
303 (setq imenu-generic-expression
304 '((nil "^\\([-A-Za-z0-9_]+\\)" 1)
305 ("*Directories*" "^\\s-*<Directory\\s-*\\([^>]+\\)>" 1)
306 ("*Locations*" "^\\s-*<Location\\s-*\\([^>]+\\)>" 1))))))
307 "Generic mode for Apache or HTTPD configuration files."))
309 (when (memq 'apache-log-generic-mode generic-extras-enable-list
)
311 (define-generic-mode apache-log-generic-mode
314 ;; Hostname ? user date request return-code number-of-bytes
315 '(("^\\([-a-zA-z0-9.]+\\) - [-A-Za-z]+ \\(\\[.*\\]\\)"
316 (1 font-lock-constant-face
)
317 (2 font-lock-variable-name-face
)))
320 "Generic mode for Apache log files."))
323 (when (memq 'samba-generic-mode generic-extras-enable-list
)
325 (define-generic-mode samba-generic-mode
328 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face
)
329 ("^\\s-*\\(.+\\)=\\([^\r\n]*\\)"
330 (1 font-lock-variable-name-face
)
331 (2 font-lock-type-face
)))
333 '(generic-bracket-support)
334 "Generic mode for Samba configuration files."))
337 ;; This is pretty basic. Also, modes for other window managers could
338 ;; be defined as well.
339 (when (memq 'fvwm-generic-mode generic-extras-enable-list
)
341 (define-generic-mode fvwm-generic-mode
357 '("\\.fvwmrc\\'" "\\.fvwm2rc\\'")
359 "Generic mode for FVWM configuration files."))
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
364 (when (memq 'x-resource-generic-mode generic-extras-enable-list
)
366 (define-generic-mode x-resource-generic-mode
369 '(("^\\([^:\n]+:\\)" 1 font-lock-variable-name-face
))
370 '("\\.Xdefaults\\'" "\\.Xresources\\'" "\\.Xenvironment\\'" "\\.ad\\'")
372 "Generic mode for X Resource configuration files."))
375 (when (memq 'hosts-generic-mode generic-extras-enable-list
)
377 (define-generic-mode hosts-generic-mode
380 '(("\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)" 1 font-lock-constant-face
))
381 '("[hH][oO][sS][tT][sS]\\'")
383 "Generic mode for HOSTS files."))
385 ;;; Windows INF files
387 ;; If i-g-m-f-f-h is defined, then so is i-g-m.
388 (declare-function ini-generic-mode
"generic-x")
390 (when (memq 'inf-generic-mode generic-extras-enable-list
)
392 (define-generic-mode inf-generic-mode
395 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face
))
396 '("\\.[iI][nN][fF]\\'")
397 '(generic-bracket-support)
398 "Generic mode for MS-Windows INF files."))
400 ;;; Windows INI files
401 ;; Should define escape character as well!
402 (when (memq 'ini-generic-mode generic-extras-enable-list
)
404 (define-generic-mode ini-generic-mode
407 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face
)
408 ("^\\([^=\n\r]*\\)=\\([^\n\r]*\\)$"
409 (1 font-lock-function-name-face
)
410 (2 font-lock-variable-name-face
)))
411 '("\\.[iI][nN][iI]\\'")
415 (setq imenu-generic-expression
416 '((nil "^\\[\\(.*\\)\\]" 1)
417 ("*Variables*" "^\\s-*\\([^=]+\\)\\s-*=" 1))))))
418 "Generic mode for MS-Windows INI files.
419 You can use `ini-generic-mode-find-file-hook' to enter this mode
420 automatically for INI files whose names do not end in \".ini\".")
422 (defun ini-generic-mode-find-file-hook ()
423 "Hook function to enter Ini-Generic mode automatically for INI files.
424 Done if the first few lines of a file in Fundamental mode look
425 like an INI file. You can add this hook to `find-file-hook'."
426 (and (eq major-mode
'fundamental-mode
)
428 (goto-char (point-min))
429 (and (looking-at "^\\s-*\\[.*\\]")
430 (ini-generic-mode)))))
431 (defalias 'generic-mode-ini-file-find-file-hook
'ini-generic-mode-find-file-hook
))
433 ;;; Windows REG files
434 ;;; Unfortunately, Windows 95 and Windows NT have different REG file syntax!
435 (when (memq 'reg-generic-mode generic-extras-enable-list
)
437 (define-generic-mode reg-generic-mode
439 '("key" "classes_root" "REGEDIT" "REGEDIT4")
440 '(("\\(\\[.*\\]\\)" 1 font-lock-constant-face
)
441 ("^\\([^\n\r]*\\)\\s-*=" 1 font-lock-variable-name-face
))
442 '("\\.[rR][eE][gG]\\'")
446 (setq imenu-generic-expression
447 '((nil "^\\s-*\\(.*\\)\\s-*=" 1))))))
448 "Generic mode for MS-Windows Registry files."))
450 (declare-function w32-shell-name
"w32-fns" ())
452 ;;; DOS/Windows BAT files
453 (when (memq 'bat-generic-mode generic-extras-enable-list
)
455 (define-generic-mode bat-generic-mode
460 ;; Make this one first in the list, otherwise comments will
461 ;; be over-written by other variables
462 '("^[@ \t]*\\([rR][eE][mM][^\n\r]*\\)" 1 font-lock-comment-face t
)
463 '("^[ \t]*\\(::.*\\)" 1 font-lock-comment-face t
)
464 '("^[@ \t]*\\([bB][rR][eE][aA][kK]\\|[vV][eE][rR][iI][fF][yY]\\)[ \t]+\\([oO]\\([nN]\\|[fF][fF]\\)\\)"
465 (1 font-lock-builtin-face
)
466 (2 font-lock-constant-face t t
))
467 ;; Any text (except ON/OFF) following ECHO is a string.
468 '("^[@ \t]*\\([eE][cC][hH][oO]\\)[ \t]+\\(\\([oO]\\([nN]\\|[fF][fF]\\)\\)\\|\\([^>|\r\n]+\\)\\)"
469 (1 font-lock-builtin-face
)
470 (3 font-lock-constant-face t t
)
471 (5 font-lock-string-face t t
))
472 ;; These keywords appear as the first word on a line. (Actually, they
473 ;; can also appear after "if ..." or "for ..." clause, but since they
474 ;; are frequently used in simple text, we punt.)
475 ;; In `generic-bat-mode-setup-function' we make the keywords
477 (generic-make-keywords-list
480 font-lock-keyword-face
"^[@ \t]*")
481 ;; These keywords can be anywhere on a line
482 ;; In `generic-bat-mode-setup-function' we make the keywords
484 (generic-make-keywords-list
490 font-lock-keyword-face
)
491 ;; These are built-in commands. Only frequently-used ones are listed.
492 (generic-make-keywords-list
493 '("CALL" "call" "Call"
501 "PAUSE" "pause" "Pause"
502 "PROMPT" "prompt" "Prompt"
506 "START" "start" "Start"
507 "SHIFT" "shift" "Shift")
508 font-lock-builtin-face
"[ \t|\n]")
509 '("^[ \t]*\\(:\\sw+\\)" 1 font-lock-function-name-face t
)
510 '("\\(%\\sw+%\\)" 1 font-lock-variable-name-face t
)
511 '("\\(%[0-9]\\)" 1 font-lock-variable-name-face t
)
512 '("[\t ]+\\([+-/][^\t\n\" ]+\\)" 1 font-lock-type-face
)
513 '("[ \t\n|]\\<\\([gG][oO][tT][oO]\\)\\>[ \t]*\\(\\sw+\\)?"
514 (1 font-lock-keyword-face
)
515 (2 font-lock-function-name-face nil t
))
516 '("[ \t\n|]\\<\\([sS][eE][tT]\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*=?"
517 (1 font-lock-builtin-face
)
518 (2 font-lock-variable-name-face t t
))))
519 '("\\.[bB][aA][tT]\\'"
521 "\\`[cC][oO][nN][fF][iI][gG]\\."
522 "\\`[aA][uU][tT][oO][eE][xX][eE][cC]\\.")
523 '(generic-bat-mode-setup-function)
524 "Generic mode for MS-Windows batch files.")
526 (defvar bat-generic-mode-syntax-table nil
527 "Syntax table in use in `bat-generic-mode' buffers.")
529 (defvar bat-generic-mode-keymap
(make-sparse-keymap)
530 "Keymap for `bat-generic-mode'.")
532 (defun bat-generic-mode-compile ()
533 "Run the current BAT file in a compilation buffer."
535 (let ((compilation-buffer-name-function
538 (concat "*" (buffer-file-name) "*")))))
540 (concat (w32-shell-name) " -c " (buffer-file-name)))))
542 (eval-when-compile (require 'comint
))
543 (defun bat-generic-mode-run-as-comint ()
544 "Run the current BAT file in a comint buffer."
547 (let* ((file (buffer-file-name))
548 (buf-name (concat "*" file
"*")))
549 (with-current-buffer (get-buffer-create buf-name
)
558 (display-buffer buf-name
))))
560 (define-key bat-generic-mode-keymap
"\C-c\C-c" 'bat-generic-mode-compile
)
562 ;; Make underscores count as words
563 (unless bat-generic-mode-syntax-table
564 (setq bat-generic-mode-syntax-table
(make-syntax-table))
565 (modify-syntax-entry ?_
"w" bat-generic-mode-syntax-table
))
567 ;; bat-generic-mode doesn't use the comment functionality of
568 ;; define-generic-mode because it has a three-letter comment-string,
569 ;; so we do it here manually instead
570 (defun generic-bat-mode-setup-function ()
571 (make-local-variable 'parse-sexp-ignore-comments
)
572 (make-local-variable 'comment-start
)
573 (make-local-variable 'comment-start-skip
)
574 (make-local-variable 'comment-end
)
575 (setq imenu-generic-expression
'((nil "^:\\(\\sw+\\)" 1))
576 parse-sexp-ignore-comments t
579 comment-start-skip
"[Rr][Ee][Mm] *")
580 (set-syntax-table bat-generic-mode-syntax-table
)
581 ;; Make keywords case-insensitive
582 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
))
583 (use-local-map bat-generic-mode-keymap
)))
586 ;; Mailagent is a Unix mail filtering program. Anyone wanna do a
587 ;; generic mode for procmail?
588 (when (memq 'mailagent-rules-generic-mode generic-extras-enable-list
)
590 (define-generic-mode mailagent-rules-generic-mode
592 '("SAVE" "DELETE" "PIPE" "ANNOTATE" "REJECT")
593 '(("^\\(\\sw+\\)\\s-*=" 1 font-lock-variable-name-face
)
594 ("\\s-/\\([^/]+\\)/[i, \t\n]" 1 font-lock-constant-face
))
599 (setq imenu-generic-expression
600 '((nil "\\s-/\\([^/]+\\)/[i, \t\n]" 1))))))
601 "Generic mode for Mailagent rules files."))
603 ;; Solaris/Sys V prototype files
604 (when (memq 'prototype-generic-mode generic-extras-enable-list
)
606 (define-generic-mode prototype-generic-mode
609 '(("^\\([0-9]\\)?\\s-*\\([a-z]\\)\\s-+\\([A-Za-z_]+\\)\\s-+\\([^\n\r]*\\)$"
610 (2 font-lock-constant-face
)
611 (3 font-lock-keyword-face
))
612 ("^\\([a-z]\\) \\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
613 (1 font-lock-constant-face
)
614 (2 font-lock-keyword-face
)
615 (3 font-lock-variable-name-face
))
616 ("^\\(!\\s-*\\(search\\|include\\|default\\)\\)\\s-*\\([^\n\r]*\\)$"
617 (1 font-lock-keyword-face
)
618 (3 font-lock-variable-name-face
))
619 ("^\\(!\\s-*\\sw+\\)=\\([^\n\r]*\\)$"
620 (1 font-lock-keyword-face
)
621 (2 font-lock-variable-name-face
)))
624 "Generic mode for Sys V prototype files."))
626 ;; Solaris/Sys V pkginfo files
627 (when (memq 'pkginfo-generic-mode generic-extras-enable-list
)
629 (define-generic-mode pkginfo-generic-mode
632 '(("^\\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
633 (1 font-lock-keyword-face
)
634 (2 font-lock-variable-name-face
)))
637 "Generic mode for Sys V pkginfo files."))
640 ;; Includes extra keywords from Armando Singer [asinger@MAIL.COLGATE.EDU]
641 (when (memq 'javascript-generic-mode generic-extras-enable-list
)
643 (define-generic-mode javascript-generic-mode
644 '("//" ("/*" .
"*/"))
667 ;; words reserved for ECMA extensions below
678 ;; Java Keywords reserved by JavaScript
705 '(("^\\s-*function\\s-+\\([A-Za-z0-9_]+\\)"
706 (1 font-lock-function-name-face
))
707 ("^\\s-*var\\s-+\\([A-Za-z0-9_]+\\)"
708 (1 font-lock-variable-name-face
)))
713 (setq imenu-generic-expression
714 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1)
715 ("*Variables*" "^var\\s-+\\([A-Za-z0-9_]+\\)" 1))))))
716 "Generic mode for JavaScript files."))
719 (when (memq 'vrml-generic-mode generic-extras-enable-list
)
721 (define-generic-mode vrml-generic-mode
751 '(("USE\\s-+\\([-A-Za-z0-9_]+\\)"
752 (1 font-lock-constant-face
))
753 ("DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
754 (1 font-lock-type-face
)
755 (2 font-lock-constant-face
))
756 ("^\\s-*\\([-A-Za-z0-9_]+\\)\\s-*{"
757 (1 font-lock-function-name-face
))
758 ("^\\s-*\\(geometry\\|appearance\\|material\\)\\s-+\\([-A-Za-z0-9_]+\\)"
759 (2 font-lock-variable-name-face
)))
764 (setq imenu-generic-expression
765 '((nil "^\\([A-Za-z0-9_]+\\)\\s-*{" 1)
767 "DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
769 "Generic Mode for VRML files."))
772 (when (memq 'java-manifest-generic-mode generic-extras-enable-list
)
774 (define-generic-mode java-manifest-generic-mode
784 '(("^Name:\\s-+\\([^\n\r]*\\)$"
785 (1 font-lock-variable-name-face
))
786 ("^\\(Manifest\\|Required\\|Signature\\)-Version:\\s-+\\([^\n\r]*\\)$"
787 (2 font-lock-constant-face
)))
788 '("[mM][aA][nN][iI][fF][eE][sS][tT]\\.[mM][fF]\\'")
790 "Generic mode for Java Manifest files."))
792 ;; Java properties files
793 (when (memq 'java-properties-generic-mode generic-extras-enable-list
)
795 (define-generic-mode java-properties-generic-mode
799 (let ((java-properties-key
800 "\\(\\([-A-Za-z0-9_\\./]\\|\\(\\\\[ =:]\\)\\)+\\)")
801 (java-properties-value
803 ;; Property and value can be separated in a number of different ways:
811 (concat "^" java-properties-key elt java-properties-value
"$")
812 '(1 font-lock-constant-face
)
813 '(4 font-lock-variable-name-face
))))
814 ;; These are the separators
815 '(":\\s-*" "\\s-+" "\\s-*=\\s-*"))))
820 (setq imenu-generic-expression
821 '((nil "^\\([^#! \t\n\r=:]+\\)" 1))))))
822 "Generic mode for Java properties files."))
824 ;; C shell alias definitions
825 (when (memq 'alias-generic-mode generic-extras-enable-list
)
827 (define-generic-mode alias-generic-mode
830 '(("^alias\\s-+\\([-A-Za-z0-9_]+\\)\\s-+"
831 (1 font-lock-variable-name-face
))
832 ("^unalias\\s-+\\([-A-Za-z0-9_]+\\)\\s-*$"
833 (1 font-lock-variable-name-face
)))
838 (setq imenu-generic-expression
839 '((nil "^\\(alias\\|unalias\\)\\s-+\\([-a-zA-Z0-9_]+\\)" 2))))))
840 "Generic mode for C Shell alias files."))
843 ;; Contributed by ACorreir@pervasive-sw.com (Alfred Correira)
844 (when (memq 'rc-generic-mode generic-extras-enable-list
)
846 (define-generic-mode rc-generic-mode
901 ;; the choice of what tokens go where is somewhat arbitrary,
902 ;; as is the choice of which value tokens are included, as
903 ;; the choice of face for each token group
906 (generic-make-keywords-list
915 (generic-make-keywords-list
920 font-lock-function-name-face
)
921 '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face
)
922 '("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face
)
923 '("^#[ \t]*\\(elif\\|if\\)\\>"
924 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil
925 (1 font-lock-constant-face
)
926 (2 font-lock-variable-name-face nil t
)))
927 '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
928 (1 font-lock-constant-face
)
929 (2 font-lock-variable-name-face nil t
))))
932 "Generic mode for MS-Windows Resource files."))
934 ;; InstallShield RUL files
935 ;; Contributed by Alfred.Correira@Pervasive.Com
936 ;; Bugfixes by "Rolf Sandau" <Rolf.Sandau@marconi.com>
937 (when (memq 'rul-generic-mode generic-extras-enable-list
)
941 ;;; build the regexp strings using regexp-opt
942 (defconst installshield-statement-keyword-list
961 ;; "goto" -- handled elsewhere
975 "Statement keywords used in InstallShield 3 and 5.")
977 (defconst installshield-system-functions-list
997 "ComponentAddItem" ; differs between IS3 and IS5
998 "ComponentCompareSizeRequired" ; IS5 only
1000 "ComponentError" ; IS5 only
1001 "ComponentFileEnum" ; IS5 only
1002 "ComponentFileInfo" ; IS5 only
1003 "ComponentFilterLanguage" ; IS5 only
1004 "ComponentFilterOS" ; IS5 only
1005 "ComponentGetData" ; IS5 only
1006 "ComponentGetItemInfo" ; IS3 only
1007 "ComponentGetItemSize" ; differs between IS3 and IS5
1008 "ComponentIsItemSelected" ; differs between IS3 and IS5
1009 "ComponentListItems"
1010 "ComponentMoveData" ; IS5 only
1011 "ComponentSelectItem" ; differs between IS3 and IS5
1012 "ComponentSetData" ; IS5 only
1013 "ComponentSetItemInfo" ; IS3 only
1014 "ComponentSetTarget" ; IS5 only
1015 "ComponentSetupTypeEnum" ; IS5 only
1016 "ComponentSetupTypeGetData" ; IS5 only
1017 "ComponentSetupTypeSet" ; IS5 only
1018 "ComponentTotalSize"
1019 "ComponentValidate" ; IS5 only
1020 "CompressAdd" ; IS3 only
1021 "CompressDel" ; IS3 only
1022 "CompressEnum" ; IS3 only
1023 "CompressGet" ; IS3 only
1024 "CompressInfo" ; IS3 only
1028 "CreateProgramFolder"
1029 "DeinstallSetReference" ; IS5 only
1055 "FileSetBeginDefine" ; IS3 only
1056 "FileSetEndDefine" ; IS3 only
1057 "FileSetPerformEz" ; IS3 only
1058 "FileSetPerform" ; IS3 only
1059 "FileSetReset" ; IS3 only
1060 "FileSetRoot" ; IS3 only
1074 "GetValidDrivesList"
1089 "ListGetFirstString"
1093 "ListSetCurrentItem"
1099 "LongPathToShortPath"
1114 "PlayMMedia" ; IS5 only
1121 "RegDBGetKeyValueEx"
1122 "RegDBSetKeyValueEx"
1123 "RegDBSetDefaultRoot"
1132 "SdComponentAdvCheckSpace"
1133 "SdComponentAdvInit"
1134 "SdComponentAdvUpdateSpace"
1136 "SdComponentDialog2"
1137 "SdComponentDialogAdv"
1138 "SdComponentDialogEx"
1139 "SdComponentDlgCheckSpace"
1142 "SdConfirmRegistration"
1154 "SdGetUserCompanyInfo"
1163 "SdOptionsButtonsInit"
1164 "SdPlugInProductName"
1167 "SdRegExEnableButton"
1172 "SdSetSequentialItems"
1174 "SdSetupTypeEx" ; IS5 only
1185 "SdUpdateComponentSelection"
1191 "SetDisplayEffect" ; IS5 only
1193 "SetForegroundWindow"
1206 "StrRemoveLastSlash"
1220 "System functions defined in InstallShield 3 and 5.")
1222 (defconst installshield-system-variables-list
1226 "CORECOMPONENTHANDLING"
1252 "System variables used in InstallShield 3 and 5.")
1254 (defconst installshield-types-list
1273 "Type keywords used in InstallShield 3 and 5.")
1275 ;;; some might want to skip highlighting these to improve performance
1276 (defconst installshield-funarg-constants-list
1306 "COMP_UPDATE_VERSION"
1325 "DLG_INFO_CHECKSELECTION"
1327 "DLG_INFO_USEDECIMAL"
1328 "DLG_MSG_INFORMATION"
1349 "FILE_ATTR_ARCHIVED"
1350 "FILE_ATTR_DIRECTORY"
1353 "FILE_ATTR_READONLY"
1359 "FILE_MODE_BINARYREADONLY"
1381 "HKEY_LOCAL_MACHINE"
1426 "REGDB_APPPATH_DEFAULT"
1429 "REGDB_ERR_CONNECTIONEXISTS"
1430 "REGDB_ERR_CORRUPTEDREGSITRY"
1431 "REGDB_ERR_INITIALIZATION"
1432 "REGDB_ERR_INVALIDHANDLE"
1433 "REGDB_ERR_INVALIDNAME"
1435 "REGDB_STRING_EXPAND"
1436 "REGDB_STRING_MULTI"
1438 "REGDB_UNINSTALL_NAME"
1482 "Function argument constants used in InstallShield 3 and 5."))
1484 (defvar rul-generic-mode-syntax-table nil
1485 "Syntax table to use in `rul-generic-mode' buffers.")
1487 (setq rul-generic-mode-syntax-table
1488 (make-syntax-table c
++-mode-syntax-table
))
1490 (modify-syntax-entry ?
\r "> b" rul-generic-mode-syntax-table
)
1491 (modify-syntax-entry ?
\n "> b" rul-generic-mode-syntax-table
)
1493 (modify-syntax-entry ?
/ ". 124b" rul-generic-mode-syntax-table
)
1494 (modify-syntax-entry ?
* ". 23" rul-generic-mode-syntax-table
)
1496 ;; here manually instead
1497 (defun generic-rul-mode-setup-function ()
1498 (make-local-variable 'parse-sexp-ignore-comments
)
1499 (make-local-variable 'comment-start
)
1500 (make-local-variable 'comment-start-skip
)
1501 (make-local-variable 'comment-end
)
1502 (setq imenu-generic-expression
1503 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1))
1504 parse-sexp-ignore-comments t
1508 ;;; comment-start "//"
1509 ;;; comment-start-skip ""
1511 ;; (set-syntax-table rul-generic-mode-syntax-table)
1512 (setq font-lock-syntax-table rul-generic-mode-syntax-table
))
1514 ;; moved mode-definition behind defun-definition to be warning-free - 15.11.02/RSan
1515 (define-generic-mode rul-generic-mode
1516 ;; Using "/*" and "*/" doesn't seem to be working right
1517 '("//" ("/*" .
"*/" ))
1518 (eval-when-compile installshield-statement-keyword-list
)
1521 ;; preprocessor constructs
1522 '("#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)"
1523 1 font-lock-string-face
)
1524 '("#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
1525 (1 font-lock-reference-face
)
1526 (2 font-lock-variable-name-face nil t
))
1527 ;; indirect string constants
1528 '("\\(@[A-Za-z][A-Za-z0-9_]+\\)" 1 font-lock-builtin-face
)
1530 '("[ \t]*\\(\\sw+:\\)" 1 font-lock-reference-face
)
1531 '("\\<\\(goto\\)\\>[ \t]*\\(\\sw+\\)?"
1532 (1 font-lock-keyword-face
)
1533 (2 font-lock-reference-face nil t
))
1535 (generic-make-keywords-list
1536 installshield-system-variables-list
1537 font-lock-variable-name-face
"[^_]" "[^_]")
1539 (generic-make-keywords-list
1540 installshield-system-functions-list
1541 font-lock-function-name-face
"[^_]" "[^_]")
1543 (generic-make-keywords-list
1544 installshield-types-list
1545 font-lock-type-face
"[^_]" "[^_]")
1546 ;; function argument constants
1547 (generic-make-keywords-list
1548 installshield-funarg-constants-list
1549 font-lock-variable-name-face
"[^_]" "[^_]"))) ; is this face the best choice?
1550 '("\\.[rR][uU][lL]\\'")
1551 '(generic-rul-mode-setup-function)
1552 "Generic mode for InstallShield RUL files.")
1554 (define-skeleton rul-if
1555 "Insert an if statement."
1557 "if(" str
") then" \n
1559 ( "other condition, %s: "
1560 > "elseif(" str
") then" \n
1567 (define-skeleton rul-function
1568 "Insert a function statement."
1570 "function " str
" ()" \n
1571 ( "local variables, %s: "
1578 ;; Additions by ACorreir@pervasive-sw.com (Alfred Correira)
1579 (when (memq 'mailrc-generic-mode generic-extras-enable-list
)
1581 (define-generic-mode mailrc-generic-mode
1592 '(("^\\s-*\\(alias\\|group\\)\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1593 (2 font-lock-constant-face
)
1594 (3 font-lock-variable-name-face
))
1595 ("^\\s-*\\(unset\\|set\\|ignore\\)\\s-+\\([-A-Za-z0-9_]+\\)=?\\([^\n\r#]*\\)\\(#.*\\)?$"
1596 (2 font-lock-constant-face
)
1597 (3 font-lock-variable-name-face
))
1598 ("^\\s-*\\(source\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1599 (2 font-lock-variable-name-face
)))
1602 "Mode for mailrc files."))
1605 (when (memq 'inetd-conf-generic-mode generic-extras-enable-list
)
1607 (define-generic-mode inetd-conf-generic-mode
1616 '(("^\\([-A-Za-z0-9_]+\\)" 1 font-lock-type-face
))
1617 '("/etc/inetd.conf\\'")
1621 (setq imenu-generic-expression
1622 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1625 (when (memq 'etc-services-generic-mode generic-extras-enable-list
)
1627 (define-generic-mode etc-services-generic-mode
1632 '(("^\\([-A-Za-z0-9_]+\\)\\s-+\\([0-9]+\\)/"
1633 (1 font-lock-type-face
)
1634 (2 font-lock-variable-name-face
)))
1635 '("/etc/services\\'")
1639 (setq imenu-generic-expression
1640 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1642 ;; Password and Group files
1643 (when (memq 'etc-passwd-generic-mode generic-extras-enable-list
)
1645 (define-generic-mode etc-passwd-generic-mode
1646 nil
;; No comment characters
1647 '("root") ;; Only one keyword
1653 ;; User name -- Never blank!
1656 ;; Password, UID and GID
1659 (make-list 3 "\\([^:]+\\)")
1662 ;; GECOS/Name -- might be blank
1665 ;; Home directory and shell
1670 '(1 font-lock-type-face
)
1671 '(5 font-lock-variable-name-face
)
1672 '(6 font-lock-constant-face
)
1673 '(7 font-lock-warning-face
))
1674 '("^\\([^:]+\\):\\([^:]*\\):\\([0-9]+\\):\\(.*\\)$"
1675 (1 font-lock-type-face
)
1676 (4 font-lock-variable-name-face
))))
1677 '("/etc/passwd\\'" "/etc/group\\'")
1681 (setq imenu-generic-expression
1682 '((nil "^\\([-A-Za-z0-9_]+\\):" 1))))))))
1685 (when (memq 'etc-fstab-generic-mode generic-extras-enable-list
)
1687 (define-generic-mode etc-fstab-generic-mode
1726 '(("^\\([^# \t]+\\)\\s-+\\([^# \t]+\\)"
1727 (1 font-lock-type-face t
)
1728 (2 font-lock-variable-name-face t
)))
1729 '("/etc/[v]*fstab\\'")
1733 (setq imenu-generic-expression
1734 '((nil "^\\([^# \t]+\\)\\s-+" 1))))))))
1737 (when (memq 'etc-sudoers-generic-mode generic-extras-enable-list
)
1739 (define-generic-mode etc-sudoers-generic-mode
1741 '("User_Alias" "Runas_Alias" "Host_Alias" "Cmnd_Alias"
1742 "NOPASSWD" "PASSWD" "NOEXEC" "EXEC"
1744 '(("\\<\\(root\\|su\\)\\>" 1 font-lock-warning-face
)
1745 ("\\(\\*\\)" 1 font-lock-warning-face
)
1746 ("\\<\\(%[A-Za-z0-9_]+\\)\\>" 1 font-lock-variable-name-face
))
1747 '("/etc/sudoers\\'")
1749 "Generic mode for sudoers configuration files."))
1751 ;; From Jacques Duthen <jacques.duthen@sncf.fr>
1752 (when (memq 'show-tabs-generic-mode generic-extras-enable-list
)
1756 (defconst show-tabs-generic-mode-font-lock-defaults-1
1757 '(;; trailing spaces must come before...
1758 ("[ \t]+$" .
'show-tabs-space
)
1760 ("[^\n\t]\\(\t+\\)" (1 'show-tabs-tab
))))
1762 (defconst show-tabs-generic-mode-font-lock-defaults-2
1763 '(;; trailing spaces must come before...
1764 ("[ \t]+$" .
'show-tabs-space
)
1766 ("\t+" .
'show-tabs-tab
))))
1768 (defface show-tabs-tab
1769 '((((class grayscale
) (background light
)) (:background
"DimGray" :weight bold
))
1770 (((class grayscale
) (background dark
)) (:background
"LightGray" :weight bold
))
1771 (((class color
) (min-colors 88)) (:background
"red1"))
1772 (((class color
)) (:background
"red"))
1774 "Font Lock mode face used to highlight TABs."
1776 (define-obsolete-face-alias 'show-tabs-tab-face
'show-tabs-tab
"22.1")
1778 (defface show-tabs-space
1779 '((((class grayscale
) (background light
)) (:background
"DimGray" :weight bold
))
1780 (((class grayscale
) (background dark
)) (:background
"LightGray" :weight bold
))
1781 (((class color
) (min-colors 88)) (:background
"yellow1"))
1782 (((class color
)) (:background
"yellow"))
1784 "Font Lock mode face used to highlight spaces."
1786 (define-obsolete-face-alias 'show-tabs-space-face
'show-tabs-space
"22.1")
1788 (define-generic-mode show-tabs-generic-mode
1789 nil
;; no comment char
1791 (eval-when-compile show-tabs-generic-mode-font-lock-defaults-1
)
1792 nil
;; no auto-mode-alist
1793 ;; '(show-tabs-generic-mode-hook-fun)
1795 "Generic mode to show tabs and trailing spaces."))
1797 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1799 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1801 (when (memq 'named-boot-generic-mode generic-extras-enable-list
)
1803 (define-generic-mode named-boot-generic-mode
1804 ;; List of comment characters
1807 '("cache" "primary" "secondary" "forwarders" "limit" "options"
1808 "directory" "check-names")
1809 ;; List of additional font-lock-expressions
1810 '(("\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)" 1 font-lock-constant-face
)
1811 ("^directory\\s-+\\(.*\\)" 1 font-lock-variable-name-face
)
1812 ("^\\(primary\\|cache\\)\\s-+\\([.A-Za-z]+\\)\\s-+\\(.*\\)"
1813 (2 font-lock-variable-name-face
)
1814 (3 font-lock-constant-face
)))
1815 ;; List of additional automode-alist expressions
1816 '("/etc/named.boot\\'")
1817 ;; List of set up functions to call
1820 (when (memq 'named-database-generic-mode generic-extras-enable-list
)
1822 (define-generic-mode named-database-generic-mode
1823 ;; List of comment characters
1826 '("IN" "NS" "CNAME" "SOA" "PTR" "MX" "A")
1827 ;; List of additional font-lock-expressions
1828 '(("\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)" 1 font-lock-constant-face
)
1829 ("^\\([.A-Za-z0-9]+\\)" 1 font-lock-variable-name-face
))
1830 ;; List of additional auto-mode-alist expressions
1832 ;; List of set up functions to call
1835 (defvar named-database-time-string
"%Y%m%d%H"
1836 "Timestring for named serial numbers.")
1838 (defun named-database-print-serial ()
1839 "Print a serial number based on the current date."
1841 (insert (format-time-string named-database-time-string
(current-time)))))
1843 (when (memq 'resolve-conf-generic-mode generic-extras-enable-list
)
1845 (define-generic-mode resolve-conf-generic-mode
1846 ;; List of comment characters
1849 '("nameserver" "domain" "search" "sortlist" "options")
1850 ;; List of additional font-lock-expressions
1852 ;; List of additional auto-mode-alist expressions
1853 '("/etc/resolv[e]?.conf\\'")
1854 ;; List of set up functions to call
1857 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1858 ;; Modes for spice and common electrical engineering circuit netlist formats
1859 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1861 (when (memq 'spice-generic-mode generic-extras-enable-list
)
1863 (define-generic-mode spice-generic-mode
1880 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1881 (" \\(\\$ .*\\)$" 1 font-lock-comment-face
)
1882 ("^\\(\\$ .*\\)$" 1 font-lock-comment-face
)
1883 ("\\([*].*\\)" 1 font-lock-comment-face
)
1884 ("^\\([+]\\)" 1 font-lock-string-face
)
1885 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face
)
1886 ("\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
)
1887 ("\\('[^']+'\\)" 1 font-lock-string-face
)
1888 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face
))
1890 "\\.[sS][pP][iI]\\'"
1891 "\\.[sS][pP][iI][cC][eE]\\'"
1892 "\\.[iI][nN][cC]\\'")
1894 'generic-bracket-support
1895 ;; Make keywords case-insensitive
1898 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
)))))
1899 "Generic mode for SPICE circuit netlist files."))
1901 (when (memq 'ibis-generic-mode generic-extras-enable-list
)
1903 (define-generic-mode ibis-generic-mode
1906 '(("[[]\\([^]]*\\)[]]" 1 font-lock-keyword-face
)
1907 ("\\(\\(_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
))
1908 '("\\.[iI][bB][sS]\\'")
1909 '(generic-bracket-support)
1910 "Generic mode for IBIS circuit netlist files."))
1912 (when (memq 'astap-generic-mode generic-extras-enable-list
)
1914 (define-generic-mode astap-generic-mode
1929 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1930 (";\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1931 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face
)
1932 ("\\('[^']+'\\)" 1 font-lock-string-face
)
1933 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face
)
1934 ("[(,]\\s-*\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
))
1936 "\\.[aA][sS][xX]\\'"
1937 "\\.[aA][sS][tT][aA][pP]\\'"
1938 "\\.[pP][sS][pP]\\'"
1939 "\\.[dD][eE][cC][kK]\\'"
1940 "\\.[gG][oO][dD][aA][tT][aA]")
1942 'generic-bracket-support
1943 ;; Make keywords case-insensitive
1946 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
)))))
1947 "Generic mode for ASTAP circuit netlist files."))
1949 (when (memq 'etc-modules-conf-generic-mode generic-extras-enable-list
)
1951 (define-generic-mode etc-modules-conf-generic-mode
1952 ;; List of comment characters
1970 "generic_stringfile"
1986 ;; List of additional font-lock-expressions
1988 ;; List of additional automode-alist expressions
1989 '("/etc/modules.conf" "/etc/conf.modules")
1990 ;; List of set up functions to call
1993 (provide 'generic-x
)
1995 ;; arch-tag: cde692a5-9ff6-4506-9999-c67999c2bdb5
1996 ;;; generic-x.el ends here