1 ;;; generic-x.el --- A collection of generic modes
3 ;; Copyright (C) 1997, 1998, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007 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, or (at your option)
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; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
29 ;; This file contains a collection of generic modes.
33 ;; Add this line to your .emacs file:
35 ;; (require 'generic-x)
37 ;; You can decide which modes to load by setting the variable
38 ;; `generic-extras-enable-list'. Its default value is platform-
39 ;; specific. The recommended way to set this variable is through
42 ;; M-x customize-option RET generic-extras-enable-list RET
44 ;; This lets you select generic modes from the list of available
45 ;; modes. If you manually set `generic-extras-enable-list' in your
46 ;; .emacs, do it BEFORE loading generic-x with (require 'generic-x).
48 ;; You can also send in new modes; if the file types are reasonably
49 ;; common, we would like to install them.
51 ;; DEFAULT GENERIC MODE:
53 ;; This file provides a hook which automatically puts a file into
54 ;; `default-generic-mode' if the first few lines of a file in
55 ;; fundamental mode start with a hash comment character. To disable
56 ;; this functionality, set the variable `generic-use-find-file-hook'
57 ;; to nil BEFORE loading generic-x. See the variables
58 ;; `generic-lines-to-scan' and `generic-find-file-regexp' for
59 ;; customization options.
61 ;; PROBLEMS WHEN USED WITH FOLDING MODE:
63 ;; [The following relates to the obsolete selective-display technique.
64 ;; Folding mode should use invisible text properties instead. -- Dave
67 ;; From Anders Lindgren <andersl@csd.uu.se>
69 ;; Problem summary: Wayne Adams has found a problem when using folding
70 ;; mode in conjunction with font-lock for a mode defined in
73 ;; The problem, as Wayne described it, was that error messages of the
74 ;; following form appeared when both font-lock and folding are used:
76 ;; > - various msgs including "Fontifying region...(error Stack
77 ;; > overflow in regexp matcher)" appear
79 ;; I have just tracked down the cause of the problem. The regexp's in
80 ;; `generic-x.el' do not take into account the way that folding hides
81 ;; sections of the buffer. The technique is known as
82 ;; `selective-display' and has been available for a very long time (I
83 ;; started using it back in the good old Emacs 18 days). Basically, a
84 ;; section is hidden by creating one very long line were the newline
85 ;; character (C-j) is replaced by a linefeed (C-m) character.
87 ;; Many other hiding packages, besides folding, use the same technique,
88 ;; the problem should occur when using them as well.
90 ;; The erroneous lines in `generic-x.el' look like the following (this
91 ;; example is from the `ini' section):
93 ;; '(("^\\(\\[.*\\]\\)" 1 'font-lock-constant-face)
94 ;; ("^\\(.*\\)=" 1 'font-lock-variable-name-face)
96 ;; The intention of these lines is to highlight lines of the following
102 ;; However, since the `.' regexp symbol matches the linefeed character
103 ;; the entire folded section is searched, resulting in a regexp stack
106 ;; Solution suggestion: Instead of using ".", use the sequence
107 ;; "[^\n\r]". This will make the rules behave just as before, but
108 ;; they will work together with selective-display.
112 (eval-when-compile (require 'font-lock
))
114 (defgroup generic-x nil
115 "A collection of generic modes."
120 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
121 ;; Default-Generic mode
122 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
124 (defcustom generic-use-find-file-hook t
125 "*If non-nil, add a hook to enter `default-generic-mode' automatically.
126 This is done if the first few lines of a file in fundamental mode
127 start with a hash comment character."
131 (defcustom generic-lines-to-scan
3
132 "*Number of lines that `generic-mode-find-file-hook' looks at.
133 Relevant when deciding whether to enter Default-Generic mode automatically.
134 This variable should be set to a small positive number."
138 (defcustom generic-find-file-regexp
"^#"
139 "*Regular expression used by `generic-mode-find-file-hook'.
140 Files in fundamental mode whose first few lines contain a match
141 for this regexp, should be put into Default-Generic mode instead.
142 The number of lines tested for the matches is specified by the
143 value of the variable `generic-lines-to-scan', which see."
147 (defcustom generic-ignore-files-regexp
"[Tt][Aa][Gg][Ss]\\'"
148 "*Regular expression used by `generic-mode-find-file-hook'.
149 Files whose names match this regular expression should not be put
150 into Default-Generic mode, even if they have lines which match
151 the regexp in `generic-find-file-regexp'. If the value is nil,
152 `generic-mode-find-file-hook' does not check the file names."
154 :type
'(choice (const :tag
"Don't check file names" nil
) regexp
))
156 ;; This generic mode is always defined
157 (define-generic-mode default-generic-mode
(list ?
#) nil nil nil nil
)
159 ;; A more general solution would allow us to enter generic-mode for
160 ;; *any* comment character, but would require us to synthesize a new
161 ;; generic-mode on the fly. I think this gives us most of what we
163 (defun generic-mode-find-file-hook ()
164 "Hook function to enter Default-Generic mode automatically.
166 Done if the first few lines of a file in Fundamental mode start
167 with a match for the regexp in `generic-find-file-regexp', unless
168 the file's name matches the regexp which is the value of the
169 variable `generic-ignore-files-regexp'.
171 This hook will be installed if the variable
172 `generic-use-find-file-hook' is non-nil. The variable
173 `generic-lines-to-scan' determines the number of lines to look at."
174 (when (and (eq major-mode
'fundamental-mode
)
175 (or (null generic-ignore-files-regexp
)
177 generic-ignore-files-regexp
178 (file-name-sans-versions buffer-file-name
)))))
180 (goto-char (point-min))
181 (when (re-search-forward generic-find-file-regexp
183 (forward-line generic-lines-to-scan
)
185 (goto-char (point-min))
186 (default-generic-mode)))))
188 (and generic-use-find-file-hook
189 (add-hook 'find-file-hook
'generic-mode-find-file-hook
))
191 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
192 ;; Other Generic modes
193 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
195 ;; If you add a generic mode to this file, put it in one of these four
198 (defconst generic-default-modes
199 '(apache-conf-generic-mode
200 apache-log-generic-mode
202 java-manifest-generic-mode
203 java-properties-generic-mode
204 javascript-generic-mode
205 show-tabs-generic-mode
207 "List of generic modes that are defined by default.")
209 (defconst generic-mswindows-modes
216 "List of generic modes that are defined by default on MS-Windows.")
218 (defconst generic-unix-modes
220 etc-fstab-generic-mode
221 etc-modules-conf-generic-mode
222 etc-passwd-generic-mode
223 etc-services-generic-mode
225 inetd-conf-generic-mode
226 mailagent-rules-generic-mode
228 named-boot-generic-mode
229 named-database-generic-mode
230 prototype-generic-mode
231 resolve-conf-generic-mode
233 x-resource-generic-mode
)
234 "List of generic modes that are defined by default on Unix.")
236 (defconst generic-other-modes
241 "List of generic mode 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 "Mode for Apache log files."))
323 (when (memq 'samba-generic-mode generic-extras-enable-list
)
325 (define-generic-mode samba-generic-mode
328 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face
)
329 ("^\\s-*\\(.+\\)=\\([^\r\n]*\\)"
330 (1 font-lock-variable-name-face
)
331 (2 font-lock-type-face
)))
333 '(generic-bracket-support)
334 "Generic mode for Samba configuration files."))
337 ;; This is pretty basic. Also, modes for other window managers could
338 ;; be defined as well.
339 (when (memq 'fvwm-generic-mode generic-extras-enable-list
)
341 (define-generic-mode fvwm-generic-mode
357 '("\\.fvwmrc\\'" "\\.fvwm2rc\\'")
359 "Generic mode for FVWM configuration files."))
362 ;; I'm pretty sure I've seen an actual mode to do this, but I don't
363 ;; think it's standard with Emacs
364 (when (memq 'x-resource-generic-mode generic-extras-enable-list
)
366 (define-generic-mode x-resource-generic-mode
369 '(("^\\([^:\n]+:\\)" 1 font-lock-variable-name-face
))
370 '("\\.Xdefaults\\'" "\\.Xresources\\'" "\\.Xenvironment\\'" "\\.ad\\'")
372 "Generic mode for X Resource configuration files."))
375 (when (memq 'hosts-generic-mode generic-extras-enable-list
)
377 (define-generic-mode hosts-generic-mode
380 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face
))
381 '("[hH][oO][sS][tT][sS]\\'")
383 "Generic mode for HOSTS files."))
385 ;;; Windows INF files
387 ;; If i-g-m-f-f-h is defined, then so is i-g-m.
388 (declare-function ini-generic-mode
"generic-x")
390 (when (memq 'inf-generic-mode generic-extras-enable-list
)
392 (define-generic-mode inf-generic-mode
395 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face
))
396 '("\\.[iI][nN][fF]\\'")
397 '(generic-bracket-support)
398 "Generic mode for MS-Windows INF files."))
400 ;;; Windows INI files
401 ;; Should define escape character as well!
402 (when (memq 'ini-generic-mode generic-extras-enable-list
)
404 (define-generic-mode ini-generic-mode
407 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face
)
408 ("^\\([^=\n\r]*\\)=\\([^\n\r]*\\)$"
409 (1 font-lock-function-name-face
)
410 (2 font-lock-variable-name-face
)))
411 '("\\.[iI][nN][iI]\\'")
415 (setq imenu-generic-expression
416 '((nil "^\\[\\(.*\\)\\]" 1)
417 ("*Variables*" "^\\s-*\\([^=]+\\)\\s-*=" 1))))))
418 "Generic mode for MS-Windows INI files.
419 You can use `ini-generic-mode-find-file-hook' to enter this mode
420 automatically for INI files whose names do not end in \".ini\".")
422 (defun ini-generic-mode-find-file-hook ()
423 "Hook function to enter Ini-Generic mode automatically for INI files.
424 Done if the first few lines of a file in Fundamental mode look
425 like an INI file. You can add this hook to `find-file-hook'."
426 (and (eq major-mode
'fundamental-mode
)
428 (goto-char (point-min))
429 (and (looking-at "^\\s-*\\[.*\\]")
430 (ini-generic-mode)))))
431 (defalias 'generic-mode-ini-file-find-file-hook
'ini-generic-mode-find-file-hook
))
433 ;;; Windows REG files
434 ;;; Unfortunately, Windows 95 and Windows NT have different REG file syntax!
435 (when (memq 'reg-generic-mode generic-extras-enable-list
)
437 (define-generic-mode reg-generic-mode
439 '("key" "classes_root" "REGEDIT" "REGEDIT4")
440 '(("\\(\\[.*\\]\\)" 1 font-lock-constant-face
)
441 ("^\\([^\n\r]*\\)\\s-*=" 1 font-lock-variable-name-face
))
442 '("\\.[rR][eE][gG]\\'")
446 (setq imenu-generic-expression
447 '((nil "^\\s-*\\(.*\\)\\s-*=" 1))))))
448 "Generic mode for MS-Windows Registry files."))
450 (declare-function w32-shell-name
"w32-fns" ())
452 ;;; DOS/Windows BAT files
453 (when (memq 'bat-generic-mode generic-extras-enable-list
)
455 (define-generic-mode bat-generic-mode
460 ;; Make this one first in the list, otherwise comments will
461 ;; be over-written by other variables
462 '("^[@ \t]*\\([rR][eE][mM][^\n\r]*\\)" 1 font-lock-comment-face t
)
463 '("^[ \t]*\\(::.*\\)" 1 font-lock-comment-face t
)
464 '("^[@ \t]*\\([bB][rR][eE][aA][kK]\\|[vV][eE][rR][iI][fF][yY]\\)[ \t]+\\([oO]\\([nN]\\|[fF][fF]\\)\\)"
465 (1 font-lock-builtin-face
)
466 (2 font-lock-constant-face t t
))
467 ;; Any text (except ON/OFF) following ECHO is a string.
468 '("^[@ \t]*\\([eE][cC][hH][oO]\\)[ \t]+\\(\\([oO]\\([nN]\\|[fF][fF]\\)\\)\\|\\([^>|\r\n]+\\)\\)"
469 (1 font-lock-builtin-face
)
470 (3 font-lock-constant-face t t
)
471 (5 font-lock-string-face t t
))
472 ;; These keywords appear as the first word on a line. (Actually, they
473 ;; can also appear after "if ..." or "for ..." clause, but since they
474 ;; are frequently used in simple text, we punt.)
475 ;; In `generic-bat-mode-setup-function' we make the keywords
477 (generic-make-keywords-list
480 font-lock-keyword-face
"^[@ \t]*")
481 ;; These keywords can be anywhere on a line
482 ;; In `generic-bat-mode-setup-function' we make the keywords
484 (generic-make-keywords-list
490 font-lock-keyword-face
)
491 ;; These are built-in commands. Only frequently-used ones are listed.
492 (generic-make-keywords-list
493 '("CALL" "call" "Call"
501 "PAUSE" "pause" "Pause"
502 "PROMPT" "prompt" "Prompt"
506 "START" "start" "Start"
507 "SHIFT" "shift" "Shift")
508 font-lock-builtin-face
"[ \t|\n]")
509 '("^[ \t]*\\(:\\sw+\\)" 1 font-lock-function-name-face t
)
510 '("\\(%\\sw+%\\)" 1 font-lock-variable-name-face t
)
511 '("\\(%[0-9]\\)" 1 font-lock-variable-name-face t
)
512 '("\\(/[^/ \"\t\n]+\\)" 1 font-lock-type-face
)
513 '("[\t ]+\\([+-][^\t\n\" ]+\\)" 1 font-lock-type-face
)
514 '("[ \t\n|]\\<\\([gG][oO][tT][oO]\\)\\>[ \t]*\\(\\sw+\\)?"
515 (1 font-lock-keyword-face
)
516 (2 font-lock-function-name-face nil t
))
517 '("[ \t\n|]\\<\\([sS][eE][tT]\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*=?"
518 (1 font-lock-builtin-face
)
519 (2 font-lock-variable-name-face t t
))))
520 '("\\.[bB][aA][tT]\\'"
522 "\\`[cC][oO][nN][fF][iI][gG]\\."
523 "\\`[aA][uU][tT][oO][eE][xX][eE][cC]\\.")
524 '(generic-bat-mode-setup-function)
525 "Generic mode for MS-Windows batch files.")
527 (defvar bat-generic-mode-syntax-table nil
528 "Syntax table in use in `bat-generic-mode' buffers.")
530 (defvar bat-generic-mode-keymap
(make-sparse-keymap)
531 "Keymap for `bat-generic-mode'.")
533 (defun bat-generic-mode-compile ()
534 "Run the current BAT file in a compilation buffer."
536 (let ((compilation-buffer-name-function
539 (concat "*" (buffer-file-name) "*")))))
541 (concat (w32-shell-name) " -c " (buffer-file-name)))))
543 (eval-when-compile (require 'comint
))
544 (defun bat-generic-mode-run-as-comint ()
545 "Run the current BAT file in a comint buffer."
548 (let* ((file (buffer-file-name))
549 (buf-name (concat "*" file
"*")))
552 (get-buffer-create buf-name
))
561 (display-buffer buf-name
))))
563 (define-key bat-generic-mode-keymap
"\C-c\C-c" 'bat-generic-mode-compile
)
565 ;; Make underscores count as words
566 (unless bat-generic-mode-syntax-table
567 (setq bat-generic-mode-syntax-table
(make-syntax-table))
568 (modify-syntax-entry ?_
"w" bat-generic-mode-syntax-table
))
570 ;; bat-generic-mode doesn't use the comment functionality of
571 ;; define-generic-mode because it has a three-letter comment-string,
572 ;; so we do it here manually instead
573 (defun generic-bat-mode-setup-function ()
574 (make-local-variable 'parse-sexp-ignore-comments
)
575 (make-local-variable 'comment-start
)
576 (make-local-variable 'comment-start-skip
)
577 (make-local-variable 'comment-end
)
578 (setq imenu-generic-expression
'((nil "^:\\(\\sw+\\)" 1))
579 parse-sexp-ignore-comments t
582 comment-start-skip
"[Rr][Ee][Mm] *")
583 (set-syntax-table bat-generic-mode-syntax-table
)
584 ;; Make keywords case-insensitive
585 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
))
586 (use-local-map bat-generic-mode-keymap
)))
589 ;; Mailagent is a Unix mail filtering program. Anyone wanna do a
590 ;; generic mode for procmail?
591 (when (memq 'mailagent-rules-generic-mode generic-extras-enable-list
)
593 (define-generic-mode mailagent-rules-generic-mode
595 '("SAVE" "DELETE" "PIPE" "ANNOTATE" "REJECT")
596 '(("^\\(\\sw+\\)\\s-*=" 1 font-lock-variable-name-face
)
597 ("\\s-/\\([^/]+\\)/[i, \t\n]" 1 font-lock-constant-face
))
602 (setq imenu-generic-expression
603 '((nil "\\s-/\\([^/]+\\)/[i, \t\n]" 1))))))
604 "Mode for Mailagent rules files."))
606 ;; Solaris/Sys V prototype files
607 (when (memq 'prototype-generic-mode generic-extras-enable-list
)
609 (define-generic-mode prototype-generic-mode
612 '(("^\\([0-9]\\)?\\s-*\\([a-z]\\)\\s-+\\([A-Za-z_]+\\)\\s-+\\([^\n\r]*\\)$"
613 (2 font-lock-constant-face
)
614 (3 font-lock-keyword-face
))
615 ("^\\([a-z]\\) \\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
616 (1 font-lock-constant-face
)
617 (2 font-lock-keyword-face
)
618 (3 font-lock-variable-name-face
))
619 ("^\\(!\\s-*\\(search\\|include\\|default\\)\\)\\s-*\\([^\n\r]*\\)$"
620 (1 font-lock-keyword-face
)
621 (3 font-lock-variable-name-face
))
622 ("^\\(!\\s-*\\sw+\\)=\\([^\n\r]*\\)$"
623 (1 font-lock-keyword-face
)
624 (2 font-lock-variable-name-face
)))
627 "Mode for Sys V prototype files."))
629 ;; Solaris/Sys V pkginfo files
630 (when (memq 'pkginfo-generic-mode generic-extras-enable-list
)
632 (define-generic-mode pkginfo-generic-mode
635 '(("^\\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
636 (1 font-lock-keyword-face
)
637 (2 font-lock-variable-name-face
)))
640 "Mode for Sys V pkginfo files."))
643 ;; Includes extra keywords from Armando Singer [asinger@MAIL.COLGATE.EDU]
644 (when (memq 'javascript-generic-mode generic-extras-enable-list
)
646 (define-generic-mode javascript-generic-mode
647 '("//" ("/*" .
"*/"))
670 ;; words reserved for ECMA extensions below
681 ;; Java Keywords reserved by JavaScript
708 '(("^\\s-*function\\s-+\\([A-Za-z0-9_]+\\)"
709 (1 font-lock-function-name-face
))
710 ("^\\s-*var\\s-+\\([A-Za-z0-9_]+\\)"
711 (1 font-lock-variable-name-face
)))
716 (setq imenu-generic-expression
717 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1)
718 ("*Variables*" "^var\\s-+\\([A-Za-z0-9_]+\\)" 1))))))
719 "Mode for JavaScript files."))
722 (when (memq 'vrml-generic-mode generic-extras-enable-list
)
724 (define-generic-mode vrml-generic-mode
754 '(("USE\\s-+\\([-A-Za-z0-9_]+\\)"
755 (1 font-lock-constant-face
))
756 ("DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
757 (1 font-lock-type-face
)
758 (2 font-lock-constant-face
))
759 ("^\\s-*\\([-A-Za-z0-9_]+\\)\\s-*{"
760 (1 font-lock-function-name-face
))
761 ("^\\s-*\\(geometry\\|appearance\\|material\\)\\s-+\\([-A-Za-z0-9_]+\\)"
762 (2 font-lock-variable-name-face
)))
767 (setq imenu-generic-expression
768 '((nil "^\\([A-Za-z0-9_]+\\)\\s-*{" 1)
770 "DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
772 "Generic Mode for VRML files."))
775 (when (memq 'java-manifest-generic-mode generic-extras-enable-list
)
777 (define-generic-mode java-manifest-generic-mode
787 '(("^Name:\\s-+\\([^\n\r]*\\)$"
788 (1 font-lock-variable-name-face
))
789 ("^\\(Manifest\\|Required\\|Signature\\)-Version:\\s-+\\([^\n\r]*\\)$"
790 (2 font-lock-constant-face
)))
791 '("[mM][aA][nN][iI][fF][eE][sS][tT]\\.[mM][fF]\\'")
793 "Mode for Java Manifest files."))
795 ;; Java properties files
796 (when (memq 'java-properties-generic-mode generic-extras-enable-list
)
798 (define-generic-mode java-properties-generic-mode
802 (let ((java-properties-key
803 "\\(\\([-A-Za-z0-9_\\./]\\|\\(\\\\[ =:]\\)\\)+\\)")
804 (java-properties-value
806 ;; Property and value can be separated in a number of different ways:
814 (concat "^" java-properties-key elt java-properties-value
"$")
815 '(1 font-lock-constant-face
)
816 '(4 font-lock-variable-name-face
))))
817 ;; These are the separators
818 '(":\\s-*" "\\s-+" "\\s-*=\\s-*"))))
823 (setq imenu-generic-expression
824 '((nil "^\\([^#! \t\n\r=:]+\\)" 1))))))
825 "Mode for Java properties files."))
827 ;; C shell alias definitions
828 (when (memq 'alias-generic-mode generic-extras-enable-list
)
830 (define-generic-mode alias-generic-mode
833 '(("^alias\\s-+\\([-A-Za-z0-9_]+\\)\\s-+"
834 (1 font-lock-variable-name-face
))
835 ("^unalias\\s-+\\([-A-Za-z0-9_]+\\)\\s-*$"
836 (1 font-lock-variable-name-face
)))
841 (setq imenu-generic-expression
842 '((nil "^\\(alias\\|unalias\\)\\s-+\\([-a-zA-Z0-9_]+\\)" 2))))))
843 "Mode for C Shell alias files."))
846 ;; Contributed by ACorreir@pervasive-sw.com (Alfred Correira)
847 (when (memq 'rc-generic-mode generic-extras-enable-list
)
849 (define-generic-mode rc-generic-mode
904 ;; the choice of what tokens go where is somewhat arbitrary,
905 ;; as is the choice of which value tokens are included, as
906 ;; the choice of face for each token group
909 (generic-make-keywords-list
918 (generic-make-keywords-list
923 font-lock-function-name-face
)
924 '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face
)
925 '("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face
)
926 '("^#[ \t]*\\(elif\\|if\\)\\>"
927 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil
928 (1 font-lock-constant-face
)
929 (2 font-lock-variable-name-face nil t
)))
930 '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
931 (1 font-lock-constant-face
)
932 (2 font-lock-variable-name-face nil t
))))
935 "Generic mode for MS-Windows Resource files."))
937 ;; InstallShield RUL files
938 ;; Contributed by Alfred.Correira@Pervasive.Com
939 ;; Bugfixes by "Rolf Sandau" <Rolf.Sandau@marconi.com>
940 (when (memq 'rul-generic-mode generic-extras-enable-list
)
944 ;;; build the regexp strings using regexp-opt
945 (defconst installshield-statement-keyword-list
964 ;; "goto" -- handled elsewhere
978 "Statement keywords used in InstallShield 3 and 5.")
980 (defconst installshield-system-functions-list
1000 "ComponentAddItem" ; differs between IS3 and IS5
1001 "ComponentCompareSizeRequired" ; IS5 only
1003 "ComponentError" ; IS5 only
1004 "ComponentFileEnum" ; IS5 only
1005 "ComponentFileInfo" ; IS5 only
1006 "ComponentFilterLanguage" ; IS5 only
1007 "ComponentFilterOS" ; IS5 only
1008 "ComponentGetData" ; IS5 only
1009 "ComponentGetItemInfo" ; IS3 only
1010 "ComponentGetItemSize" ; differs between IS3 and IS5
1011 "ComponentIsItemSelected" ; differs between IS3 and IS5
1012 "ComponentListItems"
1013 "ComponentMoveData" ; IS5 only
1014 "ComponentSelectItem" ; differs between IS3 and IS5
1015 "ComponentSetData" ; IS5 only
1016 "ComponentSetItemInfo" ; IS3 only
1017 "ComponentSetTarget" ; IS5 only
1018 "ComponentSetupTypeEnum" ; IS5 only
1019 "ComponentSetupTypeGetData" ; IS5 only
1020 "ComponentSetupTypeSet" ; IS5 only
1021 "ComponentTotalSize"
1022 "ComponentValidate" ; IS5 only
1023 "CompressAdd" ; IS3 only
1024 "CompressDel" ; IS3 only
1025 "CompressEnum" ; IS3 only
1026 "CompressGet" ; IS3 only
1027 "CompressInfo" ; IS3 only
1031 "CreateProgramFolder"
1032 "DeinstallSetReference" ; IS5 only
1058 "FileSetBeginDefine" ; IS3 only
1059 "FileSetEndDefine" ; IS3 only
1060 "FileSetPerformEz" ; IS3 only
1061 "FileSetPerform" ; IS3 only
1062 "FileSetReset" ; IS3 only
1063 "FileSetRoot" ; IS3 only
1077 "GetValidDrivesList"
1092 "ListGetFirstString"
1096 "ListSetCurrentItem"
1102 "LongPathToShortPath"
1117 "PlayMMedia" ; IS5 only
1124 "RegDBGetKeyValueEx"
1125 "RegDBSetKeyValueEx"
1126 "RegDBSetDefaultRoot"
1135 "SdComponentAdvCheckSpace"
1136 "SdComponentAdvInit"
1137 "SdComponentAdvUpdateSpace"
1139 "SdComponentDialog2"
1140 "SdComponentDialogAdv"
1141 "SdComponentDialogEx"
1142 "SdComponentDlgCheckSpace"
1145 "SdConfirmRegistration"
1157 "SdGetUserCompanyInfo"
1166 "SdOptionsButtonsInit"
1167 "SdPlugInProductName"
1170 "SdRegExEnableButton"
1175 "SdSetSequentialItems"
1177 "SdSetupTypeEx" ; IS5 only
1188 "SdUpdateComponentSelection"
1194 "SetDisplayEffect" ; IS5 only
1196 "SetForegroundWindow"
1209 "StrRemoveLastSlash"
1223 "System functions defined in InstallShield 3 and 5.")
1225 (defconst installshield-system-variables-list
1229 "CORECOMPONENTHANDLING"
1255 "System variables used in InstallShield 3 and 5.")
1257 (defconst installshield-types-list
1276 "Type keywords used in InstallShield 3 and 5.")
1278 ;;; some might want to skip highlighting these to improve performance
1279 (defconst installshield-funarg-constants-list
1309 "COMP_UPDATE_VERSION"
1328 "DLG_INFO_CHECKSELECTION"
1330 "DLG_INFO_USEDECIMAL"
1331 "DLG_MSG_INFORMATION"
1352 "FILE_ATTR_ARCHIVED"
1353 "FILE_ATTR_DIRECTORY"
1356 "FILE_ATTR_READONLY"
1362 "FILE_MODE_BINARYREADONLY"
1384 "HKEY_LOCAL_MACHINE"
1429 "REGDB_APPPATH_DEFAULT"
1432 "REGDB_ERR_CONNECTIONEXISTS"
1433 "REGDB_ERR_CORRUPTEDREGSITRY"
1434 "REGDB_ERR_INITIALIZATION"
1435 "REGDB_ERR_INVALIDHANDLE"
1436 "REGDB_ERR_INVALIDNAME"
1438 "REGDB_STRING_EXPAND"
1439 "REGDB_STRING_MULTI"
1441 "REGDB_UNINSTALL_NAME"
1485 "Function argument constants used in InstallShield 3 and 5."))
1487 (defvar rul-generic-mode-syntax-table nil
1488 "Syntax table to use in `rul-generic-mode' buffers.")
1490 (setq rul-generic-mode-syntax-table
1491 (make-syntax-table c
++-mode-syntax-table
))
1493 (modify-syntax-entry ?
\r "> b" rul-generic-mode-syntax-table
)
1494 (modify-syntax-entry ?
\n "> b" rul-generic-mode-syntax-table
)
1496 (modify-syntax-entry ?
/ ". 124b" rul-generic-mode-syntax-table
)
1497 (modify-syntax-entry ?
* ". 23" rul-generic-mode-syntax-table
)
1499 ;; here manually instead
1500 (defun generic-rul-mode-setup-function ()
1501 (make-local-variable 'parse-sexp-ignore-comments
)
1502 (make-local-variable 'comment-start
)
1503 (make-local-variable 'comment-start-skip
)
1504 (make-local-variable 'comment-end
)
1505 (setq imenu-generic-expression
1506 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1))
1507 parse-sexp-ignore-comments t
1511 ;;; comment-start "//"
1512 ;;; comment-start-skip ""
1514 ;; (set-syntax-table rul-generic-mode-syntax-table)
1515 (setq font-lock-syntax-table rul-generic-mode-syntax-table
))
1517 ;; moved mode-definition behind defun-definition to be warning-free - 15.11.02/RSan
1518 (define-generic-mode rul-generic-mode
1519 ;; Using "/*" and "*/" doesn't seem to be working right
1520 '("//" ("/*" .
"*/" ))
1521 (eval-when-compile installshield-statement-keyword-list
)
1524 ;; preprocessor constructs
1525 '("#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)"
1526 1 font-lock-string-face
)
1527 '("#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
1528 (1 font-lock-reference-face
)
1529 (2 font-lock-variable-name-face nil t
))
1530 ;; indirect string constants
1531 '("\\(@[A-Za-z][A-Za-z0-9_]+\\)" 1 font-lock-builtin-face
)
1533 '("[ \t]*\\(\\sw+:\\)" 1 font-lock-reference-face
)
1534 '("\\<\\(goto\\)\\>[ \t]*\\(\\sw+\\)?"
1535 (1 font-lock-keyword-face
)
1536 (2 font-lock-reference-face nil t
))
1538 (generic-make-keywords-list
1539 installshield-system-variables-list
1540 font-lock-variable-name-face
"[^_]" "[^_]")
1542 (generic-make-keywords-list
1543 installshield-system-functions-list
1544 font-lock-function-name-face
"[^_]" "[^_]")
1546 (generic-make-keywords-list
1547 installshield-types-list
1548 font-lock-type-face
"[^_]" "[^_]")
1549 ;; function argument constants
1550 (generic-make-keywords-list
1551 installshield-funarg-constants-list
1552 font-lock-variable-name-face
"[^_]" "[^_]"))) ; is this face the best choice?
1553 '("\\.[rR][uU][lL]\\'")
1554 '(generic-rul-mode-setup-function)
1555 "Generic mode for InstallShield RUL files.")
1557 (define-skeleton rul-if
1558 "Insert an if statement."
1560 "if(" str
") then" \n
1562 ( "other condition, %s: "
1563 > "elseif(" str
") then" \n
1570 (define-skeleton rul-function
1571 "Insert a function statement."
1573 "function " str
" ()" \n
1574 ( "local variables, %s: "
1581 ;; Additions by ACorreir@pervasive-sw.com (Alfred Correira)
1582 (when (memq 'mailrc-generic-mode generic-extras-enable-list
)
1584 (define-generic-mode mailrc-generic-mode
1595 '(("^\\s-*\\(alias\\|group\\)\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1596 (2 font-lock-constant-face
)
1597 (3 font-lock-variable-name-face
))
1598 ("^\\s-*\\(unset\\|set\\|ignore\\)\\s-+\\([-A-Za-z0-9_]+\\)=?\\([^\n\r#]*\\)\\(#.*\\)?$"
1599 (2 font-lock-constant-face
)
1600 (3 font-lock-variable-name-face
))
1601 ("^\\s-*\\(source\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1602 (2 font-lock-variable-name-face
)))
1605 "Mode for mailrc files."))
1608 (when (memq 'inetd-conf-generic-mode generic-extras-enable-list
)
1610 (define-generic-mode inetd-conf-generic-mode
1619 '(("^\\([-A-Za-z0-9_]+\\)" 1 font-lock-type-face
))
1620 '("/etc/inetd.conf\\'")
1624 (setq imenu-generic-expression
1625 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1628 (when (memq 'etc-services-generic-mode generic-extras-enable-list
)
1630 (define-generic-mode etc-services-generic-mode
1635 '(("^\\([-A-Za-z0-9_]+\\)\\s-+\\([0-9]+\\)/"
1636 (1 font-lock-type-face
)
1637 (2 font-lock-variable-name-face
)))
1638 '("/etc/services\\'")
1642 (setq imenu-generic-expression
1643 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1645 ;; Password and Group files
1646 (when (memq 'etc-passwd-generic-mode generic-extras-enable-list
)
1648 (define-generic-mode etc-passwd-generic-mode
1649 nil
;; No comment characters
1650 '("root") ;; Only one keyword
1656 ;; User name -- Never blank!
1659 ;; Password, UID and GID
1662 (make-list 3 "\\([^:]+\\)")
1665 ;; GECOS/Name -- might be blank
1668 ;; Home directory and shell
1673 '(1 font-lock-type-face
)
1674 '(5 font-lock-variable-name-face
)
1675 '(6 font-lock-constant-face
)
1676 '(7 font-lock-warning-face
))
1677 '("^\\([^:]+\\):\\([^:]*\\):\\([0-9]+\\):\\(.*\\)$"
1678 (1 font-lock-type-face
)
1679 (4 font-lock-variable-name-face
))))
1680 '("/etc/passwd\\'" "/etc/group\\'")
1684 (setq imenu-generic-expression
1685 '((nil "^\\([-A-Za-z0-9_]+\\):" 1))))))))
1688 (when (memq 'etc-fstab-generic-mode generic-extras-enable-list
)
1690 (define-generic-mode etc-fstab-generic-mode
1729 '(("^\\([^# \t]+\\)\\s-+\\([^# \t]+\\)"
1730 (1 font-lock-type-face t
)
1731 (2 font-lock-variable-name-face t
)))
1732 '("/etc/[v]*fstab\\'")
1736 (setq imenu-generic-expression
1737 '((nil "^\\([^# \t]+\\)\\s-+" 1))))))))
1739 ;; From Jacques Duthen <jacques.duthen@sncf.fr>
1740 (when (memq 'show-tabs-generic-mode generic-extras-enable-list
)
1744 (defconst show-tabs-generic-mode-font-lock-defaults-1
1745 '(;; trailing spaces must come before...
1746 ("[ \t]+$" .
'show-tabs-space
)
1748 ("[^\n\t]\\(\t+\\)" (1 'show-tabs-tab
))))
1750 (defconst show-tabs-generic-mode-font-lock-defaults-2
1751 '(;; trailing spaces must come before...
1752 ("[ \t]+$" .
'show-tabs-space
)
1754 ("\t+" .
'show-tabs-tab
))))
1756 (defface show-tabs-tab
1757 '((((class grayscale
) (background light
)) (:background
"DimGray" :weight bold
))
1758 (((class grayscale
) (background dark
)) (:background
"LightGray" :weight bold
))
1759 (((class color
) (min-colors 88)) (:background
"red1"))
1760 (((class color
)) (:background
"red"))
1762 "Font Lock mode face used to highlight TABs."
1764 ;; backward-compatibility alias
1765 (put 'show-tabs-tab-face
'face-alias
'show-tabs-tab
)
1767 (defface show-tabs-space
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
"yellow1"))
1771 (((class color
)) (:background
"yellow"))
1773 "Font Lock mode face used to highlight spaces."
1775 ;; backward-compatibility alias
1776 (put 'show-tabs-space-face
'face-alias
'show-tabs-space
)
1778 (define-generic-mode show-tabs-generic-mode
1779 nil
;; no comment char
1781 (eval-when-compile show-tabs-generic-mode-font-lock-defaults-1
)
1782 nil
;; no auto-mode-alist
1783 ;; '(show-tabs-generic-mode-hook-fun)
1785 "Generic mode to show tabs and trailing spaces."))
1787 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1789 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1791 (when (memq 'named-boot-generic-mode generic-extras-enable-list
)
1793 (define-generic-mode named-boot-generic-mode
1794 ;; List of comment characters
1797 '("cache" "primary" "secondary" "forwarders" "limit" "options"
1798 "directory" "check-names")
1799 ;; List of additional font-lock-expressions
1800 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face
)
1801 ("^directory\\s-+\\(.*\\)" 1 font-lock-variable-name-face
)
1802 ("^\\(primary\\|cache\\)\\s-+\\([.A-Za-z]+\\)\\s-+\\(.*\\)"
1803 (2 font-lock-variable-name-face
)
1804 (3 font-lock-constant-face
)))
1805 ;; List of additional automode-alist expressions
1806 '("/etc/named.boot\\'")
1807 ;; List of set up functions to call
1810 (when (memq 'named-database-generic-mode generic-extras-enable-list
)
1812 (define-generic-mode named-database-generic-mode
1813 ;; List of comment characters
1816 '("IN" "NS" "CNAME" "SOA" "PTR" "MX" "A")
1817 ;; List of additional font-lock-expressions
1818 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face
)
1819 ("^\\([.A-Za-z0-9]+\\)" 1 font-lock-variable-name-face
))
1820 ;; List of additional auto-mode-alist expressions
1822 ;; List of set up functions to call
1825 (defvar named-database-time-string
"%Y%m%d%H"
1826 "Timestring for named serial numbers.")
1828 (defun named-database-print-serial ()
1829 "Print a serial number based on the current date."
1831 (insert (format-time-string named-database-time-string
(current-time)))))
1833 (when (memq 'resolve-conf-generic-mode generic-extras-enable-list
)
1835 (define-generic-mode resolve-conf-generic-mode
1836 ;; List of comment characters
1839 '("nameserver" "domain" "search" "sortlist" "options")
1840 ;; List of additional font-lock-expressions
1842 ;; List of additional auto-mode-alist expressions
1843 '("/etc/resolv[e]?.conf\\'")
1844 ;; List of set up functions to call
1847 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1848 ;; Modes for spice and common electrical engineering circuit netlist formats
1849 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1851 (when (memq 'spice-generic-mode generic-extras-enable-list
)
1853 (define-generic-mode spice-generic-mode
1870 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1871 (" \\(\\$ .*\\)$" 1 font-lock-comment-face
)
1872 ("^\\(\\$ .*\\)$" 1 font-lock-comment-face
)
1873 ("\\([*].*\\)" 1 font-lock-comment-face
)
1874 ("^\\([+]\\)" 1 font-lock-string-face
)
1875 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face
)
1876 ("\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
)
1877 ("\\('[^']+'\\)" 1 font-lock-string-face
)
1878 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face
))
1880 "\\.[sS][pP][iI]\\'"
1881 "\\.[sS][pP][iI][cC][eE]\\'"
1882 "\\.[iI][nN][cC]\\'")
1884 'generic-bracket-support
1885 ;; Make keywords case-insensitive
1888 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
)))))
1889 "Generic mode for SPICE circuit netlist files."))
1891 (when (memq 'ibis-generic-mode generic-extras-enable-list
)
1893 (define-generic-mode ibis-generic-mode
1896 '(("[[]\\([^]]*\\)[]]" 1 font-lock-keyword-face
)
1897 ("\\(\\(_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
))
1898 '("\\.[iI][bB][sS]\\'")
1899 '(generic-bracket-support)
1900 "Generic mode for IBIS circuit netlist files."))
1902 (when (memq 'astap-generic-mode generic-extras-enable-list
)
1904 (define-generic-mode astap-generic-mode
1919 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1920 (";\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1921 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face
)
1922 ("\\('[^']+'\\)" 1 font-lock-string-face
)
1923 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face
)
1924 ("[(,]\\s-*\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
))
1926 "\\.[aA][sS][xX]\\'"
1927 "\\.[aA][sS][tT][aA][pP]\\'"
1928 "\\.[pP][sS][pP]\\'"
1929 "\\.[dD][eE][cC][kK]\\'"
1930 "\\.[gG][oO][dD][aA][tT][aA]")
1932 'generic-bracket-support
1933 ;; Make keywords case-insensitive
1936 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
)))))
1937 "Generic mode for ASTAP circuit netlist files."))
1939 (when (memq 'etc-modules-conf-generic-mode generic-extras-enable-list
)
1941 (define-generic-mode etc-modules-conf-generic-mode
1942 ;; List of comment characters
1960 "generic_stringfile"
1976 ;; List of additional font-lock-expressions
1978 ;; List of additional automode-alist expressions
1979 '("/etc/modules.conf" "/etc/conf.modules")
1980 ;; List of set up functions to call
1983 (provide 'generic-x
)
1985 ;;; arch-tag: cde692a5-9ff6-4506-9999-c67999c2bdb5
1986 ;;; generic-x.el ends here