1 ;;; generic-x.el --- A collection of generic modes
3 ;; Copyright (C) 1997, 1998, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
6 ;; Author: Peter Breton <pbreton@cs.umb.edu>
7 ;; Created: Tue Oct 08 1996
8 ;; 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 "List of generic modes that are defined by default on Unix.")
235 (defconst generic-other-modes
240 "List of generic modes that are not defined by default.")
242 (defcustom generic-define-mswindows-modes
243 (memq system-type
'(windows-nt ms-dos
))
244 "Non-nil means the modes in `generic-mswindows-modes' will be defined.
245 This is a list of MS-Windows specific generic modes. This variable
246 only affects the default value of `generic-extras-enable-list'."
250 (make-obsolete-variable 'generic-define-mswindows-modes
'generic-extras-enable-list
"22.1")
252 (defcustom generic-define-unix-modes
253 (not (memq system-type
'(windows-nt ms-dos
)))
254 "Non-nil means the modes in `generic-unix-modes' will be defined.
255 This is a list of Unix specific generic modes. This variable only
256 affects the default value of `generic-extras-enable-list'."
260 (make-obsolete-variable 'generic-define-unix-modes
'generic-extras-enable-list
"22.1")
262 (defcustom generic-extras-enable-list
263 (append generic-default-modes
264 (if generic-define-mswindows-modes generic-mswindows-modes
)
265 (if generic-define-unix-modes generic-unix-modes
)
267 "List of generic modes to define.
268 Each entry in the list should be a symbol. If you set this variable
269 directly, without using customize, you must reload generic-x to put
270 your changes into effect."
274 (sort (append generic-default-modes
275 generic-mswindows-modes
280 (string< (symbol-name b
)
283 (push `(const ,mode
) list
)))
286 (unless load-in-progress
291 (when (memq 'apache-conf-generic-mode generic-extras-enable-list
)
293 (define-generic-mode apache-conf-generic-mode
296 '(("^\\s-*\\(<.*>\\)" 1 font-lock-constant-face
)
297 ("^\\s-*\\(\\sw+\\)\\s-" 1 font-lock-variable-name-face
))
298 '("srm\\.conf\\'" "httpd\\.conf\\'" "access\\.conf\\'")
302 (setq imenu-generic-expression
303 '((nil "^\\([-A-Za-z0-9_]+\\)" 1)
304 ("*Directories*" "^\\s-*<Directory\\s-*\\([^>]+\\)>" 1)
305 ("*Locations*" "^\\s-*<Location\\s-*\\([^>]+\\)>" 1))))))
306 "Generic mode for Apache or HTTPD configuration files."))
308 (when (memq 'apache-log-generic-mode generic-extras-enable-list
)
310 (define-generic-mode apache-log-generic-mode
313 ;; Hostname ? user date request return-code number-of-bytes
314 '(("^\\([-a-zA-z0-9.]+\\) - [-A-Za-z]+ \\(\\[.*\\]\\)"
315 (1 font-lock-constant-face
)
316 (2 font-lock-variable-name-face
)))
319 "Generic mode for Apache log files."))
322 (when (memq 'samba-generic-mode generic-extras-enable-list
)
324 (define-generic-mode samba-generic-mode
327 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face
)
328 ("^\\s-*\\(.+\\)=\\([^\r\n]*\\)"
329 (1 font-lock-variable-name-face
)
330 (2 font-lock-type-face
)))
332 '(generic-bracket-support)
333 "Generic mode for Samba configuration files."))
336 ;; This is pretty basic. Also, modes for other window managers could
337 ;; be defined as well.
338 (when (memq 'fvwm-generic-mode generic-extras-enable-list
)
340 (define-generic-mode fvwm-generic-mode
356 '("\\.fvwmrc\\'" "\\.fvwm2rc\\'")
358 "Generic mode for FVWM configuration files."))
361 ;; I'm pretty sure I've seen an actual mode to do this, but I don't
362 ;; think it's standard with Emacs
363 (when (memq 'x-resource-generic-mode generic-extras-enable-list
)
365 (define-generic-mode x-resource-generic-mode
368 '(("^\\([^:\n]+:\\)" 1 font-lock-variable-name-face
))
369 '("\\.Xdefaults\\'" "\\.Xresources\\'" "\\.Xenvironment\\'" "\\.ad\\'")
371 "Generic mode for X Resource configuration files."))
374 (when (memq 'hosts-generic-mode generic-extras-enable-list
)
376 (define-generic-mode hosts-generic-mode
379 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face
))
380 '("[hH][oO][sS][tT][sS]\\'")
382 "Generic mode for HOSTS files."))
384 ;;; Windows INF files
386 ;; If i-g-m-f-f-h is defined, then so is i-g-m.
387 (declare-function ini-generic-mode
"generic-x")
389 (when (memq 'inf-generic-mode generic-extras-enable-list
)
391 (define-generic-mode inf-generic-mode
394 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face
))
395 '("\\.[iI][nN][fF]\\'")
396 '(generic-bracket-support)
397 "Generic mode for MS-Windows INF files."))
399 ;;; Windows INI files
400 ;; Should define escape character as well!
401 (when (memq 'ini-generic-mode generic-extras-enable-list
)
403 (define-generic-mode ini-generic-mode
406 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face
)
407 ("^\\([^=\n\r]*\\)=\\([^\n\r]*\\)$"
408 (1 font-lock-function-name-face
)
409 (2 font-lock-variable-name-face
)))
410 '("\\.[iI][nN][iI]\\'")
414 (setq imenu-generic-expression
415 '((nil "^\\[\\(.*\\)\\]" 1)
416 ("*Variables*" "^\\s-*\\([^=]+\\)\\s-*=" 1))))))
417 "Generic mode for MS-Windows INI files.
418 You can use `ini-generic-mode-find-file-hook' to enter this mode
419 automatically for INI files whose names do not end in \".ini\".")
421 (defun ini-generic-mode-find-file-hook ()
422 "Hook function to enter Ini-Generic mode automatically for INI files.
423 Done if the first few lines of a file in Fundamental mode look
424 like an INI file. You can add this hook to `find-file-hook'."
425 (and (eq major-mode
'fundamental-mode
)
427 (goto-char (point-min))
428 (and (looking-at "^\\s-*\\[.*\\]")
429 (ini-generic-mode)))))
430 (defalias 'generic-mode-ini-file-find-file-hook
'ini-generic-mode-find-file-hook
))
432 ;;; Windows REG files
433 ;;; Unfortunately, Windows 95 and Windows NT have different REG file syntax!
434 (when (memq 'reg-generic-mode generic-extras-enable-list
)
436 (define-generic-mode reg-generic-mode
438 '("key" "classes_root" "REGEDIT" "REGEDIT4")
439 '(("\\(\\[.*\\]\\)" 1 font-lock-constant-face
)
440 ("^\\([^\n\r]*\\)\\s-*=" 1 font-lock-variable-name-face
))
441 '("\\.[rR][eE][gG]\\'")
445 (setq imenu-generic-expression
446 '((nil "^\\s-*\\(.*\\)\\s-*=" 1))))))
447 "Generic mode for MS-Windows Registry files."))
449 (declare-function w32-shell-name
"w32-fns" ())
451 ;;; DOS/Windows BAT files
452 (when (memq 'bat-generic-mode generic-extras-enable-list
)
454 (define-generic-mode bat-generic-mode
459 ;; Make this one first in the list, otherwise comments will
460 ;; be over-written by other variables
461 '("^[@ \t]*\\([rR][eE][mM][^\n\r]*\\)" 1 font-lock-comment-face t
)
462 '("^[ \t]*\\(::.*\\)" 1 font-lock-comment-face t
)
463 '("^[@ \t]*\\([bB][rR][eE][aA][kK]\\|[vV][eE][rR][iI][fF][yY]\\)[ \t]+\\([oO]\\([nN]\\|[fF][fF]\\)\\)"
464 (1 font-lock-builtin-face
)
465 (2 font-lock-constant-face t t
))
466 ;; Any text (except ON/OFF) following ECHO is a string.
467 '("^[@ \t]*\\([eE][cC][hH][oO]\\)[ \t]+\\(\\([oO]\\([nN]\\|[fF][fF]\\)\\)\\|\\([^>|\r\n]+\\)\\)"
468 (1 font-lock-builtin-face
)
469 (3 font-lock-constant-face t t
)
470 (5 font-lock-string-face t t
))
471 ;; These keywords appear as the first word on a line. (Actually, they
472 ;; can also appear after "if ..." or "for ..." clause, but since they
473 ;; are frequently used in simple text, we punt.)
474 ;; In `generic-bat-mode-setup-function' we make the keywords
476 (generic-make-keywords-list
479 font-lock-keyword-face
"^[@ \t]*")
480 ;; These keywords can be anywhere on a line
481 ;; In `generic-bat-mode-setup-function' we make the keywords
483 (generic-make-keywords-list
489 font-lock-keyword-face
)
490 ;; These are built-in commands. Only frequently-used ones are listed.
491 (generic-make-keywords-list
492 '("CALL" "call" "Call"
500 "PAUSE" "pause" "Pause"
501 "PROMPT" "prompt" "Prompt"
505 "START" "start" "Start"
506 "SHIFT" "shift" "Shift")
507 font-lock-builtin-face
"[ \t|\n]")
508 '("^[ \t]*\\(:\\sw+\\)" 1 font-lock-function-name-face t
)
509 '("\\(%\\sw+%\\)" 1 font-lock-variable-name-face t
)
510 '("\\(%[0-9]\\)" 1 font-lock-variable-name-face t
)
511 '("\\(/[^/ \"\t\n]+\\)" 1 font-lock-type-face
)
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
"*")))
551 (get-buffer-create buf-name
))
560 (display-buffer buf-name
))))
562 (define-key bat-generic-mode-keymap
"\C-c\C-c" 'bat-generic-mode-compile
)
564 ;; Make underscores count as words
565 (unless bat-generic-mode-syntax-table
566 (setq bat-generic-mode-syntax-table
(make-syntax-table))
567 (modify-syntax-entry ?_
"w" bat-generic-mode-syntax-table
))
569 ;; bat-generic-mode doesn't use the comment functionality of
570 ;; define-generic-mode because it has a three-letter comment-string,
571 ;; so we do it here manually instead
572 (defun generic-bat-mode-setup-function ()
573 (make-local-variable 'parse-sexp-ignore-comments
)
574 (make-local-variable 'comment-start
)
575 (make-local-variable 'comment-start-skip
)
576 (make-local-variable 'comment-end
)
577 (setq imenu-generic-expression
'((nil "^:\\(\\sw+\\)" 1))
578 parse-sexp-ignore-comments t
581 comment-start-skip
"[Rr][Ee][Mm] *")
582 (set-syntax-table bat-generic-mode-syntax-table
)
583 ;; Make keywords case-insensitive
584 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
))
585 (use-local-map bat-generic-mode-keymap
)))
588 ;; Mailagent is a Unix mail filtering program. Anyone wanna do a
589 ;; generic mode for procmail?
590 (when (memq 'mailagent-rules-generic-mode generic-extras-enable-list
)
592 (define-generic-mode mailagent-rules-generic-mode
594 '("SAVE" "DELETE" "PIPE" "ANNOTATE" "REJECT")
595 '(("^\\(\\sw+\\)\\s-*=" 1 font-lock-variable-name-face
)
596 ("\\s-/\\([^/]+\\)/[i, \t\n]" 1 font-lock-constant-face
))
601 (setq imenu-generic-expression
602 '((nil "\\s-/\\([^/]+\\)/[i, \t\n]" 1))))))
603 "Generic mode for Mailagent rules files."))
605 ;; Solaris/Sys V prototype files
606 (when (memq 'prototype-generic-mode generic-extras-enable-list
)
608 (define-generic-mode prototype-generic-mode
611 '(("^\\([0-9]\\)?\\s-*\\([a-z]\\)\\s-+\\([A-Za-z_]+\\)\\s-+\\([^\n\r]*\\)$"
612 (2 font-lock-constant-face
)
613 (3 font-lock-keyword-face
))
614 ("^\\([a-z]\\) \\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
615 (1 font-lock-constant-face
)
616 (2 font-lock-keyword-face
)
617 (3 font-lock-variable-name-face
))
618 ("^\\(!\\s-*\\(search\\|include\\|default\\)\\)\\s-*\\([^\n\r]*\\)$"
619 (1 font-lock-keyword-face
)
620 (3 font-lock-variable-name-face
))
621 ("^\\(!\\s-*\\sw+\\)=\\([^\n\r]*\\)$"
622 (1 font-lock-keyword-face
)
623 (2 font-lock-variable-name-face
)))
626 "Generic mode for Sys V prototype files."))
628 ;; Solaris/Sys V pkginfo files
629 (when (memq 'pkginfo-generic-mode generic-extras-enable-list
)
631 (define-generic-mode pkginfo-generic-mode
634 '(("^\\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
635 (1 font-lock-keyword-face
)
636 (2 font-lock-variable-name-face
)))
639 "Generic mode for Sys V pkginfo files."))
642 ;; Includes extra keywords from Armando Singer [asinger@MAIL.COLGATE.EDU]
643 (when (memq 'javascript-generic-mode generic-extras-enable-list
)
645 (define-generic-mode javascript-generic-mode
646 '("//" ("/*" .
"*/"))
669 ;; words reserved for ECMA extensions below
680 ;; Java Keywords reserved by JavaScript
707 '(("^\\s-*function\\s-+\\([A-Za-z0-9_]+\\)"
708 (1 font-lock-function-name-face
))
709 ("^\\s-*var\\s-+\\([A-Za-z0-9_]+\\)"
710 (1 font-lock-variable-name-face
)))
715 (setq imenu-generic-expression
716 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1)
717 ("*Variables*" "^var\\s-+\\([A-Za-z0-9_]+\\)" 1))))))
718 "Generic mode for JavaScript files."))
721 (when (memq 'vrml-generic-mode generic-extras-enable-list
)
723 (define-generic-mode vrml-generic-mode
753 '(("USE\\s-+\\([-A-Za-z0-9_]+\\)"
754 (1 font-lock-constant-face
))
755 ("DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
756 (1 font-lock-type-face
)
757 (2 font-lock-constant-face
))
758 ("^\\s-*\\([-A-Za-z0-9_]+\\)\\s-*{"
759 (1 font-lock-function-name-face
))
760 ("^\\s-*\\(geometry\\|appearance\\|material\\)\\s-+\\([-A-Za-z0-9_]+\\)"
761 (2 font-lock-variable-name-face
)))
766 (setq imenu-generic-expression
767 '((nil "^\\([A-Za-z0-9_]+\\)\\s-*{" 1)
769 "DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
771 "Generic Mode for VRML files."))
774 (when (memq 'java-manifest-generic-mode generic-extras-enable-list
)
776 (define-generic-mode java-manifest-generic-mode
786 '(("^Name:\\s-+\\([^\n\r]*\\)$"
787 (1 font-lock-variable-name-face
))
788 ("^\\(Manifest\\|Required\\|Signature\\)-Version:\\s-+\\([^\n\r]*\\)$"
789 (2 font-lock-constant-face
)))
790 '("[mM][aA][nN][iI][fF][eE][sS][tT]\\.[mM][fF]\\'")
792 "Generic mode for Java Manifest files."))
794 ;; Java properties files
795 (when (memq 'java-properties-generic-mode generic-extras-enable-list
)
797 (define-generic-mode java-properties-generic-mode
801 (let ((java-properties-key
802 "\\(\\([-A-Za-z0-9_\\./]\\|\\(\\\\[ =:]\\)\\)+\\)")
803 (java-properties-value
805 ;; Property and value can be separated in a number of different ways:
813 (concat "^" java-properties-key elt java-properties-value
"$")
814 '(1 font-lock-constant-face
)
815 '(4 font-lock-variable-name-face
))))
816 ;; These are the separators
817 '(":\\s-*" "\\s-+" "\\s-*=\\s-*"))))
822 (setq imenu-generic-expression
823 '((nil "^\\([^#! \t\n\r=:]+\\)" 1))))))
824 "Generic mode for Java properties files."))
826 ;; C shell alias definitions
827 (when (memq 'alias-generic-mode generic-extras-enable-list
)
829 (define-generic-mode alias-generic-mode
832 '(("^alias\\s-+\\([-A-Za-z0-9_]+\\)\\s-+"
833 (1 font-lock-variable-name-face
))
834 ("^unalias\\s-+\\([-A-Za-z0-9_]+\\)\\s-*$"
835 (1 font-lock-variable-name-face
)))
840 (setq imenu-generic-expression
841 '((nil "^\\(alias\\|unalias\\)\\s-+\\([-a-zA-Z0-9_]+\\)" 2))))))
842 "Generic mode for C Shell alias files."))
845 ;; Contributed by ACorreir@pervasive-sw.com (Alfred Correira)
846 (when (memq 'rc-generic-mode generic-extras-enable-list
)
848 (define-generic-mode rc-generic-mode
903 ;; the choice of what tokens go where is somewhat arbitrary,
904 ;; as is the choice of which value tokens are included, as
905 ;; the choice of face for each token group
908 (generic-make-keywords-list
917 (generic-make-keywords-list
922 font-lock-function-name-face
)
923 '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face
)
924 '("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face
)
925 '("^#[ \t]*\\(elif\\|if\\)\\>"
926 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil
927 (1 font-lock-constant-face
)
928 (2 font-lock-variable-name-face nil t
)))
929 '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
930 (1 font-lock-constant-face
)
931 (2 font-lock-variable-name-face nil t
))))
934 "Generic mode for MS-Windows Resource files."))
936 ;; InstallShield RUL files
937 ;; Contributed by Alfred.Correira@Pervasive.Com
938 ;; Bugfixes by "Rolf Sandau" <Rolf.Sandau@marconi.com>
939 (when (memq 'rul-generic-mode generic-extras-enable-list
)
943 ;;; build the regexp strings using regexp-opt
944 (defconst installshield-statement-keyword-list
963 ;; "goto" -- handled elsewhere
977 "Statement keywords used in InstallShield 3 and 5.")
979 (defconst installshield-system-functions-list
999 "ComponentAddItem" ; differs between IS3 and IS5
1000 "ComponentCompareSizeRequired" ; IS5 only
1002 "ComponentError" ; IS5 only
1003 "ComponentFileEnum" ; IS5 only
1004 "ComponentFileInfo" ; IS5 only
1005 "ComponentFilterLanguage" ; IS5 only
1006 "ComponentFilterOS" ; IS5 only
1007 "ComponentGetData" ; IS5 only
1008 "ComponentGetItemInfo" ; IS3 only
1009 "ComponentGetItemSize" ; differs between IS3 and IS5
1010 "ComponentIsItemSelected" ; differs between IS3 and IS5
1011 "ComponentListItems"
1012 "ComponentMoveData" ; IS5 only
1013 "ComponentSelectItem" ; differs between IS3 and IS5
1014 "ComponentSetData" ; IS5 only
1015 "ComponentSetItemInfo" ; IS3 only
1016 "ComponentSetTarget" ; IS5 only
1017 "ComponentSetupTypeEnum" ; IS5 only
1018 "ComponentSetupTypeGetData" ; IS5 only
1019 "ComponentSetupTypeSet" ; IS5 only
1020 "ComponentTotalSize"
1021 "ComponentValidate" ; IS5 only
1022 "CompressAdd" ; IS3 only
1023 "CompressDel" ; IS3 only
1024 "CompressEnum" ; IS3 only
1025 "CompressGet" ; IS3 only
1026 "CompressInfo" ; IS3 only
1030 "CreateProgramFolder"
1031 "DeinstallSetReference" ; IS5 only
1057 "FileSetBeginDefine" ; IS3 only
1058 "FileSetEndDefine" ; IS3 only
1059 "FileSetPerformEz" ; IS3 only
1060 "FileSetPerform" ; IS3 only
1061 "FileSetReset" ; IS3 only
1062 "FileSetRoot" ; IS3 only
1076 "GetValidDrivesList"
1091 "ListGetFirstString"
1095 "ListSetCurrentItem"
1101 "LongPathToShortPath"
1116 "PlayMMedia" ; IS5 only
1123 "RegDBGetKeyValueEx"
1124 "RegDBSetKeyValueEx"
1125 "RegDBSetDefaultRoot"
1134 "SdComponentAdvCheckSpace"
1135 "SdComponentAdvInit"
1136 "SdComponentAdvUpdateSpace"
1138 "SdComponentDialog2"
1139 "SdComponentDialogAdv"
1140 "SdComponentDialogEx"
1141 "SdComponentDlgCheckSpace"
1144 "SdConfirmRegistration"
1156 "SdGetUserCompanyInfo"
1165 "SdOptionsButtonsInit"
1166 "SdPlugInProductName"
1169 "SdRegExEnableButton"
1174 "SdSetSequentialItems"
1176 "SdSetupTypeEx" ; IS5 only
1187 "SdUpdateComponentSelection"
1193 "SetDisplayEffect" ; IS5 only
1195 "SetForegroundWindow"
1208 "StrRemoveLastSlash"
1222 "System functions defined in InstallShield 3 and 5.")
1224 (defconst installshield-system-variables-list
1228 "CORECOMPONENTHANDLING"
1254 "System variables used in InstallShield 3 and 5.")
1256 (defconst installshield-types-list
1275 "Type keywords used in InstallShield 3 and 5.")
1277 ;;; some might want to skip highlighting these to improve performance
1278 (defconst installshield-funarg-constants-list
1308 "COMP_UPDATE_VERSION"
1327 "DLG_INFO_CHECKSELECTION"
1329 "DLG_INFO_USEDECIMAL"
1330 "DLG_MSG_INFORMATION"
1351 "FILE_ATTR_ARCHIVED"
1352 "FILE_ATTR_DIRECTORY"
1355 "FILE_ATTR_READONLY"
1361 "FILE_MODE_BINARYREADONLY"
1383 "HKEY_LOCAL_MACHINE"
1428 "REGDB_APPPATH_DEFAULT"
1431 "REGDB_ERR_CONNECTIONEXISTS"
1432 "REGDB_ERR_CORRUPTEDREGSITRY"
1433 "REGDB_ERR_INITIALIZATION"
1434 "REGDB_ERR_INVALIDHANDLE"
1435 "REGDB_ERR_INVALIDNAME"
1437 "REGDB_STRING_EXPAND"
1438 "REGDB_STRING_MULTI"
1440 "REGDB_UNINSTALL_NAME"
1484 "Function argument constants used in InstallShield 3 and 5."))
1486 (defvar rul-generic-mode-syntax-table nil
1487 "Syntax table to use in `rul-generic-mode' buffers.")
1489 (setq rul-generic-mode-syntax-table
1490 (make-syntax-table c
++-mode-syntax-table
))
1492 (modify-syntax-entry ?
\r "> b" rul-generic-mode-syntax-table
)
1493 (modify-syntax-entry ?
\n "> b" rul-generic-mode-syntax-table
)
1495 (modify-syntax-entry ?
/ ". 124b" rul-generic-mode-syntax-table
)
1496 (modify-syntax-entry ?
* ". 23" rul-generic-mode-syntax-table
)
1498 ;; here manually instead
1499 (defun generic-rul-mode-setup-function ()
1500 (make-local-variable 'parse-sexp-ignore-comments
)
1501 (make-local-variable 'comment-start
)
1502 (make-local-variable 'comment-start-skip
)
1503 (make-local-variable 'comment-end
)
1504 (setq imenu-generic-expression
1505 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1))
1506 parse-sexp-ignore-comments t
1510 ;;; comment-start "//"
1511 ;;; comment-start-skip ""
1513 ;; (set-syntax-table rul-generic-mode-syntax-table)
1514 (setq font-lock-syntax-table rul-generic-mode-syntax-table
))
1516 ;; moved mode-definition behind defun-definition to be warning-free - 15.11.02/RSan
1517 (define-generic-mode rul-generic-mode
1518 ;; Using "/*" and "*/" doesn't seem to be working right
1519 '("//" ("/*" .
"*/" ))
1520 (eval-when-compile installshield-statement-keyword-list
)
1523 ;; preprocessor constructs
1524 '("#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)"
1525 1 font-lock-string-face
)
1526 '("#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
1527 (1 font-lock-reference-face
)
1528 (2 font-lock-variable-name-face nil t
))
1529 ;; indirect string constants
1530 '("\\(@[A-Za-z][A-Za-z0-9_]+\\)" 1 font-lock-builtin-face
)
1532 '("[ \t]*\\(\\sw+:\\)" 1 font-lock-reference-face
)
1533 '("\\<\\(goto\\)\\>[ \t]*\\(\\sw+\\)?"
1534 (1 font-lock-keyword-face
)
1535 (2 font-lock-reference-face nil t
))
1537 (generic-make-keywords-list
1538 installshield-system-variables-list
1539 font-lock-variable-name-face
"[^_]" "[^_]")
1541 (generic-make-keywords-list
1542 installshield-system-functions-list
1543 font-lock-function-name-face
"[^_]" "[^_]")
1545 (generic-make-keywords-list
1546 installshield-types-list
1547 font-lock-type-face
"[^_]" "[^_]")
1548 ;; function argument constants
1549 (generic-make-keywords-list
1550 installshield-funarg-constants-list
1551 font-lock-variable-name-face
"[^_]" "[^_]"))) ; is this face the best choice?
1552 '("\\.[rR][uU][lL]\\'")
1553 '(generic-rul-mode-setup-function)
1554 "Generic mode for InstallShield RUL files.")
1556 (define-skeleton rul-if
1557 "Insert an if statement."
1559 "if(" str
") then" \n
1561 ( "other condition, %s: "
1562 > "elseif(" str
") then" \n
1569 (define-skeleton rul-function
1570 "Insert a function statement."
1572 "function " str
" ()" \n
1573 ( "local variables, %s: "
1580 ;; Additions by ACorreir@pervasive-sw.com (Alfred Correira)
1581 (when (memq 'mailrc-generic-mode generic-extras-enable-list
)
1583 (define-generic-mode mailrc-generic-mode
1594 '(("^\\s-*\\(alias\\|group\\)\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1595 (2 font-lock-constant-face
)
1596 (3 font-lock-variable-name-face
))
1597 ("^\\s-*\\(unset\\|set\\|ignore\\)\\s-+\\([-A-Za-z0-9_]+\\)=?\\([^\n\r#]*\\)\\(#.*\\)?$"
1598 (2 font-lock-constant-face
)
1599 (3 font-lock-variable-name-face
))
1600 ("^\\s-*\\(source\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1601 (2 font-lock-variable-name-face
)))
1604 "Mode for mailrc files."))
1607 (when (memq 'inetd-conf-generic-mode generic-extras-enable-list
)
1609 (define-generic-mode inetd-conf-generic-mode
1618 '(("^\\([-A-Za-z0-9_]+\\)" 1 font-lock-type-face
))
1619 '("/etc/inetd.conf\\'")
1623 (setq imenu-generic-expression
1624 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1627 (when (memq 'etc-services-generic-mode generic-extras-enable-list
)
1629 (define-generic-mode etc-services-generic-mode
1634 '(("^\\([-A-Za-z0-9_]+\\)\\s-+\\([0-9]+\\)/"
1635 (1 font-lock-type-face
)
1636 (2 font-lock-variable-name-face
)))
1637 '("/etc/services\\'")
1641 (setq imenu-generic-expression
1642 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1644 ;; Password and Group files
1645 (when (memq 'etc-passwd-generic-mode generic-extras-enable-list
)
1647 (define-generic-mode etc-passwd-generic-mode
1648 nil
;; No comment characters
1649 '("root") ;; Only one keyword
1655 ;; User name -- Never blank!
1658 ;; Password, UID and GID
1661 (make-list 3 "\\([^:]+\\)")
1664 ;; GECOS/Name -- might be blank
1667 ;; Home directory and shell
1672 '(1 font-lock-type-face
)
1673 '(5 font-lock-variable-name-face
)
1674 '(6 font-lock-constant-face
)
1675 '(7 font-lock-warning-face
))
1676 '("^\\([^:]+\\):\\([^:]*\\):\\([0-9]+\\):\\(.*\\)$"
1677 (1 font-lock-type-face
)
1678 (4 font-lock-variable-name-face
))))
1679 '("/etc/passwd\\'" "/etc/group\\'")
1683 (setq imenu-generic-expression
1684 '((nil "^\\([-A-Za-z0-9_]+\\):" 1))))))))
1687 (when (memq 'etc-fstab-generic-mode generic-extras-enable-list
)
1689 (define-generic-mode etc-fstab-generic-mode
1728 '(("^\\([^# \t]+\\)\\s-+\\([^# \t]+\\)"
1729 (1 font-lock-type-face t
)
1730 (2 font-lock-variable-name-face t
)))
1731 '("/etc/[v]*fstab\\'")
1735 (setq imenu-generic-expression
1736 '((nil "^\\([^# \t]+\\)\\s-+" 1))))))))
1739 (when (memq 'etc-sudoers-generic-mode generic-extras-enable-list
)
1741 (define-generic-mode etc-sudoers-generic-mode
1743 '("User_Alias" "Runas_Alias" "Host_Alias" "Cmnd_Alias"
1744 "NOPASSWD" "PASSWD" "NOEXEC" "EXEC"
1746 '(("\\<\\(root\\|su\\)\\>" 1 font-lock-warning-face
)
1747 ("\\(\\*\\)" 1 font-lock-warning-face
)
1748 ("\\<\\(%[A-Za-z0-9_]+\\)\\>" 1 font-lock-variable-name-face
))
1749 '("/etc/sudoers\\'")
1751 "Generic mode for sudoers configuration files."))
1753 ;; From Jacques Duthen <jacques.duthen@sncf.fr>
1754 (when (memq 'show-tabs-generic-mode generic-extras-enable-list
)
1758 (defconst show-tabs-generic-mode-font-lock-defaults-1
1759 '(;; trailing spaces must come before...
1760 ("[ \t]+$" .
'show-tabs-space
)
1762 ("[^\n\t]\\(\t+\\)" (1 'show-tabs-tab
))))
1764 (defconst show-tabs-generic-mode-font-lock-defaults-2
1765 '(;; trailing spaces must come before...
1766 ("[ \t]+$" .
'show-tabs-space
)
1768 ("\t+" .
'show-tabs-tab
))))
1770 (defface show-tabs-tab
1771 '((((class grayscale
) (background light
)) (:background
"DimGray" :weight bold
))
1772 (((class grayscale
) (background dark
)) (:background
"LightGray" :weight bold
))
1773 (((class color
) (min-colors 88)) (:background
"red1"))
1774 (((class color
)) (:background
"red"))
1776 "Font Lock mode face used to highlight TABs."
1778 ;; backward-compatibility alias
1779 (put 'show-tabs-tab-face
'face-alias
'show-tabs-tab
)
1781 (defface show-tabs-space
1782 '((((class grayscale
) (background light
)) (:background
"DimGray" :weight bold
))
1783 (((class grayscale
) (background dark
)) (:background
"LightGray" :weight bold
))
1784 (((class color
) (min-colors 88)) (:background
"yellow1"))
1785 (((class color
)) (:background
"yellow"))
1787 "Font Lock mode face used to highlight spaces."
1789 ;; backward-compatibility alias
1790 (put 'show-tabs-space-face
'face-alias
'show-tabs-space
)
1792 (define-generic-mode show-tabs-generic-mode
1793 nil
;; no comment char
1795 (eval-when-compile show-tabs-generic-mode-font-lock-defaults-1
)
1796 nil
;; no auto-mode-alist
1797 ;; '(show-tabs-generic-mode-hook-fun)
1799 "Generic mode to show tabs and trailing spaces."))
1801 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1803 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1805 (when (memq 'named-boot-generic-mode generic-extras-enable-list
)
1807 (define-generic-mode named-boot-generic-mode
1808 ;; List of comment characters
1811 '("cache" "primary" "secondary" "forwarders" "limit" "options"
1812 "directory" "check-names")
1813 ;; List of additional font-lock-expressions
1814 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face
)
1815 ("^directory\\s-+\\(.*\\)" 1 font-lock-variable-name-face
)
1816 ("^\\(primary\\|cache\\)\\s-+\\([.A-Za-z]+\\)\\s-+\\(.*\\)"
1817 (2 font-lock-variable-name-face
)
1818 (3 font-lock-constant-face
)))
1819 ;; List of additional automode-alist expressions
1820 '("/etc/named.boot\\'")
1821 ;; List of set up functions to call
1824 (when (memq 'named-database-generic-mode generic-extras-enable-list
)
1826 (define-generic-mode named-database-generic-mode
1827 ;; List of comment characters
1830 '("IN" "NS" "CNAME" "SOA" "PTR" "MX" "A")
1831 ;; List of additional font-lock-expressions
1832 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face
)
1833 ("^\\([.A-Za-z0-9]+\\)" 1 font-lock-variable-name-face
))
1834 ;; List of additional auto-mode-alist expressions
1836 ;; List of set up functions to call
1839 (defvar named-database-time-string
"%Y%m%d%H"
1840 "Timestring for named serial numbers.")
1842 (defun named-database-print-serial ()
1843 "Print a serial number based on the current date."
1845 (insert (format-time-string named-database-time-string
(current-time)))))
1847 (when (memq 'resolve-conf-generic-mode generic-extras-enable-list
)
1849 (define-generic-mode resolve-conf-generic-mode
1850 ;; List of comment characters
1853 '("nameserver" "domain" "search" "sortlist" "options")
1854 ;; List of additional font-lock-expressions
1856 ;; List of additional auto-mode-alist expressions
1857 '("/etc/resolv[e]?.conf\\'")
1858 ;; List of set up functions to call
1861 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1862 ;; Modes for spice and common electrical engineering circuit netlist formats
1863 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1865 (when (memq 'spice-generic-mode generic-extras-enable-list
)
1867 (define-generic-mode spice-generic-mode
1884 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1885 (" \\(\\$ .*\\)$" 1 font-lock-comment-face
)
1886 ("^\\(\\$ .*\\)$" 1 font-lock-comment-face
)
1887 ("\\([*].*\\)" 1 font-lock-comment-face
)
1888 ("^\\([+]\\)" 1 font-lock-string-face
)
1889 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face
)
1890 ("\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
)
1891 ("\\('[^']+'\\)" 1 font-lock-string-face
)
1892 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face
))
1894 "\\.[sS][pP][iI]\\'"
1895 "\\.[sS][pP][iI][cC][eE]\\'"
1896 "\\.[iI][nN][cC]\\'")
1898 'generic-bracket-support
1899 ;; Make keywords case-insensitive
1902 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
)))))
1903 "Generic mode for SPICE circuit netlist files."))
1905 (when (memq 'ibis-generic-mode generic-extras-enable-list
)
1907 (define-generic-mode ibis-generic-mode
1910 '(("[[]\\([^]]*\\)[]]" 1 font-lock-keyword-face
)
1911 ("\\(\\(_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
))
1912 '("\\.[iI][bB][sS]\\'")
1913 '(generic-bracket-support)
1914 "Generic mode for IBIS circuit netlist files."))
1916 (when (memq 'astap-generic-mode generic-extras-enable-list
)
1918 (define-generic-mode astap-generic-mode
1933 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1934 (";\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1935 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face
)
1936 ("\\('[^']+'\\)" 1 font-lock-string-face
)
1937 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face
)
1938 ("[(,]\\s-*\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
))
1940 "\\.[aA][sS][xX]\\'"
1941 "\\.[aA][sS][tT][aA][pP]\\'"
1942 "\\.[pP][sS][pP]\\'"
1943 "\\.[dD][eE][cC][kK]\\'"
1944 "\\.[gG][oO][dD][aA][tT][aA]")
1946 'generic-bracket-support
1947 ;; Make keywords case-insensitive
1950 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
)))))
1951 "Generic mode for ASTAP circuit netlist files."))
1953 (when (memq 'etc-modules-conf-generic-mode generic-extras-enable-list
)
1955 (define-generic-mode etc-modules-conf-generic-mode
1956 ;; List of comment characters
1974 "generic_stringfile"
1990 ;; List of additional font-lock-expressions
1992 ;; List of additional automode-alist expressions
1993 '("/etc/modules.conf" "/etc/conf.modules")
1994 ;; List of set up functions to call
1997 (provide 'generic-x
)
1999 ;; arch-tag: cde692a5-9ff6-4506-9999-c67999c2bdb5
2000 ;;; generic-x.el ends here