1 ;;; generic-x.el --- A collection of generic modes
3 ;; Copyright (C) 1997-1998, 2001-2011 Free Software Foundation, Inc.
5 ;; Author: Peter Breton <pbreton@cs.umb.edu>
6 ;; Created: Tue Oct 08 1996
7 ;; Keywords: generic, comment, font-lock
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
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.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 ;; This file contains a collection of generic modes.
31 ;; Add this line to your .emacs file:
33 ;; (require 'generic-x)
35 ;; You can decide which modes to load by setting the variable
36 ;; `generic-extras-enable-list'. Its default value is platform-
37 ;; specific. The recommended way to set this variable is through
40 ;; M-x customize-option RET generic-extras-enable-list RET
42 ;; This lets you select generic modes from the list of available
43 ;; modes. If you manually set `generic-extras-enable-list' in your
44 ;; .emacs, do it BEFORE loading generic-x with (require 'generic-x).
46 ;; You can also send in new modes; if the file types are reasonably
47 ;; common, we would like to install them.
49 ;; DEFAULT GENERIC MODE:
51 ;; This file provides a hook which automatically puts a file into
52 ;; `default-generic-mode' if the first few lines of a file in
53 ;; fundamental mode start with a hash comment character. To disable
54 ;; this functionality, set the variable `generic-use-find-file-hook'
55 ;; to nil BEFORE loading generic-x. See the variables
56 ;; `generic-lines-to-scan' and `generic-find-file-regexp' for
57 ;; customization options.
59 ;; PROBLEMS WHEN USED WITH FOLDING MODE:
61 ;; [The following relates to the obsolete selective-display technique.
62 ;; Folding mode should use invisible text properties instead. -- Dave
65 ;; From Anders Lindgren <andersl@csd.uu.se>
67 ;; Problem summary: Wayne Adams has found a problem when using folding
68 ;; mode in conjunction with font-lock for a mode defined in
71 ;; The problem, as Wayne described it, was that error messages of the
72 ;; following form appeared when both font-lock and folding are used:
74 ;; > - various msgs including "Fontifying region...(error Stack
75 ;; > overflow in regexp matcher)" appear
77 ;; I have just tracked down the cause of the problem. The regexp's in
78 ;; `generic-x.el' do not take into account the way that folding hides
79 ;; sections of the buffer. The technique is known as
80 ;; `selective-display' and has been available for a very long time (I
81 ;; started using it back in the good old Emacs 18 days). Basically, a
82 ;; section is hidden by creating one very long line were the newline
83 ;; character (C-j) is replaced by a linefeed (C-m) character.
85 ;; Many other hiding packages, besides folding, use the same technique,
86 ;; the problem should occur when using them as well.
88 ;; The erroneous lines in `generic-x.el' look like the following (this
89 ;; example is from the `ini' section):
91 ;; '(("^\\(\\[.*\\]\\)" 1 'font-lock-constant-face)
92 ;; ("^\\(.*\\)=" 1 'font-lock-variable-name-face)
94 ;; The intention of these lines is to highlight lines of the following
100 ;; However, since the `.' regexp symbol matches the linefeed character
101 ;; the entire folded section is searched, resulting in a regexp stack
104 ;; Solution suggestion: Instead of using ".", use the sequence
105 ;; "[^\n\r]". This will make the rules behave just as before, but
106 ;; they will work together with selective-display.
110 (eval-when-compile (require 'font-lock
))
112 (defgroup generic-x nil
113 "A collection of generic modes."
118 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
119 ;; Default-Generic mode
120 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
122 (defcustom generic-use-find-file-hook t
123 "If non-nil, add a hook to enter `default-generic-mode' automatically.
124 This is done if the first few lines of a file in fundamental mode
125 start with a hash comment character."
129 (defcustom generic-lines-to-scan
3
130 "Number of lines that `generic-mode-find-file-hook' looks at.
131 Relevant when deciding whether to enter Default-Generic mode automatically.
132 This variable should be set to a small positive number."
136 (defcustom generic-find-file-regexp
"^#"
137 "Regular expression used by `generic-mode-find-file-hook'.
138 Files in fundamental mode whose first few lines contain a match
139 for this regexp, should be put into Default-Generic mode instead.
140 The number of lines tested for the matches is specified by the
141 value of the variable `generic-lines-to-scan', which see."
145 (defcustom generic-ignore-files-regexp
"[Tt][Aa][Gg][Ss]\\'"
146 "Regular expression used by `generic-mode-find-file-hook'.
147 Files whose names match this regular expression should not be put
148 into Default-Generic mode, even if they have lines which match
149 the regexp in `generic-find-file-regexp'. If the value is nil,
150 `generic-mode-find-file-hook' does not check the file names."
152 :type
'(choice (const :tag
"Don't check file names" nil
) regexp
))
154 ;; This generic mode is always defined
155 (define-generic-mode default-generic-mode
(list ?
#) nil nil nil nil
)
157 ;; A more general solution would allow us to enter generic-mode for
158 ;; *any* comment character, but would require us to synthesize a new
159 ;; generic-mode on the fly. I think this gives us most of what we
161 (defun generic-mode-find-file-hook ()
162 "Hook function to enter Default-Generic mode automatically.
164 Done if the first few lines of a file in Fundamental mode start
165 with a match for the regexp in `generic-find-file-regexp', unless
166 the file's name matches the regexp which is the value of the
167 variable `generic-ignore-files-regexp'.
169 This hook will be installed if the variable
170 `generic-use-find-file-hook' is non-nil. The variable
171 `generic-lines-to-scan' determines the number of lines to look at."
172 (when (and (eq major-mode
'fundamental-mode
)
173 (or (null generic-ignore-files-regexp
)
175 generic-ignore-files-regexp
176 (file-name-sans-versions buffer-file-name
)))))
178 (goto-char (point-min))
179 (when (re-search-forward generic-find-file-regexp
181 (forward-line generic-lines-to-scan
)
183 (goto-char (point-min))
184 (default-generic-mode)))))
186 (and generic-use-find-file-hook
187 (add-hook 'find-file-hook
'generic-mode-find-file-hook
))
189 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
190 ;; Other Generic modes
191 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
193 ;; If you add a generic mode to this file, put it in one of these four
196 (defconst generic-default-modes
197 '(apache-conf-generic-mode
198 apache-log-generic-mode
200 java-manifest-generic-mode
201 java-properties-generic-mode
202 javascript-generic-mode
203 show-tabs-generic-mode
205 "List of generic modes that are defined by default.")
207 (defconst generic-mswindows-modes
214 "List of generic modes that are defined by default on MS-Windows.")
216 (defconst generic-unix-modes
218 etc-fstab-generic-mode
219 etc-modules-conf-generic-mode
220 etc-passwd-generic-mode
221 etc-services-generic-mode
222 etc-sudoers-generic-mode
224 inetd-conf-generic-mode
225 mailagent-rules-generic-mode
227 named-boot-generic-mode
228 named-database-generic-mode
229 prototype-generic-mode
230 resolve-conf-generic-mode
232 x-resource-generic-mode
233 xmodmap-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."))
374 (if (memq 'xmodmap-generic-mode generic-extras-enable-list
)
375 (define-generic-mode xmodmap-generic-mode
377 '("add" "clear" "keycode" "keysym" "remove" "pointer")
379 '("[xX]modmap\\(rc\\)?\\'")
381 "Simple mode for xmodmap files."))
384 (when (memq 'hosts-generic-mode generic-extras-enable-list
)
386 (define-generic-mode hosts-generic-mode
389 '(("\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)" 1 font-lock-constant-face
))
390 '("[hH][oO][sS][tT][sS]\\'")
392 "Generic mode for HOSTS files."))
394 ;;; Windows INF files
396 ;; If i-g-m-f-f-h is defined, then so is i-g-m.
397 (declare-function ini-generic-mode
"generic-x")
399 (when (memq 'inf-generic-mode generic-extras-enable-list
)
401 (define-generic-mode inf-generic-mode
404 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face
))
405 '("\\.[iI][nN][fF]\\'")
406 '(generic-bracket-support)
407 "Generic mode for MS-Windows INF files."))
409 ;;; Windows INI files
410 ;; Should define escape character as well!
411 (when (memq 'ini-generic-mode generic-extras-enable-list
)
413 (define-generic-mode ini-generic-mode
416 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face
)
417 ("^\\([^=\n\r]*\\)=\\([^\n\r]*\\)$"
418 (1 font-lock-function-name-face
)
419 (2 font-lock-variable-name-face
)))
420 '("\\.[iI][nN][iI]\\'")
424 (setq imenu-generic-expression
425 '((nil "^\\[\\(.*\\)\\]" 1)
426 ("*Variables*" "^\\s-*\\([^=]+\\)\\s-*=" 1))))))
427 "Generic mode for MS-Windows INI files.
428 You can use `ini-generic-mode-find-file-hook' to enter this mode
429 automatically for INI files whose names do not end in \".ini\".")
431 (defun ini-generic-mode-find-file-hook ()
432 "Hook function to enter Ini-Generic mode automatically for INI files.
433 Done if the first few lines of a file in Fundamental mode look
434 like an INI file. You can add this hook to `find-file-hook'."
435 (and (eq major-mode
'fundamental-mode
)
437 (goto-char (point-min))
438 (and (looking-at "^\\s-*\\[.*\\]")
439 (ini-generic-mode)))))
440 (defalias 'generic-mode-ini-file-find-file-hook
'ini-generic-mode-find-file-hook
))
442 ;;; Windows REG files
443 ;;; Unfortunately, Windows 95 and Windows NT have different REG file syntax!
444 (when (memq 'reg-generic-mode generic-extras-enable-list
)
446 (define-generic-mode reg-generic-mode
448 '("key" "classes_root" "REGEDIT" "REGEDIT4")
449 '(("\\(\\[.*\\]\\)" 1 font-lock-constant-face
)
450 ("^\\([^\n\r]*\\)\\s-*=" 1 font-lock-variable-name-face
))
451 '("\\.[rR][eE][gG]\\'")
455 (setq imenu-generic-expression
456 '((nil "^\\s-*\\(.*\\)\\s-*=" 1))))))
457 "Generic mode for MS-Windows Registry files."))
459 (declare-function w32-shell-name
"w32-fns" ())
461 ;;; DOS/Windows BAT files
462 (when (memq 'bat-generic-mode generic-extras-enable-list
)
464 (define-generic-mode bat-generic-mode
469 ;; Make this one first in the list, otherwise comments will
470 ;; be over-written by other variables
471 '("^[@ \t]*\\([rR][eE][mM][^\n\r]*\\)" 1 font-lock-comment-face t
)
472 '("^[ \t]*\\(::.*\\)" 1 font-lock-comment-face t
)
473 '("^[@ \t]*\\([bB][rR][eE][aA][kK]\\|[vV][eE][rR][iI][fF][yY]\\)[ \t]+\\([oO]\\([nN]\\|[fF][fF]\\)\\)"
474 (1 font-lock-builtin-face
)
475 (2 font-lock-constant-face t t
))
476 ;; Any text (except ON/OFF) following ECHO is a string.
477 '("^[@ \t]*\\([eE][cC][hH][oO]\\)[ \t]+\\(\\([oO]\\([nN]\\|[fF][fF]\\)\\)\\|\\([^>|\r\n]+\\)\\)"
478 (1 font-lock-builtin-face
)
479 (3 font-lock-constant-face t t
)
480 (5 font-lock-string-face t t
))
481 ;; These keywords appear as the first word on a line. (Actually, they
482 ;; can also appear after "if ..." or "for ..." clause, but since they
483 ;; are frequently used in simple text, we punt.)
484 ;; In `generic-bat-mode-setup-function' we make the keywords
486 (generic-make-keywords-list
489 font-lock-keyword-face
"^[@ \t]*")
490 ;; These keywords can be anywhere on a line
491 ;; In `generic-bat-mode-setup-function' we make the keywords
493 (generic-make-keywords-list
499 font-lock-keyword-face
)
500 ;; These are built-in commands. Only frequently-used ones are listed.
501 (generic-make-keywords-list
502 '("CALL" "call" "Call"
510 "PAUSE" "pause" "Pause"
511 "PROMPT" "prompt" "Prompt"
515 "START" "start" "Start"
516 "SHIFT" "shift" "Shift")
517 font-lock-builtin-face
"[ \t|\n]")
518 '("^[ \t]*\\(:\\sw+\\)" 1 font-lock-function-name-face t
)
519 '("\\(%\\sw+%\\)" 1 font-lock-variable-name-face t
)
520 '("\\(%[0-9]\\)" 1 font-lock-variable-name-face t
)
521 '("[\t ]+\\([+-/][^\t\n\" ]+\\)" 1 font-lock-type-face
)
522 '("[ \t\n|]\\<\\([gG][oO][tT][oO]\\)\\>[ \t]*\\(\\sw+\\)?"
523 (1 font-lock-keyword-face
)
524 (2 font-lock-function-name-face nil t
))
525 '("[ \t\n|]\\<\\([sS][eE][tT]\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*=?"
526 (1 font-lock-builtin-face
)
527 (2 font-lock-variable-name-face t t
))))
528 '("\\.[bB][aA][tT]\\'"
530 "\\`[cC][oO][nN][fF][iI][gG]\\."
531 "\\`[aA][uU][tT][oO][eE][xX][eE][cC]\\.")
532 '(generic-bat-mode-setup-function)
533 "Generic mode for MS-Windows batch files.")
535 (defvar bat-generic-mode-syntax-table nil
536 "Syntax table in use in `bat-generic-mode' buffers.")
538 (defvar bat-generic-mode-keymap
(make-sparse-keymap)
539 "Keymap for `bat-generic-mode'.")
541 (defun bat-generic-mode-compile ()
542 "Run the current BAT file in a compilation buffer."
544 (let ((compilation-buffer-name-function
547 (concat "*" (buffer-file-name) "*")))))
549 (concat (w32-shell-name) " -c " (buffer-file-name)))))
551 (eval-when-compile (require 'comint
))
552 (defun bat-generic-mode-run-as-comint ()
553 "Run the current BAT file in a comint buffer."
556 (let* ((file (buffer-file-name))
557 (buf-name (concat "*" file
"*")))
558 (with-current-buffer (get-buffer-create buf-name
)
567 (display-buffer buf-name
))))
569 (define-key bat-generic-mode-keymap
"\C-c\C-c" 'bat-generic-mode-compile
)
571 ;; Make underscores count as words
572 (unless bat-generic-mode-syntax-table
573 (setq bat-generic-mode-syntax-table
(make-syntax-table))
574 (modify-syntax-entry ?_
"w" bat-generic-mode-syntax-table
))
576 ;; bat-generic-mode doesn't use the comment functionality of
577 ;; define-generic-mode because it has a three-letter comment-string,
578 ;; so we do it here manually instead
579 (defun generic-bat-mode-setup-function ()
580 (make-local-variable 'parse-sexp-ignore-comments
)
581 (make-local-variable 'comment-start
)
582 (make-local-variable 'comment-start-skip
)
583 (make-local-variable 'comment-end
)
584 (setq imenu-generic-expression
'((nil "^:\\(\\sw+\\)" 1))
585 parse-sexp-ignore-comments t
588 comment-start-skip
"[Rr][Ee][Mm] *")
589 (set-syntax-table bat-generic-mode-syntax-table
)
590 ;; Make keywords case-insensitive
591 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
))
592 (use-local-map bat-generic-mode-keymap
)))
595 ;; Mailagent is a Unix mail filtering program. Anyone wanna do a
596 ;; generic mode for procmail?
597 (when (memq 'mailagent-rules-generic-mode generic-extras-enable-list
)
599 (define-generic-mode mailagent-rules-generic-mode
601 '("SAVE" "DELETE" "PIPE" "ANNOTATE" "REJECT")
602 '(("^\\(\\sw+\\)\\s-*=" 1 font-lock-variable-name-face
)
603 ("\\s-/\\([^/]+\\)/[i, \t\n]" 1 font-lock-constant-face
))
608 (setq imenu-generic-expression
609 '((nil "\\s-/\\([^/]+\\)/[i, \t\n]" 1))))))
610 "Generic mode for Mailagent rules files."))
612 ;; Solaris/Sys V prototype files
613 (when (memq 'prototype-generic-mode generic-extras-enable-list
)
615 (define-generic-mode prototype-generic-mode
618 '(("^\\([0-9]\\)?\\s-*\\([a-z]\\)\\s-+\\([A-Za-z_]+\\)\\s-+\\([^\n\r]*\\)$"
619 (2 font-lock-constant-face
)
620 (3 font-lock-keyword-face
))
621 ("^\\([a-z]\\) \\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
622 (1 font-lock-constant-face
)
623 (2 font-lock-keyword-face
)
624 (3 font-lock-variable-name-face
))
625 ("^\\(!\\s-*\\(search\\|include\\|default\\)\\)\\s-*\\([^\n\r]*\\)$"
626 (1 font-lock-keyword-face
)
627 (3 font-lock-variable-name-face
))
628 ("^\\(!\\s-*\\sw+\\)=\\([^\n\r]*\\)$"
629 (1 font-lock-keyword-face
)
630 (2 font-lock-variable-name-face
)))
633 "Generic mode for Sys V prototype files."))
635 ;; Solaris/Sys V pkginfo files
636 (when (memq 'pkginfo-generic-mode generic-extras-enable-list
)
638 (define-generic-mode pkginfo-generic-mode
641 '(("^\\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
642 (1 font-lock-keyword-face
)
643 (2 font-lock-variable-name-face
)))
646 "Generic mode for Sys V pkginfo files."))
649 ;; Includes extra keywords from Armando Singer [asinger@MAIL.COLGATE.EDU]
650 (when (memq 'javascript-generic-mode generic-extras-enable-list
)
652 (define-generic-mode javascript-generic-mode
653 '("//" ("/*" .
"*/"))
676 ;; words reserved for ECMA extensions below
687 ;; Java Keywords reserved by JavaScript
714 '(("^\\s-*function\\s-+\\([A-Za-z0-9_]+\\)"
715 (1 font-lock-function-name-face
))
716 ("^\\s-*var\\s-+\\([A-Za-z0-9_]+\\)"
717 (1 font-lock-variable-name-face
)))
722 (setq imenu-generic-expression
723 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1)
724 ("*Variables*" "^var\\s-+\\([A-Za-z0-9_]+\\)" 1))))))
725 "Generic mode for JavaScript files."))
728 (when (memq 'vrml-generic-mode generic-extras-enable-list
)
730 (define-generic-mode vrml-generic-mode
760 '(("USE\\s-+\\([-A-Za-z0-9_]+\\)"
761 (1 font-lock-constant-face
))
762 ("DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
763 (1 font-lock-type-face
)
764 (2 font-lock-constant-face
))
765 ("^\\s-*\\([-A-Za-z0-9_]+\\)\\s-*{"
766 (1 font-lock-function-name-face
))
767 ("^\\s-*\\(geometry\\|appearance\\|material\\)\\s-+\\([-A-Za-z0-9_]+\\)"
768 (2 font-lock-variable-name-face
)))
773 (setq imenu-generic-expression
774 '((nil "^\\([A-Za-z0-9_]+\\)\\s-*{" 1)
776 "DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
778 "Generic Mode for VRML files."))
781 (when (memq 'java-manifest-generic-mode generic-extras-enable-list
)
783 (define-generic-mode java-manifest-generic-mode
793 '(("^Name:\\s-+\\([^\n\r]*\\)$"
794 (1 font-lock-variable-name-face
))
795 ("^\\(Manifest\\|Required\\|Signature\\)-Version:\\s-+\\([^\n\r]*\\)$"
796 (2 font-lock-constant-face
)))
797 '("[mM][aA][nN][iI][fF][eE][sS][tT]\\.[mM][fF]\\'")
799 "Generic mode for Java Manifest files."))
801 ;; Java properties files
802 (when (memq 'java-properties-generic-mode generic-extras-enable-list
)
804 (define-generic-mode java-properties-generic-mode
808 (let ((java-properties-key
809 "\\(\\([-A-Za-z0-9_\\./]\\|\\(\\\\[ =:]\\)\\)+\\)")
810 (java-properties-value
812 ;; Property and value can be separated in a number of different ways:
820 (concat "^" java-properties-key elt java-properties-value
"$")
821 '(1 font-lock-constant-face
)
822 '(4 font-lock-variable-name-face
))))
823 ;; These are the separators
824 '(":\\s-*" "\\s-+" "\\s-*=\\s-*"))))
829 (setq imenu-generic-expression
830 '((nil "^\\([^#! \t\n\r=:]+\\)" 1))))))
831 "Generic mode for Java properties files."))
833 ;; C shell alias definitions
834 (when (memq 'alias-generic-mode generic-extras-enable-list
)
836 (define-generic-mode alias-generic-mode
839 '(("^alias\\s-+\\([-A-Za-z0-9_]+\\)\\s-+"
840 (1 font-lock-variable-name-face
))
841 ("^unalias\\s-+\\([-A-Za-z0-9_]+\\)\\s-*$"
842 (1 font-lock-variable-name-face
)))
847 (setq imenu-generic-expression
848 '((nil "^\\(alias\\|unalias\\)\\s-+\\([-a-zA-Z0-9_]+\\)" 2))))))
849 "Generic mode for C Shell alias files."))
852 ;; Contributed by ACorreir@pervasive-sw.com (Alfred Correira)
853 (when (memq 'rc-generic-mode generic-extras-enable-list
)
855 (define-generic-mode rc-generic-mode
910 ;; the choice of what tokens go where is somewhat arbitrary,
911 ;; as is the choice of which value tokens are included, as
912 ;; the choice of face for each token group
915 (generic-make-keywords-list
924 (generic-make-keywords-list
929 font-lock-function-name-face
)
930 '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face
)
931 '("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face
)
932 '("^#[ \t]*\\(elif\\|if\\)\\>"
933 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil
934 (1 font-lock-constant-face
)
935 (2 font-lock-variable-name-face nil t
)))
936 '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
937 (1 font-lock-constant-face
)
938 (2 font-lock-variable-name-face nil t
))))
941 "Generic mode for MS-Windows Resource files."))
943 ;; InstallShield RUL files
944 ;; Contributed by Alfred.Correira@Pervasive.Com
945 ;; Bugfixes by "Rolf Sandau" <Rolf.Sandau@marconi.com>
946 (when (memq 'rul-generic-mode generic-extras-enable-list
)
950 ;;; build the regexp strings using regexp-opt
951 (defconst installshield-statement-keyword-list
970 ;; "goto" -- handled elsewhere
984 "Statement keywords used in InstallShield 3 and 5.")
986 (defconst installshield-system-functions-list
1006 "ComponentAddItem" ; differs between IS3 and IS5
1007 "ComponentCompareSizeRequired" ; IS5 only
1009 "ComponentError" ; IS5 only
1010 "ComponentFileEnum" ; IS5 only
1011 "ComponentFileInfo" ; IS5 only
1012 "ComponentFilterLanguage" ; IS5 only
1013 "ComponentFilterOS" ; IS5 only
1014 "ComponentGetData" ; IS5 only
1015 "ComponentGetItemInfo" ; IS3 only
1016 "ComponentGetItemSize" ; differs between IS3 and IS5
1017 "ComponentIsItemSelected" ; differs between IS3 and IS5
1018 "ComponentListItems"
1019 "ComponentMoveData" ; IS5 only
1020 "ComponentSelectItem" ; differs between IS3 and IS5
1021 "ComponentSetData" ; IS5 only
1022 "ComponentSetItemInfo" ; IS3 only
1023 "ComponentSetTarget" ; IS5 only
1024 "ComponentSetupTypeEnum" ; IS5 only
1025 "ComponentSetupTypeGetData" ; IS5 only
1026 "ComponentSetupTypeSet" ; IS5 only
1027 "ComponentTotalSize"
1028 "ComponentValidate" ; IS5 only
1029 "CompressAdd" ; IS3 only
1030 "CompressDel" ; IS3 only
1031 "CompressEnum" ; IS3 only
1032 "CompressGet" ; IS3 only
1033 "CompressInfo" ; IS3 only
1037 "CreateProgramFolder"
1038 "DeinstallSetReference" ; IS5 only
1064 "FileSetBeginDefine" ; IS3 only
1065 "FileSetEndDefine" ; IS3 only
1066 "FileSetPerformEz" ; IS3 only
1067 "FileSetPerform" ; IS3 only
1068 "FileSetReset" ; IS3 only
1069 "FileSetRoot" ; IS3 only
1083 "GetValidDrivesList"
1098 "ListGetFirstString"
1102 "ListSetCurrentItem"
1108 "LongPathToShortPath"
1123 "PlayMMedia" ; IS5 only
1130 "RegDBGetKeyValueEx"
1131 "RegDBSetKeyValueEx"
1132 "RegDBSetDefaultRoot"
1141 "SdComponentAdvCheckSpace"
1142 "SdComponentAdvInit"
1143 "SdComponentAdvUpdateSpace"
1145 "SdComponentDialog2"
1146 "SdComponentDialogAdv"
1147 "SdComponentDialogEx"
1148 "SdComponentDlgCheckSpace"
1151 "SdConfirmRegistration"
1163 "SdGetUserCompanyInfo"
1172 "SdOptionsButtonsInit"
1173 "SdPlugInProductName"
1176 "SdRegExEnableButton"
1181 "SdSetSequentialItems"
1183 "SdSetupTypeEx" ; IS5 only
1194 "SdUpdateComponentSelection"
1200 "SetDisplayEffect" ; IS5 only
1202 "SetForegroundWindow"
1215 "StrRemoveLastSlash"
1229 "System functions defined in InstallShield 3 and 5.")
1231 (defconst installshield-system-variables-list
1235 "CORECOMPONENTHANDLING"
1261 "System variables used in InstallShield 3 and 5.")
1263 (defconst installshield-types-list
1282 "Type keywords used in InstallShield 3 and 5.")
1284 ;;; some might want to skip highlighting these to improve performance
1285 (defconst installshield-funarg-constants-list
1315 "COMP_UPDATE_VERSION"
1334 "DLG_INFO_CHECKSELECTION"
1336 "DLG_INFO_USEDECIMAL"
1337 "DLG_MSG_INFORMATION"
1358 "FILE_ATTR_ARCHIVED"
1359 "FILE_ATTR_DIRECTORY"
1362 "FILE_ATTR_READONLY"
1368 "FILE_MODE_BINARYREADONLY"
1390 "HKEY_LOCAL_MACHINE"
1435 "REGDB_APPPATH_DEFAULT"
1438 "REGDB_ERR_CONNECTIONEXISTS"
1439 "REGDB_ERR_CORRUPTEDREGSITRY"
1440 "REGDB_ERR_INITIALIZATION"
1441 "REGDB_ERR_INVALIDHANDLE"
1442 "REGDB_ERR_INVALIDNAME"
1444 "REGDB_STRING_EXPAND"
1445 "REGDB_STRING_MULTI"
1447 "REGDB_UNINSTALL_NAME"
1491 "Function argument constants used in InstallShield 3 and 5."))
1493 (defvar rul-generic-mode-syntax-table nil
1494 "Syntax table to use in `rul-generic-mode' buffers.")
1496 (setq rul-generic-mode-syntax-table
1497 (make-syntax-table c
++-mode-syntax-table
))
1499 (modify-syntax-entry ?
\r "> b" rul-generic-mode-syntax-table
)
1500 (modify-syntax-entry ?
\n "> b" rul-generic-mode-syntax-table
)
1502 (modify-syntax-entry ?
/ ". 124b" rul-generic-mode-syntax-table
)
1503 (modify-syntax-entry ?
* ". 23" rul-generic-mode-syntax-table
)
1505 ;; here manually instead
1506 (defun generic-rul-mode-setup-function ()
1507 (make-local-variable 'parse-sexp-ignore-comments
)
1508 (make-local-variable 'comment-start
)
1509 (make-local-variable 'comment-start-skip
)
1510 (make-local-variable 'comment-end
)
1511 (setq imenu-generic-expression
1512 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1))
1513 parse-sexp-ignore-comments t
1517 ;;; comment-start "//"
1518 ;;; comment-start-skip ""
1520 ;; (set-syntax-table rul-generic-mode-syntax-table)
1521 (setq font-lock-syntax-table rul-generic-mode-syntax-table
))
1523 ;; moved mode-definition behind defun-definition to be warning-free - 15.11.02/RSan
1524 (define-generic-mode rul-generic-mode
1525 ;; Using "/*" and "*/" doesn't seem to be working right
1526 '("//" ("/*" .
"*/" ))
1527 (eval-when-compile installshield-statement-keyword-list
)
1530 ;; preprocessor constructs
1531 '("#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)"
1532 1 font-lock-string-face
)
1533 '("#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
1534 (1 font-lock-reference-face
)
1535 (2 font-lock-variable-name-face nil t
))
1536 ;; indirect string constants
1537 '("\\(@[A-Za-z][A-Za-z0-9_]+\\)" 1 font-lock-builtin-face
)
1539 '("[ \t]*\\(\\sw+:\\)" 1 font-lock-reference-face
)
1540 '("\\<\\(goto\\)\\>[ \t]*\\(\\sw+\\)?"
1541 (1 font-lock-keyword-face
)
1542 (2 font-lock-reference-face nil t
))
1544 (generic-make-keywords-list
1545 installshield-system-variables-list
1546 font-lock-variable-name-face
"[^_]" "[^_]")
1548 (generic-make-keywords-list
1549 installshield-system-functions-list
1550 font-lock-function-name-face
"[^_]" "[^_]")
1552 (generic-make-keywords-list
1553 installshield-types-list
1554 font-lock-type-face
"[^_]" "[^_]")
1555 ;; function argument constants
1556 (generic-make-keywords-list
1557 installshield-funarg-constants-list
1558 font-lock-variable-name-face
"[^_]" "[^_]"))) ; is this face the best choice?
1559 '("\\.[rR][uU][lL]\\'")
1560 '(generic-rul-mode-setup-function)
1561 "Generic mode for InstallShield RUL files.")
1563 (define-skeleton rul-if
1564 "Insert an if statement."
1566 "if(" str
") then" \n
1568 ( "other condition, %s: "
1569 > "elseif(" str
") then" \n
1576 (define-skeleton rul-function
1577 "Insert a function statement."
1579 "function " str
" ()" \n
1580 ( "local variables, %s: "
1587 ;; Additions by ACorreir@pervasive-sw.com (Alfred Correira)
1588 (when (memq 'mailrc-generic-mode generic-extras-enable-list
)
1590 (define-generic-mode mailrc-generic-mode
1601 '(("^\\s-*\\(alias\\|group\\)\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1602 (2 font-lock-constant-face
)
1603 (3 font-lock-variable-name-face
))
1604 ("^\\s-*\\(unset\\|set\\|ignore\\)\\s-+\\([-A-Za-z0-9_]+\\)=?\\([^\n\r#]*\\)\\(#.*\\)?$"
1605 (2 font-lock-constant-face
)
1606 (3 font-lock-variable-name-face
))
1607 ("^\\s-*\\(source\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1608 (2 font-lock-variable-name-face
)))
1611 "Mode for mailrc files."))
1614 (when (memq 'inetd-conf-generic-mode generic-extras-enable-list
)
1616 (define-generic-mode inetd-conf-generic-mode
1625 '(("^\\([-A-Za-z0-9_]+\\)" 1 font-lock-type-face
))
1626 '("/etc/inetd.conf\\'")
1630 (setq imenu-generic-expression
1631 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1634 (when (memq 'etc-services-generic-mode generic-extras-enable-list
)
1636 (define-generic-mode etc-services-generic-mode
1641 '(("^\\([-A-Za-z0-9_]+\\)\\s-+\\([0-9]+\\)/"
1642 (1 font-lock-type-face
)
1643 (2 font-lock-variable-name-face
)))
1644 '("/etc/services\\'")
1648 (setq imenu-generic-expression
1649 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1651 ;; Password and Group files
1652 (when (memq 'etc-passwd-generic-mode generic-extras-enable-list
)
1654 (define-generic-mode etc-passwd-generic-mode
1655 nil
;; No comment characters
1656 '("root") ;; Only one keyword
1662 ;; User name -- Never blank!
1665 ;; Password, UID and GID
1668 (make-list 3 "\\([^:]+\\)")
1671 ;; GECOS/Name -- might be blank
1674 ;; Home directory and shell
1679 '(1 font-lock-type-face
)
1680 '(5 font-lock-variable-name-face
)
1681 '(6 font-lock-constant-face
)
1682 '(7 font-lock-warning-face
))
1683 '("^\\([^:]+\\):\\([^:]*\\):\\([0-9]+\\):\\(.*\\)$"
1684 (1 font-lock-type-face
)
1685 (4 font-lock-variable-name-face
))))
1686 '("/etc/passwd\\'" "/etc/group\\'")
1690 (setq imenu-generic-expression
1691 '((nil "^\\([-A-Za-z0-9_]+\\):" 1))))))))
1694 (when (memq 'etc-fstab-generic-mode generic-extras-enable-list
)
1696 (define-generic-mode etc-fstab-generic-mode
1737 '(("^\\([^# \t]+\\)\\s-+\\([^# \t]+\\)"
1738 (1 font-lock-type-face t
)
1739 (2 font-lock-variable-name-face t
)))
1740 '("/etc/[v]*fstab\\'")
1744 (setq imenu-generic-expression
1745 '((nil "^\\([^# \t]+\\)\\s-+" 1))))))))
1748 (when (memq 'etc-sudoers-generic-mode generic-extras-enable-list
)
1750 (define-generic-mode etc-sudoers-generic-mode
1752 '("User_Alias" "Runas_Alias" "Host_Alias" "Cmnd_Alias"
1753 "NOPASSWD" "PASSWD" "NOEXEC" "EXEC"
1755 '(("\\<\\(root\\|su\\)\\>" 1 font-lock-warning-face
)
1756 ("\\(\\*\\)" 1 font-lock-warning-face
)
1757 ("\\<\\(%[A-Za-z0-9_]+\\)\\>" 1 font-lock-variable-name-face
))
1758 '("/etc/sudoers\\'")
1760 "Generic mode for sudoers configuration files."))
1762 ;; From Jacques Duthen <jacques.duthen@sncf.fr>
1763 (when (memq 'show-tabs-generic-mode generic-extras-enable-list
)
1767 (defconst show-tabs-generic-mode-font-lock-defaults-1
1768 '(;; trailing spaces must come before...
1769 ("[ \t]+$" .
'show-tabs-space
)
1771 ("[^\n\t]\\(\t+\\)" (1 'show-tabs-tab
))))
1773 (defconst show-tabs-generic-mode-font-lock-defaults-2
1774 '(;; trailing spaces must come before...
1775 ("[ \t]+$" .
'show-tabs-space
)
1777 ("\t+" .
'show-tabs-tab
))))
1779 (defface show-tabs-tab
1780 '((((class grayscale
) (background light
)) (:background
"DimGray" :weight bold
))
1781 (((class grayscale
) (background dark
)) (:background
"LightGray" :weight bold
))
1782 (((class color
) (min-colors 88)) (:background
"red1"))
1783 (((class color
)) (:background
"red"))
1785 "Font Lock mode face used to highlight TABs."
1787 (define-obsolete-face-alias 'show-tabs-tab-face
'show-tabs-tab
"22.1")
1789 (defface show-tabs-space
1790 '((((class grayscale
) (background light
)) (:background
"DimGray" :weight bold
))
1791 (((class grayscale
) (background dark
)) (:background
"LightGray" :weight bold
))
1792 (((class color
) (min-colors 88)) (:background
"yellow1"))
1793 (((class color
)) (:background
"yellow"))
1795 "Font Lock mode face used to highlight spaces."
1797 (define-obsolete-face-alias 'show-tabs-space-face
'show-tabs-space
"22.1")
1799 (define-generic-mode show-tabs-generic-mode
1800 nil
;; no comment char
1802 (eval-when-compile show-tabs-generic-mode-font-lock-defaults-1
)
1803 nil
;; no auto-mode-alist
1804 ;; '(show-tabs-generic-mode-hook-fun)
1806 "Generic mode to show tabs and trailing spaces."))
1808 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1810 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1812 (when (memq 'named-boot-generic-mode generic-extras-enable-list
)
1814 (define-generic-mode named-boot-generic-mode
1815 ;; List of comment characters
1818 '("cache" "primary" "secondary" "forwarders" "limit" "options"
1819 "directory" "check-names")
1820 ;; List of additional font-lock-expressions
1821 '(("\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)" 1 font-lock-constant-face
)
1822 ("^directory\\s-+\\(.*\\)" 1 font-lock-variable-name-face
)
1823 ("^\\(primary\\|cache\\)\\s-+\\([.A-Za-z]+\\)\\s-+\\(.*\\)"
1824 (2 font-lock-variable-name-face
)
1825 (3 font-lock-constant-face
)))
1826 ;; List of additional automode-alist expressions
1827 '("/etc/named.boot\\'")
1828 ;; List of set up functions to call
1831 (when (memq 'named-database-generic-mode generic-extras-enable-list
)
1833 (define-generic-mode named-database-generic-mode
1834 ;; List of comment characters
1837 '("IN" "NS" "CNAME" "SOA" "PTR" "MX" "A")
1838 ;; List of additional font-lock-expressions
1839 '(("\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)" 1 font-lock-constant-face
)
1840 ("^\\([.A-Za-z0-9]+\\)" 1 font-lock-variable-name-face
))
1841 ;; List of additional auto-mode-alist expressions
1843 ;; List of set up functions to call
1846 (defvar named-database-time-string
"%Y%m%d%H"
1847 "Timestring for named serial numbers.")
1849 (defun named-database-print-serial ()
1850 "Print a serial number based on the current date."
1852 (insert (format-time-string named-database-time-string
(current-time)))))
1854 (when (memq 'resolve-conf-generic-mode generic-extras-enable-list
)
1856 (define-generic-mode resolve-conf-generic-mode
1857 ;; List of comment characters
1860 '("nameserver" "domain" "search" "sortlist" "options")
1861 ;; List of additional font-lock-expressions
1863 ;; List of additional auto-mode-alist expressions
1864 '("/etc/resolv[e]?.conf\\'")
1865 ;; List of set up functions to call
1868 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1869 ;; Modes for spice and common electrical engineering circuit netlist formats
1870 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1872 (when (memq 'spice-generic-mode generic-extras-enable-list
)
1874 (define-generic-mode spice-generic-mode
1891 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1892 (" \\(\\$ .*\\)$" 1 font-lock-comment-face
)
1893 ("^\\(\\$ .*\\)$" 1 font-lock-comment-face
)
1894 ("\\([*].*\\)" 1 font-lock-comment-face
)
1895 ("^\\([+]\\)" 1 font-lock-string-face
)
1896 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face
)
1897 ("\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
)
1898 ("\\('[^']+'\\)" 1 font-lock-string-face
)
1899 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face
))
1901 "\\.[sS][pP][iI]\\'"
1902 "\\.[sS][pP][iI][cC][eE]\\'"
1903 "\\.[iI][nN][cC]\\'")
1905 'generic-bracket-support
1906 ;; Make keywords case-insensitive
1909 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
)))))
1910 "Generic mode for SPICE circuit netlist files."))
1912 (when (memq 'ibis-generic-mode generic-extras-enable-list
)
1914 (define-generic-mode ibis-generic-mode
1917 '(("[[]\\([^]]*\\)[]]" 1 font-lock-keyword-face
)
1918 ("\\(\\(_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
))
1919 '("\\.[iI][bB][sS]\\'")
1920 '(generic-bracket-support)
1921 "Generic mode for IBIS circuit netlist files."))
1923 (when (memq 'astap-generic-mode generic-extras-enable-list
)
1925 (define-generic-mode astap-generic-mode
1940 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1941 (";\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1942 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face
)
1943 ("\\('[^']+'\\)" 1 font-lock-string-face
)
1944 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face
)
1945 ("[(,]\\s-*\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
))
1947 "\\.[aA][sS][xX]\\'"
1948 "\\.[aA][sS][tT][aA][pP]\\'"
1949 "\\.[pP][sS][pP]\\'"
1950 "\\.[dD][eE][cC][kK]\\'"
1951 "\\.[gG][oO][dD][aA][tT][aA]")
1953 'generic-bracket-support
1954 ;; Make keywords case-insensitive
1957 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
)))))
1958 "Generic mode for ASTAP circuit netlist files."))
1960 (when (memq 'etc-modules-conf-generic-mode generic-extras-enable-list
)
1962 (define-generic-mode etc-modules-conf-generic-mode
1963 ;; List of comment characters
1981 "generic_stringfile"
1997 ;; List of additional font-lock-expressions
1999 ;; List of additional automode-alist expressions
2000 '("/etc/modules.conf" "/etc/conf.modules")
2001 ;; List of set up functions to call
2004 (provide 'generic-x
)
2006 ;;; generic-x.el ends here