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
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 ]+\\([+-/][^\t\n\" ]+\\)" 1 font-lock-type-face
)
512 '("[ \t\n|]\\<\\([gG][oO][tT][oO]\\)\\>[ \t]*\\(\\sw+\\)?"
513 (1 font-lock-keyword-face
)
514 (2 font-lock-function-name-face nil t
))
515 '("[ \t\n|]\\<\\([sS][eE][tT]\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*=?"
516 (1 font-lock-builtin-face
)
517 (2 font-lock-variable-name-face t t
))))
518 '("\\.[bB][aA][tT]\\'"
520 "\\`[cC][oO][nN][fF][iI][gG]\\."
521 "\\`[aA][uU][tT][oO][eE][xX][eE][cC]\\.")
522 '(generic-bat-mode-setup-function)
523 "Generic mode for MS-Windows batch files.")
525 (defvar bat-generic-mode-syntax-table nil
526 "Syntax table in use in `bat-generic-mode' buffers.")
528 (defvar bat-generic-mode-keymap
(make-sparse-keymap)
529 "Keymap for `bat-generic-mode'.")
531 (defun bat-generic-mode-compile ()
532 "Run the current BAT file in a compilation buffer."
534 (let ((compilation-buffer-name-function
537 (concat "*" (buffer-file-name) "*")))))
539 (concat (w32-shell-name) " -c " (buffer-file-name)))))
541 (eval-when-compile (require 'comint
))
542 (defun bat-generic-mode-run-as-comint ()
543 "Run the current BAT file in a comint buffer."
546 (let* ((file (buffer-file-name))
547 (buf-name (concat "*" file
"*")))
548 (with-current-buffer (get-buffer-create buf-name
)
557 (display-buffer buf-name
))))
559 (define-key bat-generic-mode-keymap
"\C-c\C-c" 'bat-generic-mode-compile
)
561 ;; Make underscores count as words
562 (unless bat-generic-mode-syntax-table
563 (setq bat-generic-mode-syntax-table
(make-syntax-table))
564 (modify-syntax-entry ?_
"w" bat-generic-mode-syntax-table
))
566 ;; bat-generic-mode doesn't use the comment functionality of
567 ;; define-generic-mode because it has a three-letter comment-string,
568 ;; so we do it here manually instead
569 (defun generic-bat-mode-setup-function ()
570 (make-local-variable 'parse-sexp-ignore-comments
)
571 (make-local-variable 'comment-start
)
572 (make-local-variable 'comment-start-skip
)
573 (make-local-variable 'comment-end
)
574 (setq imenu-generic-expression
'((nil "^:\\(\\sw+\\)" 1))
575 parse-sexp-ignore-comments t
578 comment-start-skip
"[Rr][Ee][Mm] *")
579 (set-syntax-table bat-generic-mode-syntax-table
)
580 ;; Make keywords case-insensitive
581 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
))
582 (use-local-map bat-generic-mode-keymap
)))
585 ;; Mailagent is a Unix mail filtering program. Anyone wanna do a
586 ;; generic mode for procmail?
587 (when (memq 'mailagent-rules-generic-mode generic-extras-enable-list
)
589 (define-generic-mode mailagent-rules-generic-mode
591 '("SAVE" "DELETE" "PIPE" "ANNOTATE" "REJECT")
592 '(("^\\(\\sw+\\)\\s-*=" 1 font-lock-variable-name-face
)
593 ("\\s-/\\([^/]+\\)/[i, \t\n]" 1 font-lock-constant-face
))
598 (setq imenu-generic-expression
599 '((nil "\\s-/\\([^/]+\\)/[i, \t\n]" 1))))))
600 "Generic mode for Mailagent rules files."))
602 ;; Solaris/Sys V prototype files
603 (when (memq 'prototype-generic-mode generic-extras-enable-list
)
605 (define-generic-mode prototype-generic-mode
608 '(("^\\([0-9]\\)?\\s-*\\([a-z]\\)\\s-+\\([A-Za-z_]+\\)\\s-+\\([^\n\r]*\\)$"
609 (2 font-lock-constant-face
)
610 (3 font-lock-keyword-face
))
611 ("^\\([a-z]\\) \\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
612 (1 font-lock-constant-face
)
613 (2 font-lock-keyword-face
)
614 (3 font-lock-variable-name-face
))
615 ("^\\(!\\s-*\\(search\\|include\\|default\\)\\)\\s-*\\([^\n\r]*\\)$"
616 (1 font-lock-keyword-face
)
617 (3 font-lock-variable-name-face
))
618 ("^\\(!\\s-*\\sw+\\)=\\([^\n\r]*\\)$"
619 (1 font-lock-keyword-face
)
620 (2 font-lock-variable-name-face
)))
623 "Generic mode for Sys V prototype files."))
625 ;; Solaris/Sys V pkginfo files
626 (when (memq 'pkginfo-generic-mode generic-extras-enable-list
)
628 (define-generic-mode pkginfo-generic-mode
631 '(("^\\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
632 (1 font-lock-keyword-face
)
633 (2 font-lock-variable-name-face
)))
636 "Generic mode for Sys V pkginfo files."))
639 ;; Includes extra keywords from Armando Singer [asinger@MAIL.COLGATE.EDU]
640 (when (memq 'javascript-generic-mode generic-extras-enable-list
)
642 (define-generic-mode javascript-generic-mode
643 '("//" ("/*" .
"*/"))
666 ;; words reserved for ECMA extensions below
677 ;; Java Keywords reserved by JavaScript
704 '(("^\\s-*function\\s-+\\([A-Za-z0-9_]+\\)"
705 (1 font-lock-function-name-face
))
706 ("^\\s-*var\\s-+\\([A-Za-z0-9_]+\\)"
707 (1 font-lock-variable-name-face
)))
712 (setq imenu-generic-expression
713 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1)
714 ("*Variables*" "^var\\s-+\\([A-Za-z0-9_]+\\)" 1))))))
715 "Generic mode for JavaScript files."))
718 (when (memq 'vrml-generic-mode generic-extras-enable-list
)
720 (define-generic-mode vrml-generic-mode
750 '(("USE\\s-+\\([-A-Za-z0-9_]+\\)"
751 (1 font-lock-constant-face
))
752 ("DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
753 (1 font-lock-type-face
)
754 (2 font-lock-constant-face
))
755 ("^\\s-*\\([-A-Za-z0-9_]+\\)\\s-*{"
756 (1 font-lock-function-name-face
))
757 ("^\\s-*\\(geometry\\|appearance\\|material\\)\\s-+\\([-A-Za-z0-9_]+\\)"
758 (2 font-lock-variable-name-face
)))
763 (setq imenu-generic-expression
764 '((nil "^\\([A-Za-z0-9_]+\\)\\s-*{" 1)
766 "DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
768 "Generic Mode for VRML files."))
771 (when (memq 'java-manifest-generic-mode generic-extras-enable-list
)
773 (define-generic-mode java-manifest-generic-mode
783 '(("^Name:\\s-+\\([^\n\r]*\\)$"
784 (1 font-lock-variable-name-face
))
785 ("^\\(Manifest\\|Required\\|Signature\\)-Version:\\s-+\\([^\n\r]*\\)$"
786 (2 font-lock-constant-face
)))
787 '("[mM][aA][nN][iI][fF][eE][sS][tT]\\.[mM][fF]\\'")
789 "Generic mode for Java Manifest files."))
791 ;; Java properties files
792 (when (memq 'java-properties-generic-mode generic-extras-enable-list
)
794 (define-generic-mode java-properties-generic-mode
798 (let ((java-properties-key
799 "\\(\\([-A-Za-z0-9_\\./]\\|\\(\\\\[ =:]\\)\\)+\\)")
800 (java-properties-value
802 ;; Property and value can be separated in a number of different ways:
810 (concat "^" java-properties-key elt java-properties-value
"$")
811 '(1 font-lock-constant-face
)
812 '(4 font-lock-variable-name-face
))))
813 ;; These are the separators
814 '(":\\s-*" "\\s-+" "\\s-*=\\s-*"))))
819 (setq imenu-generic-expression
820 '((nil "^\\([^#! \t\n\r=:]+\\)" 1))))))
821 "Generic mode for Java properties files."))
823 ;; C shell alias definitions
824 (when (memq 'alias-generic-mode generic-extras-enable-list
)
826 (define-generic-mode alias-generic-mode
829 '(("^alias\\s-+\\([-A-Za-z0-9_]+\\)\\s-+"
830 (1 font-lock-variable-name-face
))
831 ("^unalias\\s-+\\([-A-Za-z0-9_]+\\)\\s-*$"
832 (1 font-lock-variable-name-face
)))
837 (setq imenu-generic-expression
838 '((nil "^\\(alias\\|unalias\\)\\s-+\\([-a-zA-Z0-9_]+\\)" 2))))))
839 "Generic mode for C Shell alias files."))
842 ;; Contributed by ACorreir@pervasive-sw.com (Alfred Correira)
843 (when (memq 'rc-generic-mode generic-extras-enable-list
)
845 (define-generic-mode rc-generic-mode
900 ;; the choice of what tokens go where is somewhat arbitrary,
901 ;; as is the choice of which value tokens are included, as
902 ;; the choice of face for each token group
905 (generic-make-keywords-list
914 (generic-make-keywords-list
919 font-lock-function-name-face
)
920 '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face
)
921 '("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face
)
922 '("^#[ \t]*\\(elif\\|if\\)\\>"
923 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil
924 (1 font-lock-constant-face
)
925 (2 font-lock-variable-name-face nil t
)))
926 '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
927 (1 font-lock-constant-face
)
928 (2 font-lock-variable-name-face nil t
))))
931 "Generic mode for MS-Windows Resource files."))
933 ;; InstallShield RUL files
934 ;; Contributed by Alfred.Correira@Pervasive.Com
935 ;; Bugfixes by "Rolf Sandau" <Rolf.Sandau@marconi.com>
936 (when (memq 'rul-generic-mode generic-extras-enable-list
)
940 ;;; build the regexp strings using regexp-opt
941 (defconst installshield-statement-keyword-list
960 ;; "goto" -- handled elsewhere
974 "Statement keywords used in InstallShield 3 and 5.")
976 (defconst installshield-system-functions-list
996 "ComponentAddItem" ; differs between IS3 and IS5
997 "ComponentCompareSizeRequired" ; IS5 only
999 "ComponentError" ; IS5 only
1000 "ComponentFileEnum" ; IS5 only
1001 "ComponentFileInfo" ; IS5 only
1002 "ComponentFilterLanguage" ; IS5 only
1003 "ComponentFilterOS" ; IS5 only
1004 "ComponentGetData" ; IS5 only
1005 "ComponentGetItemInfo" ; IS3 only
1006 "ComponentGetItemSize" ; differs between IS3 and IS5
1007 "ComponentIsItemSelected" ; differs between IS3 and IS5
1008 "ComponentListItems"
1009 "ComponentMoveData" ; IS5 only
1010 "ComponentSelectItem" ; differs between IS3 and IS5
1011 "ComponentSetData" ; IS5 only
1012 "ComponentSetItemInfo" ; IS3 only
1013 "ComponentSetTarget" ; IS5 only
1014 "ComponentSetupTypeEnum" ; IS5 only
1015 "ComponentSetupTypeGetData" ; IS5 only
1016 "ComponentSetupTypeSet" ; IS5 only
1017 "ComponentTotalSize"
1018 "ComponentValidate" ; IS5 only
1019 "CompressAdd" ; IS3 only
1020 "CompressDel" ; IS3 only
1021 "CompressEnum" ; IS3 only
1022 "CompressGet" ; IS3 only
1023 "CompressInfo" ; IS3 only
1027 "CreateProgramFolder"
1028 "DeinstallSetReference" ; IS5 only
1054 "FileSetBeginDefine" ; IS3 only
1055 "FileSetEndDefine" ; IS3 only
1056 "FileSetPerformEz" ; IS3 only
1057 "FileSetPerform" ; IS3 only
1058 "FileSetReset" ; IS3 only
1059 "FileSetRoot" ; IS3 only
1073 "GetValidDrivesList"
1088 "ListGetFirstString"
1092 "ListSetCurrentItem"
1098 "LongPathToShortPath"
1113 "PlayMMedia" ; IS5 only
1120 "RegDBGetKeyValueEx"
1121 "RegDBSetKeyValueEx"
1122 "RegDBSetDefaultRoot"
1131 "SdComponentAdvCheckSpace"
1132 "SdComponentAdvInit"
1133 "SdComponentAdvUpdateSpace"
1135 "SdComponentDialog2"
1136 "SdComponentDialogAdv"
1137 "SdComponentDialogEx"
1138 "SdComponentDlgCheckSpace"
1141 "SdConfirmRegistration"
1153 "SdGetUserCompanyInfo"
1162 "SdOptionsButtonsInit"
1163 "SdPlugInProductName"
1166 "SdRegExEnableButton"
1171 "SdSetSequentialItems"
1173 "SdSetupTypeEx" ; IS5 only
1184 "SdUpdateComponentSelection"
1190 "SetDisplayEffect" ; IS5 only
1192 "SetForegroundWindow"
1205 "StrRemoveLastSlash"
1219 "System functions defined in InstallShield 3 and 5.")
1221 (defconst installshield-system-variables-list
1225 "CORECOMPONENTHANDLING"
1251 "System variables used in InstallShield 3 and 5.")
1253 (defconst installshield-types-list
1272 "Type keywords used in InstallShield 3 and 5.")
1274 ;;; some might want to skip highlighting these to improve performance
1275 (defconst installshield-funarg-constants-list
1305 "COMP_UPDATE_VERSION"
1324 "DLG_INFO_CHECKSELECTION"
1326 "DLG_INFO_USEDECIMAL"
1327 "DLG_MSG_INFORMATION"
1348 "FILE_ATTR_ARCHIVED"
1349 "FILE_ATTR_DIRECTORY"
1352 "FILE_ATTR_READONLY"
1358 "FILE_MODE_BINARYREADONLY"
1380 "HKEY_LOCAL_MACHINE"
1425 "REGDB_APPPATH_DEFAULT"
1428 "REGDB_ERR_CONNECTIONEXISTS"
1429 "REGDB_ERR_CORRUPTEDREGSITRY"
1430 "REGDB_ERR_INITIALIZATION"
1431 "REGDB_ERR_INVALIDHANDLE"
1432 "REGDB_ERR_INVALIDNAME"
1434 "REGDB_STRING_EXPAND"
1435 "REGDB_STRING_MULTI"
1437 "REGDB_UNINSTALL_NAME"
1481 "Function argument constants used in InstallShield 3 and 5."))
1483 (defvar rul-generic-mode-syntax-table nil
1484 "Syntax table to use in `rul-generic-mode' buffers.")
1486 (setq rul-generic-mode-syntax-table
1487 (make-syntax-table c
++-mode-syntax-table
))
1489 (modify-syntax-entry ?
\r "> b" rul-generic-mode-syntax-table
)
1490 (modify-syntax-entry ?
\n "> b" rul-generic-mode-syntax-table
)
1492 (modify-syntax-entry ?
/ ". 124b" rul-generic-mode-syntax-table
)
1493 (modify-syntax-entry ?
* ". 23" rul-generic-mode-syntax-table
)
1495 ;; here manually instead
1496 (defun generic-rul-mode-setup-function ()
1497 (make-local-variable 'parse-sexp-ignore-comments
)
1498 (make-local-variable 'comment-start
)
1499 (make-local-variable 'comment-start-skip
)
1500 (make-local-variable 'comment-end
)
1501 (setq imenu-generic-expression
1502 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1))
1503 parse-sexp-ignore-comments t
1507 ;;; comment-start "//"
1508 ;;; comment-start-skip ""
1510 ;; (set-syntax-table rul-generic-mode-syntax-table)
1511 (setq font-lock-syntax-table rul-generic-mode-syntax-table
))
1513 ;; moved mode-definition behind defun-definition to be warning-free - 15.11.02/RSan
1514 (define-generic-mode rul-generic-mode
1515 ;; Using "/*" and "*/" doesn't seem to be working right
1516 '("//" ("/*" .
"*/" ))
1517 (eval-when-compile installshield-statement-keyword-list
)
1520 ;; preprocessor constructs
1521 '("#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)"
1522 1 font-lock-string-face
)
1523 '("#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
1524 (1 font-lock-reference-face
)
1525 (2 font-lock-variable-name-face nil t
))
1526 ;; indirect string constants
1527 '("\\(@[A-Za-z][A-Za-z0-9_]+\\)" 1 font-lock-builtin-face
)
1529 '("[ \t]*\\(\\sw+:\\)" 1 font-lock-reference-face
)
1530 '("\\<\\(goto\\)\\>[ \t]*\\(\\sw+\\)?"
1531 (1 font-lock-keyword-face
)
1532 (2 font-lock-reference-face nil t
))
1534 (generic-make-keywords-list
1535 installshield-system-variables-list
1536 font-lock-variable-name-face
"[^_]" "[^_]")
1538 (generic-make-keywords-list
1539 installshield-system-functions-list
1540 font-lock-function-name-face
"[^_]" "[^_]")
1542 (generic-make-keywords-list
1543 installshield-types-list
1544 font-lock-type-face
"[^_]" "[^_]")
1545 ;; function argument constants
1546 (generic-make-keywords-list
1547 installshield-funarg-constants-list
1548 font-lock-variable-name-face
"[^_]" "[^_]"))) ; is this face the best choice?
1549 '("\\.[rR][uU][lL]\\'")
1550 '(generic-rul-mode-setup-function)
1551 "Generic mode for InstallShield RUL files.")
1553 (define-skeleton rul-if
1554 "Insert an if statement."
1556 "if(" str
") then" \n
1558 ( "other condition, %s: "
1559 > "elseif(" str
") then" \n
1566 (define-skeleton rul-function
1567 "Insert a function statement."
1569 "function " str
" ()" \n
1570 ( "local variables, %s: "
1577 ;; Additions by ACorreir@pervasive-sw.com (Alfred Correira)
1578 (when (memq 'mailrc-generic-mode generic-extras-enable-list
)
1580 (define-generic-mode mailrc-generic-mode
1591 '(("^\\s-*\\(alias\\|group\\)\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1592 (2 font-lock-constant-face
)
1593 (3 font-lock-variable-name-face
))
1594 ("^\\s-*\\(unset\\|set\\|ignore\\)\\s-+\\([-A-Za-z0-9_]+\\)=?\\([^\n\r#]*\\)\\(#.*\\)?$"
1595 (2 font-lock-constant-face
)
1596 (3 font-lock-variable-name-face
))
1597 ("^\\s-*\\(source\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1598 (2 font-lock-variable-name-face
)))
1601 "Mode for mailrc files."))
1604 (when (memq 'inetd-conf-generic-mode generic-extras-enable-list
)
1606 (define-generic-mode inetd-conf-generic-mode
1615 '(("^\\([-A-Za-z0-9_]+\\)" 1 font-lock-type-face
))
1616 '("/etc/inetd.conf\\'")
1620 (setq imenu-generic-expression
1621 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1624 (when (memq 'etc-services-generic-mode generic-extras-enable-list
)
1626 (define-generic-mode etc-services-generic-mode
1631 '(("^\\([-A-Za-z0-9_]+\\)\\s-+\\([0-9]+\\)/"
1632 (1 font-lock-type-face
)
1633 (2 font-lock-variable-name-face
)))
1634 '("/etc/services\\'")
1638 (setq imenu-generic-expression
1639 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1641 ;; Password and Group files
1642 (when (memq 'etc-passwd-generic-mode generic-extras-enable-list
)
1644 (define-generic-mode etc-passwd-generic-mode
1645 nil
;; No comment characters
1646 '("root") ;; Only one keyword
1652 ;; User name -- Never blank!
1655 ;; Password, UID and GID
1658 (make-list 3 "\\([^:]+\\)")
1661 ;; GECOS/Name -- might be blank
1664 ;; Home directory and shell
1669 '(1 font-lock-type-face
)
1670 '(5 font-lock-variable-name-face
)
1671 '(6 font-lock-constant-face
)
1672 '(7 font-lock-warning-face
))
1673 '("^\\([^:]+\\):\\([^:]*\\):\\([0-9]+\\):\\(.*\\)$"
1674 (1 font-lock-type-face
)
1675 (4 font-lock-variable-name-face
))))
1676 '("/etc/passwd\\'" "/etc/group\\'")
1680 (setq imenu-generic-expression
1681 '((nil "^\\([-A-Za-z0-9_]+\\):" 1))))))))
1684 (when (memq 'etc-fstab-generic-mode generic-extras-enable-list
)
1686 (define-generic-mode etc-fstab-generic-mode
1725 '(("^\\([^# \t]+\\)\\s-+\\([^# \t]+\\)"
1726 (1 font-lock-type-face t
)
1727 (2 font-lock-variable-name-face t
)))
1728 '("/etc/[v]*fstab\\'")
1732 (setq imenu-generic-expression
1733 '((nil "^\\([^# \t]+\\)\\s-+" 1))))))))
1736 (when (memq 'etc-sudoers-generic-mode generic-extras-enable-list
)
1738 (define-generic-mode etc-sudoers-generic-mode
1740 '("User_Alias" "Runas_Alias" "Host_Alias" "Cmnd_Alias"
1741 "NOPASSWD" "PASSWD" "NOEXEC" "EXEC"
1743 '(("\\<\\(root\\|su\\)\\>" 1 font-lock-warning-face
)
1744 ("\\(\\*\\)" 1 font-lock-warning-face
)
1745 ("\\<\\(%[A-Za-z0-9_]+\\)\\>" 1 font-lock-variable-name-face
))
1746 '("/etc/sudoers\\'")
1748 "Generic mode for sudoers configuration files."))
1750 ;; From Jacques Duthen <jacques.duthen@sncf.fr>
1751 (when (memq 'show-tabs-generic-mode generic-extras-enable-list
)
1755 (defconst show-tabs-generic-mode-font-lock-defaults-1
1756 '(;; trailing spaces must come before...
1757 ("[ \t]+$" .
'show-tabs-space
)
1759 ("[^\n\t]\\(\t+\\)" (1 'show-tabs-tab
))))
1761 (defconst show-tabs-generic-mode-font-lock-defaults-2
1762 '(;; trailing spaces must come before...
1763 ("[ \t]+$" .
'show-tabs-space
)
1765 ("\t+" .
'show-tabs-tab
))))
1767 (defface show-tabs-tab
1768 '((((class grayscale
) (background light
)) (:background
"DimGray" :weight bold
))
1769 (((class grayscale
) (background dark
)) (:background
"LightGray" :weight bold
))
1770 (((class color
) (min-colors 88)) (:background
"red1"))
1771 (((class color
)) (:background
"red"))
1773 "Font Lock mode face used to highlight TABs."
1775 (define-obsolete-face-alias 'show-tabs-tab-face
'show-tabs-tab
"22.1")
1777 (defface show-tabs-space
1778 '((((class grayscale
) (background light
)) (:background
"DimGray" :weight bold
))
1779 (((class grayscale
) (background dark
)) (:background
"LightGray" :weight bold
))
1780 (((class color
) (min-colors 88)) (:background
"yellow1"))
1781 (((class color
)) (:background
"yellow"))
1783 "Font Lock mode face used to highlight spaces."
1785 (define-obsolete-face-alias 'show-tabs-space-face
'show-tabs-space
"22.1")
1787 (define-generic-mode show-tabs-generic-mode
1788 nil
;; no comment char
1790 (eval-when-compile show-tabs-generic-mode-font-lock-defaults-1
)
1791 nil
;; no auto-mode-alist
1792 ;; '(show-tabs-generic-mode-hook-fun)
1794 "Generic mode to show tabs and trailing spaces."))
1796 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1798 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1800 (when (memq 'named-boot-generic-mode generic-extras-enable-list
)
1802 (define-generic-mode named-boot-generic-mode
1803 ;; List of comment characters
1806 '("cache" "primary" "secondary" "forwarders" "limit" "options"
1807 "directory" "check-names")
1808 ;; List of additional font-lock-expressions
1809 '(("\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)" 1 font-lock-constant-face
)
1810 ("^directory\\s-+\\(.*\\)" 1 font-lock-variable-name-face
)
1811 ("^\\(primary\\|cache\\)\\s-+\\([.A-Za-z]+\\)\\s-+\\(.*\\)"
1812 (2 font-lock-variable-name-face
)
1813 (3 font-lock-constant-face
)))
1814 ;; List of additional automode-alist expressions
1815 '("/etc/named.boot\\'")
1816 ;; List of set up functions to call
1819 (when (memq 'named-database-generic-mode generic-extras-enable-list
)
1821 (define-generic-mode named-database-generic-mode
1822 ;; List of comment characters
1825 '("IN" "NS" "CNAME" "SOA" "PTR" "MX" "A")
1826 ;; List of additional font-lock-expressions
1827 '(("\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)" 1 font-lock-constant-face
)
1828 ("^\\([.A-Za-z0-9]+\\)" 1 font-lock-variable-name-face
))
1829 ;; List of additional auto-mode-alist expressions
1831 ;; List of set up functions to call
1834 (defvar named-database-time-string
"%Y%m%d%H"
1835 "Timestring for named serial numbers.")
1837 (defun named-database-print-serial ()
1838 "Print a serial number based on the current date."
1840 (insert (format-time-string named-database-time-string
(current-time)))))
1842 (when (memq 'resolve-conf-generic-mode generic-extras-enable-list
)
1844 (define-generic-mode resolve-conf-generic-mode
1845 ;; List of comment characters
1848 '("nameserver" "domain" "search" "sortlist" "options")
1849 ;; List of additional font-lock-expressions
1851 ;; List of additional auto-mode-alist expressions
1852 '("/etc/resolv[e]?.conf\\'")
1853 ;; List of set up functions to call
1856 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1857 ;; Modes for spice and common electrical engineering circuit netlist formats
1858 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1860 (when (memq 'spice-generic-mode generic-extras-enable-list
)
1862 (define-generic-mode spice-generic-mode
1879 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1880 (" \\(\\$ .*\\)$" 1 font-lock-comment-face
)
1881 ("^\\(\\$ .*\\)$" 1 font-lock-comment-face
)
1882 ("\\([*].*\\)" 1 font-lock-comment-face
)
1883 ("^\\([+]\\)" 1 font-lock-string-face
)
1884 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face
)
1885 ("\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
)
1886 ("\\('[^']+'\\)" 1 font-lock-string-face
)
1887 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face
))
1889 "\\.[sS][pP][iI]\\'"
1890 "\\.[sS][pP][iI][cC][eE]\\'"
1891 "\\.[iI][nN][cC]\\'")
1893 'generic-bracket-support
1894 ;; Make keywords case-insensitive
1897 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
)))))
1898 "Generic mode for SPICE circuit netlist files."))
1900 (when (memq 'ibis-generic-mode generic-extras-enable-list
)
1902 (define-generic-mode ibis-generic-mode
1905 '(("[[]\\([^]]*\\)[]]" 1 font-lock-keyword-face
)
1906 ("\\(\\(_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
))
1907 '("\\.[iI][bB][sS]\\'")
1908 '(generic-bracket-support)
1909 "Generic mode for IBIS circuit netlist files."))
1911 (when (memq 'astap-generic-mode generic-extras-enable-list
)
1913 (define-generic-mode astap-generic-mode
1928 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1929 (";\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1930 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face
)
1931 ("\\('[^']+'\\)" 1 font-lock-string-face
)
1932 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face
)
1933 ("[(,]\\s-*\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
))
1935 "\\.[aA][sS][xX]\\'"
1936 "\\.[aA][sS][tT][aA][pP]\\'"
1937 "\\.[pP][sS][pP]\\'"
1938 "\\.[dD][eE][cC][kK]\\'"
1939 "\\.[gG][oO][dD][aA][tT][aA]")
1941 'generic-bracket-support
1942 ;; Make keywords case-insensitive
1945 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
)))))
1946 "Generic mode for ASTAP circuit netlist files."))
1948 (when (memq 'etc-modules-conf-generic-mode generic-extras-enable-list
)
1950 (define-generic-mode etc-modules-conf-generic-mode
1951 ;; List of comment characters
1969 "generic_stringfile"
1985 ;; List of additional font-lock-expressions
1987 ;; List of additional automode-alist expressions
1988 '("/etc/modules.conf" "/etc/conf.modules")
1989 ;; List of set up functions to call
1992 (provide 'generic-x
)
1994 ;; arch-tag: cde692a5-9ff6-4506-9999-c67999c2bdb5
1995 ;;; generic-x.el ends here