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, 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
224 etc-sudoers-generic-mode
226 inetd-conf-generic-mode
227 mailagent-rules-generic-mode
229 named-boot-generic-mode
230 named-database-generic-mode
231 prototype-generic-mode
232 resolve-conf-generic-mode
234 x-resource-generic-mode
)
235 "List of generic modes that are defined by default on Unix.")
237 (defconst generic-other-modes
242 "List of generic mode that are not defined by default.")
244 (defcustom generic-define-mswindows-modes
245 (memq system-type
'(windows-nt ms-dos
))
246 "*Non-nil means the modes in `generic-mswindows-modes' will be defined.
247 This is a list of MS-Windows specific generic modes. This variable
248 only affects the default value of `generic-extras-enable-list'."
252 (make-obsolete-variable 'generic-define-mswindows-modes
'generic-extras-enable-list
"22.1")
254 (defcustom generic-define-unix-modes
255 (not (memq system-type
'(windows-nt ms-dos
)))
256 "*Non-nil means the modes in `generic-unix-modes' will be defined.
257 This is a list of Unix specific generic modes. This variable only
258 affects the default value of `generic-extras-enable-list'."
262 (make-obsolete-variable 'generic-define-unix-modes
'generic-extras-enable-list
"22.1")
264 (defcustom generic-extras-enable-list
265 (append generic-default-modes
266 (if generic-define-mswindows-modes generic-mswindows-modes
)
267 (if generic-define-unix-modes generic-unix-modes
)
269 "List of generic modes to define.
270 Each entry in the list should be a symbol. If you set this variable
271 directly, without using customize, you must reload generic-x to put
272 your changes into effect."
276 (sort (append generic-default-modes
277 generic-mswindows-modes
282 (string< (symbol-name b
)
285 (push `(const ,mode
) list
)))
288 (unless load-in-progress
293 (when (memq 'apache-conf-generic-mode generic-extras-enable-list
)
295 (define-generic-mode apache-conf-generic-mode
298 '(("^\\s-*\\(<.*>\\)" 1 font-lock-constant-face
)
299 ("^\\s-*\\(\\sw+\\)\\s-" 1 font-lock-variable-name-face
))
300 '("srm\\.conf\\'" "httpd\\.conf\\'" "access\\.conf\\'")
304 (setq imenu-generic-expression
305 '((nil "^\\([-A-Za-z0-9_]+\\)" 1)
306 ("*Directories*" "^\\s-*<Directory\\s-*\\([^>]+\\)>" 1)
307 ("*Locations*" "^\\s-*<Location\\s-*\\([^>]+\\)>" 1))))))
308 "Generic mode for Apache or HTTPD configuration files."))
310 (when (memq 'apache-log-generic-mode generic-extras-enable-list
)
312 (define-generic-mode apache-log-generic-mode
315 ;; Hostname ? user date request return-code number-of-bytes
316 '(("^\\([-a-zA-z0-9.]+\\) - [-A-Za-z]+ \\(\\[.*\\]\\)"
317 (1 font-lock-constant-face
)
318 (2 font-lock-variable-name-face
)))
321 "Mode for Apache log files."))
324 (when (memq 'samba-generic-mode generic-extras-enable-list
)
326 (define-generic-mode samba-generic-mode
329 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face
)
330 ("^\\s-*\\(.+\\)=\\([^\r\n]*\\)"
331 (1 font-lock-variable-name-face
)
332 (2 font-lock-type-face
)))
334 '(generic-bracket-support)
335 "Generic mode for Samba configuration files."))
338 ;; This is pretty basic. Also, modes for other window managers could
339 ;; be defined as well.
340 (when (memq 'fvwm-generic-mode generic-extras-enable-list
)
342 (define-generic-mode fvwm-generic-mode
358 '("\\.fvwmrc\\'" "\\.fvwm2rc\\'")
360 "Generic mode for FVWM configuration files."))
363 ;; I'm pretty sure I've seen an actual mode to do this, but I don't
364 ;; think it's standard with Emacs
365 (when (memq 'x-resource-generic-mode generic-extras-enable-list
)
367 (define-generic-mode x-resource-generic-mode
370 '(("^\\([^:\n]+:\\)" 1 font-lock-variable-name-face
))
371 '("\\.Xdefaults\\'" "\\.Xresources\\'" "\\.Xenvironment\\'" "\\.ad\\'")
373 "Generic mode for X Resource configuration files."))
376 (when (memq 'hosts-generic-mode generic-extras-enable-list
)
378 (define-generic-mode hosts-generic-mode
381 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face
))
382 '("[hH][oO][sS][tT][sS]\\'")
384 "Generic mode for HOSTS files."))
386 ;;; Windows INF files
388 ;; If i-g-m-f-f-h is defined, then so is i-g-m.
389 (declare-function ini-generic-mode
"generic-x")
391 (when (memq 'inf-generic-mode generic-extras-enable-list
)
393 (define-generic-mode inf-generic-mode
396 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face
))
397 '("\\.[iI][nN][fF]\\'")
398 '(generic-bracket-support)
399 "Generic mode for MS-Windows INF files."))
401 ;;; Windows INI files
402 ;; Should define escape character as well!
403 (when (memq 'ini-generic-mode generic-extras-enable-list
)
405 (define-generic-mode ini-generic-mode
408 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face
)
409 ("^\\([^=\n\r]*\\)=\\([^\n\r]*\\)$"
410 (1 font-lock-function-name-face
)
411 (2 font-lock-variable-name-face
)))
412 '("\\.[iI][nN][iI]\\'")
416 (setq imenu-generic-expression
417 '((nil "^\\[\\(.*\\)\\]" 1)
418 ("*Variables*" "^\\s-*\\([^=]+\\)\\s-*=" 1))))))
419 "Generic mode for MS-Windows INI files.
420 You can use `ini-generic-mode-find-file-hook' to enter this mode
421 automatically for INI files whose names do not end in \".ini\".")
423 (defun ini-generic-mode-find-file-hook ()
424 "Hook function to enter Ini-Generic mode automatically for INI files.
425 Done if the first few lines of a file in Fundamental mode look
426 like an INI file. You can add this hook to `find-file-hook'."
427 (and (eq major-mode
'fundamental-mode
)
429 (goto-char (point-min))
430 (and (looking-at "^\\s-*\\[.*\\]")
431 (ini-generic-mode)))))
432 (defalias 'generic-mode-ini-file-find-file-hook
'ini-generic-mode-find-file-hook
))
434 ;;; Windows REG files
435 ;;; Unfortunately, Windows 95 and Windows NT have different REG file syntax!
436 (when (memq 'reg-generic-mode generic-extras-enable-list
)
438 (define-generic-mode reg-generic-mode
440 '("key" "classes_root" "REGEDIT" "REGEDIT4")
441 '(("\\(\\[.*\\]\\)" 1 font-lock-constant-face
)
442 ("^\\([^\n\r]*\\)\\s-*=" 1 font-lock-variable-name-face
))
443 '("\\.[rR][eE][gG]\\'")
447 (setq imenu-generic-expression
448 '((nil "^\\s-*\\(.*\\)\\s-*=" 1))))))
449 "Generic mode for MS-Windows Registry files."))
451 (declare-function w32-shell-name
"w32-fns" ())
453 ;;; DOS/Windows BAT files
454 (when (memq 'bat-generic-mode generic-extras-enable-list
)
456 (define-generic-mode bat-generic-mode
461 ;; Make this one first in the list, otherwise comments will
462 ;; be over-written by other variables
463 '("^[@ \t]*\\([rR][eE][mM][^\n\r]*\\)" 1 font-lock-comment-face t
)
464 '("^[ \t]*\\(::.*\\)" 1 font-lock-comment-face t
)
465 '("^[@ \t]*\\([bB][rR][eE][aA][kK]\\|[vV][eE][rR][iI][fF][yY]\\)[ \t]+\\([oO]\\([nN]\\|[fF][fF]\\)\\)"
466 (1 font-lock-builtin-face
)
467 (2 font-lock-constant-face t t
))
468 ;; Any text (except ON/OFF) following ECHO is a string.
469 '("^[@ \t]*\\([eE][cC][hH][oO]\\)[ \t]+\\(\\([oO]\\([nN]\\|[fF][fF]\\)\\)\\|\\([^>|\r\n]+\\)\\)"
470 (1 font-lock-builtin-face
)
471 (3 font-lock-constant-face t t
)
472 (5 font-lock-string-face t t
))
473 ;; These keywords appear as the first word on a line. (Actually, they
474 ;; can also appear after "if ..." or "for ..." clause, but since they
475 ;; are frequently used in simple text, we punt.)
476 ;; In `generic-bat-mode-setup-function' we make the keywords
478 (generic-make-keywords-list
481 font-lock-keyword-face
"^[@ \t]*")
482 ;; These keywords can be anywhere on a line
483 ;; In `generic-bat-mode-setup-function' we make the keywords
485 (generic-make-keywords-list
491 font-lock-keyword-face
)
492 ;; These are built-in commands. Only frequently-used ones are listed.
493 (generic-make-keywords-list
494 '("CALL" "call" "Call"
502 "PAUSE" "pause" "Pause"
503 "PROMPT" "prompt" "Prompt"
507 "START" "start" "Start"
508 "SHIFT" "shift" "Shift")
509 font-lock-builtin-face
"[ \t|\n]")
510 '("^[ \t]*\\(:\\sw+\\)" 1 font-lock-function-name-face t
)
511 '("\\(%\\sw+%\\)" 1 font-lock-variable-name-face t
)
512 '("\\(%[0-9]\\)" 1 font-lock-variable-name-face t
)
513 '("\\(/[^/ \"\t\n]+\\)" 1 font-lock-type-face
)
514 '("[\t ]+\\([+-][^\t\n\" ]+\\)" 1 font-lock-type-face
)
515 '("[ \t\n|]\\<\\([gG][oO][tT][oO]\\)\\>[ \t]*\\(\\sw+\\)?"
516 (1 font-lock-keyword-face
)
517 (2 font-lock-function-name-face nil t
))
518 '("[ \t\n|]\\<\\([sS][eE][tT]\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*=?"
519 (1 font-lock-builtin-face
)
520 (2 font-lock-variable-name-face t t
))))
521 '("\\.[bB][aA][tT]\\'"
523 "\\`[cC][oO][nN][fF][iI][gG]\\."
524 "\\`[aA][uU][tT][oO][eE][xX][eE][cC]\\.")
525 '(generic-bat-mode-setup-function)
526 "Generic mode for MS-Windows batch files.")
528 (defvar bat-generic-mode-syntax-table nil
529 "Syntax table in use in `bat-generic-mode' buffers.")
531 (defvar bat-generic-mode-keymap
(make-sparse-keymap)
532 "Keymap for `bat-generic-mode'.")
534 (defun bat-generic-mode-compile ()
535 "Run the current BAT file in a compilation buffer."
537 (let ((compilation-buffer-name-function
540 (concat "*" (buffer-file-name) "*")))))
542 (concat (w32-shell-name) " -c " (buffer-file-name)))))
544 (eval-when-compile (require 'comint
))
545 (defun bat-generic-mode-run-as-comint ()
546 "Run the current BAT file in a comint buffer."
549 (let* ((file (buffer-file-name))
550 (buf-name (concat "*" file
"*")))
553 (get-buffer-create buf-name
))
562 (display-buffer buf-name
))))
564 (define-key bat-generic-mode-keymap
"\C-c\C-c" 'bat-generic-mode-compile
)
566 ;; Make underscores count as words
567 (unless bat-generic-mode-syntax-table
568 (setq bat-generic-mode-syntax-table
(make-syntax-table))
569 (modify-syntax-entry ?_
"w" bat-generic-mode-syntax-table
))
571 ;; bat-generic-mode doesn't use the comment functionality of
572 ;; define-generic-mode because it has a three-letter comment-string,
573 ;; so we do it here manually instead
574 (defun generic-bat-mode-setup-function ()
575 (make-local-variable 'parse-sexp-ignore-comments
)
576 (make-local-variable 'comment-start
)
577 (make-local-variable 'comment-start-skip
)
578 (make-local-variable 'comment-end
)
579 (setq imenu-generic-expression
'((nil "^:\\(\\sw+\\)" 1))
580 parse-sexp-ignore-comments t
583 comment-start-skip
"[Rr][Ee][Mm] *")
584 (set-syntax-table bat-generic-mode-syntax-table
)
585 ;; Make keywords case-insensitive
586 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
))
587 (use-local-map bat-generic-mode-keymap
)))
590 ;; Mailagent is a Unix mail filtering program. Anyone wanna do a
591 ;; generic mode for procmail?
592 (when (memq 'mailagent-rules-generic-mode generic-extras-enable-list
)
594 (define-generic-mode mailagent-rules-generic-mode
596 '("SAVE" "DELETE" "PIPE" "ANNOTATE" "REJECT")
597 '(("^\\(\\sw+\\)\\s-*=" 1 font-lock-variable-name-face
)
598 ("\\s-/\\([^/]+\\)/[i, \t\n]" 1 font-lock-constant-face
))
603 (setq imenu-generic-expression
604 '((nil "\\s-/\\([^/]+\\)/[i, \t\n]" 1))))))
605 "Mode for Mailagent rules files."))
607 ;; Solaris/Sys V prototype files
608 (when (memq 'prototype-generic-mode generic-extras-enable-list
)
610 (define-generic-mode prototype-generic-mode
613 '(("^\\([0-9]\\)?\\s-*\\([a-z]\\)\\s-+\\([A-Za-z_]+\\)\\s-+\\([^\n\r]*\\)$"
614 (2 font-lock-constant-face
)
615 (3 font-lock-keyword-face
))
616 ("^\\([a-z]\\) \\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
617 (1 font-lock-constant-face
)
618 (2 font-lock-keyword-face
)
619 (3 font-lock-variable-name-face
))
620 ("^\\(!\\s-*\\(search\\|include\\|default\\)\\)\\s-*\\([^\n\r]*\\)$"
621 (1 font-lock-keyword-face
)
622 (3 font-lock-variable-name-face
))
623 ("^\\(!\\s-*\\sw+\\)=\\([^\n\r]*\\)$"
624 (1 font-lock-keyword-face
)
625 (2 font-lock-variable-name-face
)))
628 "Mode for Sys V prototype files."))
630 ;; Solaris/Sys V pkginfo files
631 (when (memq 'pkginfo-generic-mode generic-extras-enable-list
)
633 (define-generic-mode pkginfo-generic-mode
636 '(("^\\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
637 (1 font-lock-keyword-face
)
638 (2 font-lock-variable-name-face
)))
641 "Mode for Sys V pkginfo files."))
644 ;; Includes extra keywords from Armando Singer [asinger@MAIL.COLGATE.EDU]
645 (when (memq 'javascript-generic-mode generic-extras-enable-list
)
647 (define-generic-mode javascript-generic-mode
648 '("//" ("/*" .
"*/"))
671 ;; words reserved for ECMA extensions below
682 ;; Java Keywords reserved by JavaScript
709 '(("^\\s-*function\\s-+\\([A-Za-z0-9_]+\\)"
710 (1 font-lock-function-name-face
))
711 ("^\\s-*var\\s-+\\([A-Za-z0-9_]+\\)"
712 (1 font-lock-variable-name-face
)))
717 (setq imenu-generic-expression
718 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1)
719 ("*Variables*" "^var\\s-+\\([A-Za-z0-9_]+\\)" 1))))))
720 "Mode for JavaScript files."))
723 (when (memq 'vrml-generic-mode generic-extras-enable-list
)
725 (define-generic-mode vrml-generic-mode
755 '(("USE\\s-+\\([-A-Za-z0-9_]+\\)"
756 (1 font-lock-constant-face
))
757 ("DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
758 (1 font-lock-type-face
)
759 (2 font-lock-constant-face
))
760 ("^\\s-*\\([-A-Za-z0-9_]+\\)\\s-*{"
761 (1 font-lock-function-name-face
))
762 ("^\\s-*\\(geometry\\|appearance\\|material\\)\\s-+\\([-A-Za-z0-9_]+\\)"
763 (2 font-lock-variable-name-face
)))
768 (setq imenu-generic-expression
769 '((nil "^\\([A-Za-z0-9_]+\\)\\s-*{" 1)
771 "DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
773 "Generic Mode for VRML files."))
776 (when (memq 'java-manifest-generic-mode generic-extras-enable-list
)
778 (define-generic-mode java-manifest-generic-mode
788 '(("^Name:\\s-+\\([^\n\r]*\\)$"
789 (1 font-lock-variable-name-face
))
790 ("^\\(Manifest\\|Required\\|Signature\\)-Version:\\s-+\\([^\n\r]*\\)$"
791 (2 font-lock-constant-face
)))
792 '("[mM][aA][nN][iI][fF][eE][sS][tT]\\.[mM][fF]\\'")
794 "Mode for Java Manifest files."))
796 ;; Java properties files
797 (when (memq 'java-properties-generic-mode generic-extras-enable-list
)
799 (define-generic-mode java-properties-generic-mode
803 (let ((java-properties-key
804 "\\(\\([-A-Za-z0-9_\\./]\\|\\(\\\\[ =:]\\)\\)+\\)")
805 (java-properties-value
807 ;; Property and value can be separated in a number of different ways:
815 (concat "^" java-properties-key elt java-properties-value
"$")
816 '(1 font-lock-constant-face
)
817 '(4 font-lock-variable-name-face
))))
818 ;; These are the separators
819 '(":\\s-*" "\\s-+" "\\s-*=\\s-*"))))
824 (setq imenu-generic-expression
825 '((nil "^\\([^#! \t\n\r=:]+\\)" 1))))))
826 "Mode for Java properties files."))
828 ;; C shell alias definitions
829 (when (memq 'alias-generic-mode generic-extras-enable-list
)
831 (define-generic-mode alias-generic-mode
834 '(("^alias\\s-+\\([-A-Za-z0-9_]+\\)\\s-+"
835 (1 font-lock-variable-name-face
))
836 ("^unalias\\s-+\\([-A-Za-z0-9_]+\\)\\s-*$"
837 (1 font-lock-variable-name-face
)))
842 (setq imenu-generic-expression
843 '((nil "^\\(alias\\|unalias\\)\\s-+\\([-a-zA-Z0-9_]+\\)" 2))))))
844 "Mode for C Shell alias files."))
847 ;; Contributed by ACorreir@pervasive-sw.com (Alfred Correira)
848 (when (memq 'rc-generic-mode generic-extras-enable-list
)
850 (define-generic-mode rc-generic-mode
905 ;; the choice of what tokens go where is somewhat arbitrary,
906 ;; as is the choice of which value tokens are included, as
907 ;; the choice of face for each token group
910 (generic-make-keywords-list
919 (generic-make-keywords-list
924 font-lock-function-name-face
)
925 '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face
)
926 '("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face
)
927 '("^#[ \t]*\\(elif\\|if\\)\\>"
928 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil
929 (1 font-lock-constant-face
)
930 (2 font-lock-variable-name-face nil t
)))
931 '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
932 (1 font-lock-constant-face
)
933 (2 font-lock-variable-name-face nil t
))))
936 "Generic mode for MS-Windows Resource files."))
938 ;; InstallShield RUL files
939 ;; Contributed by Alfred.Correira@Pervasive.Com
940 ;; Bugfixes by "Rolf Sandau" <Rolf.Sandau@marconi.com>
941 (when (memq 'rul-generic-mode generic-extras-enable-list
)
945 ;;; build the regexp strings using regexp-opt
946 (defconst installshield-statement-keyword-list
965 ;; "goto" -- handled elsewhere
979 "Statement keywords used in InstallShield 3 and 5.")
981 (defconst installshield-system-functions-list
1001 "ComponentAddItem" ; differs between IS3 and IS5
1002 "ComponentCompareSizeRequired" ; IS5 only
1004 "ComponentError" ; IS5 only
1005 "ComponentFileEnum" ; IS5 only
1006 "ComponentFileInfo" ; IS5 only
1007 "ComponentFilterLanguage" ; IS5 only
1008 "ComponentFilterOS" ; IS5 only
1009 "ComponentGetData" ; IS5 only
1010 "ComponentGetItemInfo" ; IS3 only
1011 "ComponentGetItemSize" ; differs between IS3 and IS5
1012 "ComponentIsItemSelected" ; differs between IS3 and IS5
1013 "ComponentListItems"
1014 "ComponentMoveData" ; IS5 only
1015 "ComponentSelectItem" ; differs between IS3 and IS5
1016 "ComponentSetData" ; IS5 only
1017 "ComponentSetItemInfo" ; IS3 only
1018 "ComponentSetTarget" ; IS5 only
1019 "ComponentSetupTypeEnum" ; IS5 only
1020 "ComponentSetupTypeGetData" ; IS5 only
1021 "ComponentSetupTypeSet" ; IS5 only
1022 "ComponentTotalSize"
1023 "ComponentValidate" ; IS5 only
1024 "CompressAdd" ; IS3 only
1025 "CompressDel" ; IS3 only
1026 "CompressEnum" ; IS3 only
1027 "CompressGet" ; IS3 only
1028 "CompressInfo" ; IS3 only
1032 "CreateProgramFolder"
1033 "DeinstallSetReference" ; IS5 only
1059 "FileSetBeginDefine" ; IS3 only
1060 "FileSetEndDefine" ; IS3 only
1061 "FileSetPerformEz" ; IS3 only
1062 "FileSetPerform" ; IS3 only
1063 "FileSetReset" ; IS3 only
1064 "FileSetRoot" ; IS3 only
1078 "GetValidDrivesList"
1093 "ListGetFirstString"
1097 "ListSetCurrentItem"
1103 "LongPathToShortPath"
1118 "PlayMMedia" ; IS5 only
1125 "RegDBGetKeyValueEx"
1126 "RegDBSetKeyValueEx"
1127 "RegDBSetDefaultRoot"
1136 "SdComponentAdvCheckSpace"
1137 "SdComponentAdvInit"
1138 "SdComponentAdvUpdateSpace"
1140 "SdComponentDialog2"
1141 "SdComponentDialogAdv"
1142 "SdComponentDialogEx"
1143 "SdComponentDlgCheckSpace"
1146 "SdConfirmRegistration"
1158 "SdGetUserCompanyInfo"
1167 "SdOptionsButtonsInit"
1168 "SdPlugInProductName"
1171 "SdRegExEnableButton"
1176 "SdSetSequentialItems"
1178 "SdSetupTypeEx" ; IS5 only
1189 "SdUpdateComponentSelection"
1195 "SetDisplayEffect" ; IS5 only
1197 "SetForegroundWindow"
1210 "StrRemoveLastSlash"
1224 "System functions defined in InstallShield 3 and 5.")
1226 (defconst installshield-system-variables-list
1230 "CORECOMPONENTHANDLING"
1256 "System variables used in InstallShield 3 and 5.")
1258 (defconst installshield-types-list
1277 "Type keywords used in InstallShield 3 and 5.")
1279 ;;; some might want to skip highlighting these to improve performance
1280 (defconst installshield-funarg-constants-list
1310 "COMP_UPDATE_VERSION"
1329 "DLG_INFO_CHECKSELECTION"
1331 "DLG_INFO_USEDECIMAL"
1332 "DLG_MSG_INFORMATION"
1353 "FILE_ATTR_ARCHIVED"
1354 "FILE_ATTR_DIRECTORY"
1357 "FILE_ATTR_READONLY"
1363 "FILE_MODE_BINARYREADONLY"
1385 "HKEY_LOCAL_MACHINE"
1430 "REGDB_APPPATH_DEFAULT"
1433 "REGDB_ERR_CONNECTIONEXISTS"
1434 "REGDB_ERR_CORRUPTEDREGSITRY"
1435 "REGDB_ERR_INITIALIZATION"
1436 "REGDB_ERR_INVALIDHANDLE"
1437 "REGDB_ERR_INVALIDNAME"
1439 "REGDB_STRING_EXPAND"
1440 "REGDB_STRING_MULTI"
1442 "REGDB_UNINSTALL_NAME"
1486 "Function argument constants used in InstallShield 3 and 5."))
1488 (defvar rul-generic-mode-syntax-table nil
1489 "Syntax table to use in `rul-generic-mode' buffers.")
1491 (setq rul-generic-mode-syntax-table
1492 (make-syntax-table c
++-mode-syntax-table
))
1494 (modify-syntax-entry ?
\r "> b" rul-generic-mode-syntax-table
)
1495 (modify-syntax-entry ?
\n "> b" rul-generic-mode-syntax-table
)
1497 (modify-syntax-entry ?
/ ". 124b" rul-generic-mode-syntax-table
)
1498 (modify-syntax-entry ?
* ". 23" rul-generic-mode-syntax-table
)
1500 ;; here manually instead
1501 (defun generic-rul-mode-setup-function ()
1502 (make-local-variable 'parse-sexp-ignore-comments
)
1503 (make-local-variable 'comment-start
)
1504 (make-local-variable 'comment-start-skip
)
1505 (make-local-variable 'comment-end
)
1506 (setq imenu-generic-expression
1507 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1))
1508 parse-sexp-ignore-comments t
1512 ;;; comment-start "//"
1513 ;;; comment-start-skip ""
1515 ;; (set-syntax-table rul-generic-mode-syntax-table)
1516 (setq font-lock-syntax-table rul-generic-mode-syntax-table
))
1518 ;; moved mode-definition behind defun-definition to be warning-free - 15.11.02/RSan
1519 (define-generic-mode rul-generic-mode
1520 ;; Using "/*" and "*/" doesn't seem to be working right
1521 '("//" ("/*" .
"*/" ))
1522 (eval-when-compile installshield-statement-keyword-list
)
1525 ;; preprocessor constructs
1526 '("#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)"
1527 1 font-lock-string-face
)
1528 '("#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
1529 (1 font-lock-reference-face
)
1530 (2 font-lock-variable-name-face nil t
))
1531 ;; indirect string constants
1532 '("\\(@[A-Za-z][A-Za-z0-9_]+\\)" 1 font-lock-builtin-face
)
1534 '("[ \t]*\\(\\sw+:\\)" 1 font-lock-reference-face
)
1535 '("\\<\\(goto\\)\\>[ \t]*\\(\\sw+\\)?"
1536 (1 font-lock-keyword-face
)
1537 (2 font-lock-reference-face nil t
))
1539 (generic-make-keywords-list
1540 installshield-system-variables-list
1541 font-lock-variable-name-face
"[^_]" "[^_]")
1543 (generic-make-keywords-list
1544 installshield-system-functions-list
1545 font-lock-function-name-face
"[^_]" "[^_]")
1547 (generic-make-keywords-list
1548 installshield-types-list
1549 font-lock-type-face
"[^_]" "[^_]")
1550 ;; function argument constants
1551 (generic-make-keywords-list
1552 installshield-funarg-constants-list
1553 font-lock-variable-name-face
"[^_]" "[^_]"))) ; is this face the best choice?
1554 '("\\.[rR][uU][lL]\\'")
1555 '(generic-rul-mode-setup-function)
1556 "Generic mode for InstallShield RUL files.")
1558 (define-skeleton rul-if
1559 "Insert an if statement."
1561 "if(" str
") then" \n
1563 ( "other condition, %s: "
1564 > "elseif(" str
") then" \n
1571 (define-skeleton rul-function
1572 "Insert a function statement."
1574 "function " str
" ()" \n
1575 ( "local variables, %s: "
1582 ;; Additions by ACorreir@pervasive-sw.com (Alfred Correira)
1583 (when (memq 'mailrc-generic-mode generic-extras-enable-list
)
1585 (define-generic-mode mailrc-generic-mode
1596 '(("^\\s-*\\(alias\\|group\\)\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1597 (2 font-lock-constant-face
)
1598 (3 font-lock-variable-name-face
))
1599 ("^\\s-*\\(unset\\|set\\|ignore\\)\\s-+\\([-A-Za-z0-9_]+\\)=?\\([^\n\r#]*\\)\\(#.*\\)?$"
1600 (2 font-lock-constant-face
)
1601 (3 font-lock-variable-name-face
))
1602 ("^\\s-*\\(source\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1603 (2 font-lock-variable-name-face
)))
1606 "Mode for mailrc files."))
1609 (when (memq 'inetd-conf-generic-mode generic-extras-enable-list
)
1611 (define-generic-mode inetd-conf-generic-mode
1620 '(("^\\([-A-Za-z0-9_]+\\)" 1 font-lock-type-face
))
1621 '("/etc/inetd.conf\\'")
1625 (setq imenu-generic-expression
1626 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1629 (when (memq 'etc-services-generic-mode generic-extras-enable-list
)
1631 (define-generic-mode etc-services-generic-mode
1636 '(("^\\([-A-Za-z0-9_]+\\)\\s-+\\([0-9]+\\)/"
1637 (1 font-lock-type-face
)
1638 (2 font-lock-variable-name-face
)))
1639 '("/etc/services\\'")
1643 (setq imenu-generic-expression
1644 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1646 ;; Password and Group files
1647 (when (memq 'etc-passwd-generic-mode generic-extras-enable-list
)
1649 (define-generic-mode etc-passwd-generic-mode
1650 nil
;; No comment characters
1651 '("root") ;; Only one keyword
1657 ;; User name -- Never blank!
1660 ;; Password, UID and GID
1663 (make-list 3 "\\([^:]+\\)")
1666 ;; GECOS/Name -- might be blank
1669 ;; Home directory and shell
1674 '(1 font-lock-type-face
)
1675 '(5 font-lock-variable-name-face
)
1676 '(6 font-lock-constant-face
)
1677 '(7 font-lock-warning-face
))
1678 '("^\\([^:]+\\):\\([^:]*\\):\\([0-9]+\\):\\(.*\\)$"
1679 (1 font-lock-type-face
)
1680 (4 font-lock-variable-name-face
))))
1681 '("/etc/passwd\\'" "/etc/group\\'")
1685 (setq imenu-generic-expression
1686 '((nil "^\\([-A-Za-z0-9_]+\\):" 1))))))))
1689 (when (memq 'etc-fstab-generic-mode generic-extras-enable-list
)
1691 (define-generic-mode etc-fstab-generic-mode
1730 '(("^\\([^# \t]+\\)\\s-+\\([^# \t]+\\)"
1731 (1 font-lock-type-face t
)
1732 (2 font-lock-variable-name-face t
)))
1733 '("/etc/[v]*fstab\\'")
1737 (setq imenu-generic-expression
1738 '((nil "^\\([^# \t]+\\)\\s-+" 1))))))))
1741 (when (memq 'etc-sudoers-generic-mode generic-extras-enable-list
)
1743 (define-generic-mode etc-sudoers-generic-mode
1745 '("User_Alias" "Runas_Alias" "Host_Alias" "Cmnd_Alias"
1746 "NOPASSWD" "PASSWD" "NOEXEC" "EXEC"
1748 '(("\\<\\(root\\|su\\)\\>" 1 font-lock-warning-face
)
1749 ("\\(\\*\\)" 1 font-lock-warning-face
)
1750 ("\\<\\(%[A-Za-z0-9_]+\\)\\>" 1 font-lock-variable-name-face
))
1751 '("/etc/sudoers\\'")
1753 "Generic mode for sudoers configuration files."))
1755 ;; From Jacques Duthen <jacques.duthen@sncf.fr>
1756 (when (memq 'show-tabs-generic-mode generic-extras-enable-list
)
1760 (defconst show-tabs-generic-mode-font-lock-defaults-1
1761 '(;; trailing spaces must come before...
1762 ("[ \t]+$" .
'show-tabs-space
)
1764 ("[^\n\t]\\(\t+\\)" (1 'show-tabs-tab
))))
1766 (defconst show-tabs-generic-mode-font-lock-defaults-2
1767 '(;; trailing spaces must come before...
1768 ("[ \t]+$" .
'show-tabs-space
)
1770 ("\t+" .
'show-tabs-tab
))))
1772 (defface show-tabs-tab
1773 '((((class grayscale
) (background light
)) (:background
"DimGray" :weight bold
))
1774 (((class grayscale
) (background dark
)) (:background
"LightGray" :weight bold
))
1775 (((class color
) (min-colors 88)) (:background
"red1"))
1776 (((class color
)) (:background
"red"))
1778 "Font Lock mode face used to highlight TABs."
1780 ;; backward-compatibility alias
1781 (put 'show-tabs-tab-face
'face-alias
'show-tabs-tab
)
1783 (defface show-tabs-space
1784 '((((class grayscale
) (background light
)) (:background
"DimGray" :weight bold
))
1785 (((class grayscale
) (background dark
)) (:background
"LightGray" :weight bold
))
1786 (((class color
) (min-colors 88)) (:background
"yellow1"))
1787 (((class color
)) (:background
"yellow"))
1789 "Font Lock mode face used to highlight spaces."
1791 ;; backward-compatibility alias
1792 (put 'show-tabs-space-face
'face-alias
'show-tabs-space
)
1794 (define-generic-mode show-tabs-generic-mode
1795 nil
;; no comment char
1797 (eval-when-compile show-tabs-generic-mode-font-lock-defaults-1
)
1798 nil
;; no auto-mode-alist
1799 ;; '(show-tabs-generic-mode-hook-fun)
1801 "Generic mode to show tabs and trailing spaces."))
1803 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1805 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1807 (when (memq 'named-boot-generic-mode generic-extras-enable-list
)
1809 (define-generic-mode named-boot-generic-mode
1810 ;; List of comment characters
1813 '("cache" "primary" "secondary" "forwarders" "limit" "options"
1814 "directory" "check-names")
1815 ;; List of additional font-lock-expressions
1816 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face
)
1817 ("^directory\\s-+\\(.*\\)" 1 font-lock-variable-name-face
)
1818 ("^\\(primary\\|cache\\)\\s-+\\([.A-Za-z]+\\)\\s-+\\(.*\\)"
1819 (2 font-lock-variable-name-face
)
1820 (3 font-lock-constant-face
)))
1821 ;; List of additional automode-alist expressions
1822 '("/etc/named.boot\\'")
1823 ;; List of set up functions to call
1826 (when (memq 'named-database-generic-mode generic-extras-enable-list
)
1828 (define-generic-mode named-database-generic-mode
1829 ;; List of comment characters
1832 '("IN" "NS" "CNAME" "SOA" "PTR" "MX" "A")
1833 ;; List of additional font-lock-expressions
1834 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face
)
1835 ("^\\([.A-Za-z0-9]+\\)" 1 font-lock-variable-name-face
))
1836 ;; List of additional auto-mode-alist expressions
1838 ;; List of set up functions to call
1841 (defvar named-database-time-string
"%Y%m%d%H"
1842 "Timestring for named serial numbers.")
1844 (defun named-database-print-serial ()
1845 "Print a serial number based on the current date."
1847 (insert (format-time-string named-database-time-string
(current-time)))))
1849 (when (memq 'resolve-conf-generic-mode generic-extras-enable-list
)
1851 (define-generic-mode resolve-conf-generic-mode
1852 ;; List of comment characters
1855 '("nameserver" "domain" "search" "sortlist" "options")
1856 ;; List of additional font-lock-expressions
1858 ;; List of additional auto-mode-alist expressions
1859 '("/etc/resolv[e]?.conf\\'")
1860 ;; List of set up functions to call
1863 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1864 ;; Modes for spice and common electrical engineering circuit netlist formats
1865 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1867 (when (memq 'spice-generic-mode generic-extras-enable-list
)
1869 (define-generic-mode spice-generic-mode
1886 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1887 (" \\(\\$ .*\\)$" 1 font-lock-comment-face
)
1888 ("^\\(\\$ .*\\)$" 1 font-lock-comment-face
)
1889 ("\\([*].*\\)" 1 font-lock-comment-face
)
1890 ("^\\([+]\\)" 1 font-lock-string-face
)
1891 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face
)
1892 ("\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
)
1893 ("\\('[^']+'\\)" 1 font-lock-string-face
)
1894 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face
))
1896 "\\.[sS][pP][iI]\\'"
1897 "\\.[sS][pP][iI][cC][eE]\\'"
1898 "\\.[iI][nN][cC]\\'")
1900 'generic-bracket-support
1901 ;; Make keywords case-insensitive
1904 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
)))))
1905 "Generic mode for SPICE circuit netlist files."))
1907 (when (memq 'ibis-generic-mode generic-extras-enable-list
)
1909 (define-generic-mode ibis-generic-mode
1912 '(("[[]\\([^]]*\\)[]]" 1 font-lock-keyword-face
)
1913 ("\\(\\(_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
))
1914 '("\\.[iI][bB][sS]\\'")
1915 '(generic-bracket-support)
1916 "Generic mode for IBIS circuit netlist files."))
1918 (when (memq 'astap-generic-mode generic-extras-enable-list
)
1920 (define-generic-mode astap-generic-mode
1935 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1936 (";\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1937 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face
)
1938 ("\\('[^']+'\\)" 1 font-lock-string-face
)
1939 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face
)
1940 ("[(,]\\s-*\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
))
1942 "\\.[aA][sS][xX]\\'"
1943 "\\.[aA][sS][tT][aA][pP]\\'"
1944 "\\.[pP][sS][pP]\\'"
1945 "\\.[dD][eE][cC][kK]\\'"
1946 "\\.[gG][oO][dD][aA][tT][aA]")
1948 'generic-bracket-support
1949 ;; Make keywords case-insensitive
1952 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
)))))
1953 "Generic mode for ASTAP circuit netlist files."))
1955 (when (memq 'etc-modules-conf-generic-mode generic-extras-enable-list
)
1957 (define-generic-mode etc-modules-conf-generic-mode
1958 ;; List of comment characters
1976 "generic_stringfile"
1992 ;; List of additional font-lock-expressions
1994 ;; List of additional automode-alist expressions
1995 '("/etc/modules.conf" "/etc/conf.modules")
1996 ;; List of set up functions to call
1999 (provide 'generic-x
)
2001 ;;; arch-tag: cde692a5-9ff6-4506-9999-c67999c2bdb5
2002 ;;; generic-x.el ends here