1 ;;; generic-x.el --- A collection of generic modes
3 ;; Copyright (C) 1997, 1998, 2003, 2005 Free Software Foundation, Inc.
5 ;; Author: Peter Breton <pbreton@cs.umb.edu>
6 ;; Created: Tue Oct 08 1996
7 ;; Keywords: generic, comment, font-lock
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
28 ;; This file contains a collection generic modes.
32 ;; Add this line to your .emacs file:
34 ;; (require 'generic-x)
36 ;; You can decide which modes to load by setting the variable
37 ;; `generic-extras-enable-list'. Its default value is platform-
38 ;; specific. The recommended way to set this variable is through
41 ;; M-x customize-option RET generic-extras-enable-list RET
43 ;; This lets you select generic modes from the list of available
44 ;; modes. If you manually set `generic-extras-enable-list' in your
45 ;; .emacs, do it BEFORE loading generic-x with (require 'generic-x).
47 ;; You can also send in new modes; if the file types are reasonably
48 ;; common, we would like to install them.
50 ;; DEFAULT GENERIC MODE:
52 ;; This file provides a hook which automatically puts a file into
53 ;; `default-generic-mode' if the first few lines of a file in
54 ;; fundamental mode start with a hash comment character. To disable
55 ;; this functionality, set the variable `generic-use-find-file-hook'
56 ;; to nil BEFORE loading generic-x. See the variables
57 ;; `generic-lines-to-scan' and `generic-find-file-regexp' for
58 ;; customization options.
60 ;; PROBLEMS WHEN USED WITH FOLDING MODE:
62 ;; [The following relates to the obsolete selective-display technique.
63 ;; Folding mode should use invisible text properties instead. -- Dave
66 ;; From Anders Lindgren <andersl@csd.uu.se>
68 ;; Problem summary: Wayne Adams has found a problem when using folding
69 ;; mode in conjunction with font-lock for a mode defined in
72 ;; The problem, as Wayne described it, was that error messages of the
73 ;; following form appeared when both font-lock and folding are used:
75 ;; > - various msgs including "Fontifying region...(error Stack
76 ;; > overflow in regexp matcher)" appear
78 ;; I have just tracked down the cause of the problem. The regexp's in
79 ;; `generic-x.el' do not take into account the way that folding hides
80 ;; sections of the buffer. The technique is known as
81 ;; `selective-display' and has been available for a very long time (I
82 ;; started using it back in the good old Emacs 18 days). Basically, a
83 ;; section is hidden by creating one very long line were the newline
84 ;; character (C-j) is replaced by a linefeed (C-m) character.
86 ;; Many other hiding packages, besides folding, use the same technique,
87 ;; the problem should occur when using them as well.
89 ;; The erroneous lines in `generic-x.el' look like the following (this
90 ;; example is from the `ini' section):
92 ;; '(("^\\(\\[.*\\]\\)" 1 'font-lock-constant-face)
93 ;; ("^\\(.*\\)=" 1 'font-lock-variable-name-face)
95 ;; The intention of these lines is to highlight lines of the following
101 ;; However, since the `.' regexp symbol matches the linefeed character
102 ;; the entire folded section is searched, resulting in a regexp stack
105 ;; Solution suggestion: Instead of using ".", use the sequence
106 ;; "[^\n\r]". This will make the rules behave just as before, but
107 ;; they will work together with selective-display.
111 (eval-when-compile (require 'font-lock
))
113 (defgroup generic-x nil
114 "A collection of generic modes."
119 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
120 ;; Default-Generic mode
121 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
123 (defcustom generic-use-find-file-hook t
124 "*If non-nil, add a hook to enter `default-generic-mode' automatically.
125 This is done if the first few lines of a file in fundamental mode
126 start with a hash comment character."
130 (defcustom generic-lines-to-scan
3
131 "*Number of lines that `generic-mode-find-file-hook' looks at.
132 Relevant when deciding whether to enter Default-Generic mode automatically.
133 This variable should be set to a small positive number."
137 (defcustom generic-find-file-regexp
"^#"
138 "*Regular expression used by `generic-mode-find-file-hook'.
139 Files in fundamental mode whose first few lines contain a match
140 for this regexp, should be put into Default-Generic mode instead.
141 The number of lines tested for the matches is specified by the
142 value of the variable `generic-lines-to-scan', which see."
146 (defcustom generic-ignore-files-regexp
"[Tt][Aa][Gg][Ss]\\'"
147 "*Regular expression used by `generic-mode-find-file-hook'.
148 Files whose names match this regular expression should not be put
149 into Default-Generic mode, even if they have lines which match
150 the regexp in `generic-find-file-regexp'. If the value is nil,
151 `generic-mode-find-file-hook' does not check the file names."
153 :type
'(choice (const :tag
"Don't check file names" nil
) regexp
))
155 ;; This generic mode is always defined
156 (define-generic-mode default-generic-mode
(list ?
#) nil nil nil nil
)
158 ;; A more general solution would allow us to enter generic-mode for
159 ;; *any* comment character, but would require us to synthesize a new
160 ;; generic-mode on the fly. I think this gives us most of what we
162 (defun generic-mode-find-file-hook ()
163 "Hook function to enter Default-Generic mode automatically.
165 Done if the first few lines of a file in Fundamental mode start
166 with a match for the regexp in `generic-find-file-regexp', unless
167 the file's name matches the regexp which is the value of the
168 variable `generic-ignore-files-regexp'.
170 This hook will be installed if the variable
171 `generic-use-find-file-hook' is non-nil. The variable
172 `generic-lines-to-scan' determines the number of lines to look at."
173 (when (and (eq major-mode
'fundamental-mode
)
174 (or (null generic-ignore-files-regexp
)
176 generic-ignore-files-regexp
177 (file-name-sans-versions buffer-file-name
)))))
179 (goto-char (point-min))
180 (when (re-search-forward generic-find-file-regexp
182 (forward-line generic-lines-to-scan
)
184 (goto-char (point-min))
185 (default-generic-mode)))))
187 (and generic-use-find-file-hook
188 (add-hook 'find-file-hook
'generic-mode-find-file-hook
))
190 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
191 ;; Other Generic modes
192 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
194 ;; If you add a generic mode to this file, put it in one of these four
197 (defconst generic-default-modes
198 '(apache-conf-generic-mode
199 apache-log-generic-mode
201 java-manifest-generic-mode
202 java-properties-generic-mode
203 javascript-generic-mode
204 show-tabs-generic-mode
206 "List of generic modes that are defined by default.")
208 (defconst generic-mswindows-modes
215 "List of generic modes that are defined by default on MS-Windows.")
217 (defconst generic-unix-modes
219 etc-fstab-generic-mode
220 etc-modules-conf-generic-mode
221 etc-passwd-generic-mode
222 etc-services-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 mode 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 effects 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 effects 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 "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
385 (when (memq 'inf-generic-mode generic-extras-enable-list
)
387 (define-generic-mode inf-generic-mode
390 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face
))
391 '("\\.[iI][nN][fF]\\'")
392 '(generic-bracket-support)
393 "Generic mode for MS-Windows INF files."))
395 ;;; Windows INI files
396 ;; Should define escape character as well!
397 (when (memq 'ini-generic-mode generic-extras-enable-list
)
399 (define-generic-mode ini-generic-mode
402 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face
)
403 ("^\\([^=\n\r]*\\)=\\([^\n\r]*\\)$"
404 (1 font-lock-function-name-face
)
405 (2 font-lock-variable-name-face
)))
406 '("\\.[iI][nN][iI]\\'")
410 (setq imenu-generic-expression
411 '((nil "^\\[\\(.*\\)\\]" 1)
412 ("*Variables*" "^\\s-*\\([^=]+\\)\\s-*=" 1))))))
413 "Generic mode for MS-Windows INI files.
414 You can use `ini-generic-mode-find-file-hook' to enter this mode
415 automatically for INI files whose names do not end in \".ini\".")
417 (defun ini-generic-mode-find-file-hook ()
418 "Hook function to enter Ini-Generic mode automatically for INI files.
419 Done if the first few lines of a file in Fundamental mode look
420 like an INI file. You can add this hook to `find-file-hook'."
421 (and (eq major-mode
'fundamental-mode
)
423 (goto-char (point-min))
424 (and (looking-at "^\\s-*\\[.*\\]")
425 (ini-generic-mode)))))
426 (defalias 'generic-mode-ini-file-find-file-hook
'ini-generic-mode-find-file-hook
))
428 ;;; Windows REG files
429 ;;; Unfortunately, Windows 95 and Windows NT have different REG file syntax!
430 (when (memq 'reg-generic-mode generic-extras-enable-list
)
432 (define-generic-mode reg-generic-mode
434 '("key" "classes_root" "REGEDIT" "REGEDIT4")
435 '(("\\(\\[.*]\\)" 1 font-lock-constant-face
)
436 ("^\\([^\n\r]*\\)\\s-*=" 1 font-lock-variable-name-face
))
437 '("\\.[rR][eE][gG]\\'")
441 (setq imenu-generic-expression
442 '((nil "^\\s-*\\(.*\\)\\s-*=" 1))))))
443 "Generic mode for MS-Windows Registry files."))
445 ;;; DOS/Windows BAT files
446 (when (memq 'bat-generic-mode generic-extras-enable-list
)
448 (define-generic-mode bat-generic-mode
453 ;; Make this one first in the list, otherwise comments will
454 ;; be over-written by other variables
455 '("^[@ \t]*\\([rR][eE][mM][^\n\r]*\\)" 1 font-lock-comment-face t
)
456 '("^[ \t]*\\(::.*\\)" 1 font-lock-comment-face t
)
457 '("^[@ \t]*\\([bB][rR][eE][aA][kK]\\|[vV][eE][rR][iI][fF][yY]\\)[ \t]+\\([oO]\\([nN]\\|[fF][fF]\\)\\)"
458 (1 font-lock-builtin-face
)
459 (2 font-lock-constant-face t t
))
460 ;; Any text (except ON/OFF) following ECHO is a string.
461 '("^[@ \t]*\\([eE][cC][hH][oO]\\)[ \t]+\\(\\([oO]\\([nN]\\|[fF][fF]\\)\\)\\|\\([^>|\r\n]+\\)\\)"
462 (1 font-lock-builtin-face
)
463 (3 font-lock-constant-face t t
)
464 (5 font-lock-string-face t t
))
465 ;; These keywords appear as the first word on a line. (Actually, they
466 ;; can also appear after "if ..." or "for ..." clause, but since they
467 ;; are frequently used in simple text, we punt.)
468 ;; In `generic-bat-mode-setup-function' we make the keywords
470 (generic-make-keywords-list
473 font-lock-keyword-face
"^[@ \t]*")
474 ;; These keywords can be anywhere on a line
475 ;; In `generic-bat-mode-setup-function' we make the keywords
477 (generic-make-keywords-list
483 font-lock-keyword-face
)
484 ;; These are built-in commands. Only frequently-used ones are listed.
485 (generic-make-keywords-list
486 '("CALL" "call" "Call"
494 "PAUSE" "pause" "Pause"
495 "PROMPT" "prompt" "Prompt"
499 "START" "start" "Start"
500 "SHIFT" "shift" "Shift")
501 font-lock-builtin-face
"[ \t|\n]")
502 '("^[ \t]*\\(:\\sw+\\)" 1 font-lock-function-name-face t
)
503 '("\\(%\\sw+%\\)" 1 font-lock-variable-name-face t
)
504 '("\\(%[0-9]\\)" 1 font-lock-variable-name-face t
)
505 '("\\(/[^/ \"\t\n]+\\)" 1 font-lock-type-face
)
506 '("[\t ]+\\([+-][^\t\n\" ]+\\)" 1 font-lock-type-face
)
507 '("[ \t\n|]\\<\\([gG][oO][tT][oO]\\)\\>[ \t]*\\(\\sw+\\)?"
508 (1 font-lock-keyword-face
)
509 (2 font-lock-function-name-face nil t
))
510 '("[ \t\n|]\\<\\([sS][eE][tT]\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*=?"
511 (1 font-lock-builtin-face
)
512 (2 font-lock-variable-name-face t t
))))
513 '("\\.[bB][aA][tT]\\'"
514 "\\`[cC][oO][nN][fF][iI][gG]\\."
515 "\\`[aA][uU][tT][oO][eE][xX][eE][cC]\\.")
516 '(generic-bat-mode-setup-function)
517 "Generic mode for MS-Windows BAT files.")
519 (defvar bat-generic-mode-syntax-table nil
520 "Syntax table in use in `bat-generic-mode' buffers.")
522 (defvar bat-generic-mode-keymap
(make-sparse-keymap)
523 "Keymap for bet-generic-mode.")
525 (defun bat-generic-mode-compile ()
526 "Run the current BAT file in a compilation buffer."
528 (let ((compilation-buffer-name-function
531 (concat "*" (buffer-file-name) "*")))))
533 (concat (w32-shell-name) " -c " (buffer-file-name)))))
535 (eval-when-compile (require 'comint
))
536 (defun bat-generic-mode-run-as-comint ()
537 "Run the current BAT file in a comint buffer."
540 (let* ((file (buffer-file-name))
541 (buf-name (concat "*" file
"*")))
544 (get-buffer-create buf-name
))
553 (display-buffer buf-name
))))
555 (define-key bat-generic-mode-keymap
"\C-c\C-c" 'bat-generic-mode-compile
)
557 ;; Make underscores count as words
558 (unless bat-generic-mode-syntax-table
559 (setq bat-generic-mode-syntax-table
(make-syntax-table))
560 (modify-syntax-entry ?_
"w" bat-generic-mode-syntax-table
))
562 ;; bat-generic-mode doesn't use the comment functionality of
563 ;; define-generic-mode because it has a three-letter comment-string,
564 ;; so we do it here manually instead
565 (defun generic-bat-mode-setup-function ()
566 (make-local-variable 'parse-sexp-ignore-comments
)
567 (make-local-variable 'comment-start
)
568 (make-local-variable 'comment-start-skip
)
569 (make-local-variable 'comment-end
)
570 (setq imenu-generic-expression
'((nil "^:\\(\\sw+\\)" 1))
571 parse-sexp-ignore-comments t
574 comment-start-skip
"[Rr][Ee][Mm] *")
575 (set-syntax-table bat-generic-mode-syntax-table
)
576 ;; Make keywords case-insensitive
577 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
))
578 (use-local-map bat-generic-mode-keymap
)))
581 ;; Mailagent is a Unix mail filtering program. Anyone wanna do a
582 ;; generic mode for procmail?
583 (when (memq 'mailagent-rules-generic-mode generic-extras-enable-list
)
585 (define-generic-mode mailagent-rules-generic-mode
587 '("SAVE" "DELETE" "PIPE" "ANNOTATE" "REJECT")
588 '(("^\\(\\sw+\\)\\s-*=" 1 font-lock-variable-name-face
)
589 ("\\s-/\\([^/]+\\)/[i, \t\n]" 1 font-lock-constant-face
))
594 (setq imenu-generic-expression
595 '((nil "\\s-/\\([^/]+\\)/[i, \t\n]" 1))))))
596 "Mode for Mailagent rules files."))
598 ;; Solaris/Sys V prototype files
599 (when (memq 'prototype-generic-mode generic-extras-enable-list
)
601 (define-generic-mode prototype-generic-mode
604 '(("^\\([0-9]\\)?\\s-*\\([a-z]\\)\\s-+\\([A-Za-z_]+\\)\\s-+\\([^\n\r]*\\)$"
605 (2 font-lock-constant-face
)
606 (3 font-lock-keyword-face
))
607 ("^\\([a-z]\\) \\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
608 (1 font-lock-constant-face
)
609 (2 font-lock-keyword-face
)
610 (3 font-lock-variable-name-face
))
611 ("^\\(!\\s-*\\(search\\|include\\|default\\)\\)\\s-*\\([^\n\r]*\\)$"
612 (1 font-lock-keyword-face
)
613 (3 font-lock-variable-name-face
))
614 ("^\\(!\\s-*\\sw+\\)=\\([^\n\r]*\\)$"
615 (1 font-lock-keyword-face
)
616 (2 font-lock-variable-name-face
)))
619 "Mode for Sys V prototype files."))
621 ;; Solaris/Sys V pkginfo files
622 (when (memq 'pkginfo-generic-mode generic-extras-enable-list
)
624 (define-generic-mode pkginfo-generic-mode
627 '(("^\\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
628 (1 font-lock-keyword-face
)
629 (2 font-lock-variable-name-face
)))
632 "Mode for Sys V pkginfo files."))
635 ;; Includes extra keywords from Armando Singer [asinger@MAIL.COLGATE.EDU]
636 (when (memq 'javascript-generic-mode generic-extras-enable-list
)
638 (define-generic-mode javascript-generic-mode
639 '("//" ("/*" .
"*/"))
662 ;; words reserved for ECMA extensions below
673 ;; Java Keywords reserved by JavaScript
700 '(("^\\s-*function\\s-+\\([A-Za-z0-9_]+\\)"
701 (1 font-lock-function-name-face
))
702 ("^\\s-*var\\s-+\\([A-Za-z0-9_]+\\)"
703 (1 font-lock-variable-name-face
)))
708 (setq imenu-generic-expression
709 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1)
710 ("*Variables*" "^var\\s-+\\([A-Za-z0-9_]+\\)" 1))))))
711 "Mode for JavaScript files."))
714 (when (memq 'vrml-generic-mode generic-extras-enable-list
)
716 (define-generic-mode vrml-generic-mode
746 '(("USE\\s-+\\([-A-Za-z0-9_]+\\)"
747 (1 font-lock-constant-face
))
748 ("DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
749 (1 font-lock-type-face
)
750 (2 font-lock-constant-face
))
751 ("^\\s-*\\([-A-Za-z0-9_]+\\)\\s-*{"
752 (1 font-lock-function-name-face
))
753 ("^\\s-*\\(geometry\\|appearance\\|material\\)\\s-+\\([-A-Za-z0-9_]+\\)"
754 (2 font-lock-variable-name-face
)))
759 (setq imenu-generic-expression
760 '((nil "^\\([A-Za-z0-9_]+\\)\\s-*{" 1)
762 "DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
764 "Generic Mode for VRML files."))
767 (when (memq 'java-manifest-generic-mode generic-extras-enable-list
)
769 (define-generic-mode java-manifest-generic-mode
779 '(("^Name:\\s-+\\([^\n\r]*\\)$"
780 (1 font-lock-variable-name-face
))
781 ("^\\(Manifest\\|Required\\|Signature\\)-Version:\\s-+\\([^\n\r]*\\)$"
782 (2 font-lock-constant-face
)))
783 '("[mM][aA][nN][iI][fF][eE][sS][tT]\\.[mM][fF]\\'")
785 "Mode for Java Manifest files"))
787 ;; Java properties files
788 (when (memq 'java-properties-generic-mode generic-extras-enable-list
)
790 (define-generic-mode java-properties-generic-mode
794 (let ((java-properties-key
795 "\\(\\([-A-Za-z0-9_\\./]\\|\\(\\\\[ =:]\\)\\)+\\)")
796 (java-properties-value
798 ;; Property and value can be separated in a number of different ways:
806 (concat "^" java-properties-key elt java-properties-value
"$")
807 '(1 font-lock-constant-face
)
808 '(4 font-lock-variable-name-face
))))
809 ;; These are the separators
810 '(":\\s-*" "\\s-+" "\\s-*=\\s-*"))))
815 (setq imenu-generic-expression
816 '((nil "^\\([^#! \t\n\r=:]+\\)" 1))))))
817 "Mode for Java properties files."))
819 ;; C shell alias definitions
820 (when (memq 'alias-generic-mode generic-extras-enable-list
)
822 (define-generic-mode alias-generic-mode
825 '(("^alias\\s-+\\([-A-Za-z0-9_]+\\)\\s-+"
826 (1 font-lock-variable-name-face
))
827 ("^unalias\\s-+\\([-A-Za-z0-9_]+\\)\\s-*$"
828 (1 font-lock-variable-name-face
)))
833 (setq imenu-generic-expression
834 '((nil "^\\(alias\\|unalias\\)\\s-+\\([-a-zA-Z0-9_]+\\)" 2))))))
835 "Mode for C Shell alias files."))
838 ;; Contributed by ACorreir@pervasive-sw.com (Alfred Correira)
839 (when (memq 'rc-generic-mode generic-extras-enable-list
)
841 (define-generic-mode rc-generic-mode
896 ;; the choice of what tokens go where is somewhat arbitrary,
897 ;; as is the choice of which value tokens are included, as
898 ;; the choice of face for each token group
901 (generic-make-keywords-list
910 (generic-make-keywords-list
915 font-lock-function-name-face
)
916 '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face
)
917 '("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face
)
918 '("^#[ \t]*\\(elif\\|if\\)\\>"
919 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil
920 (1 font-lock-constant-face
)
921 (2 font-lock-variable-name-face nil t
)))
922 '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
923 (1 font-lock-constant-face
)
924 (2 font-lock-variable-name-face nil t
))))
927 "Generic mode for MS-Windows Resource files."))
929 ;; InstallShield RUL files
930 ;; Contributed by Alfred.Correira@Pervasive.Com
931 ;; Bugfixes by "Rolf Sandau" <Rolf.Sandau@marconi.com>
932 (when (memq 'rul-generic-mode generic-extras-enable-list
)
936 ;;; build the regexp strings using regexp-opt
937 (defconst installshield-statement-keyword-list
956 ;; "goto" -- handled elsewhere
970 "Statement keywords used in InstallShield 3 and 5.")
972 (defconst installshield-system-functions-list
992 "ComponentAddItem" ; differs between IS3 and IS5
993 "ComponentCompareSizeRequired" ; IS5 only
995 "ComponentError" ; IS5 only
996 "ComponentFileEnum" ; IS5 only
997 "ComponentFileInfo" ; IS5 only
998 "ComponentFilterLanguage" ; IS5 only
999 "ComponentFilterOS" ; IS5 only
1000 "ComponentGetData" ; IS5 only
1001 "ComponentGetItemInfo" ; IS3 only
1002 "ComponentGetItemSize" ; differs between IS3 and IS5
1003 "ComponentIsItemSelected" ; differs between IS3 and IS5
1004 "ComponentListItems"
1005 "ComponentMoveData" ; IS5 only
1006 "ComponentSelectItem" ; differs between IS3 and IS5
1007 "ComponentSetData" ; IS5 only
1008 "ComponentSetItemInfo" ; IS3 only
1009 "ComponentSetTarget" ; IS5 only
1010 "ComponentSetupTypeEnum" ; IS5 only
1011 "ComponentSetupTypeGetData" ; IS5 only
1012 "ComponentSetupTypeSet" ; IS5 only
1013 "ComponentTotalSize"
1014 "ComponentValidate" ; IS5 only
1015 "CompressAdd" ; IS3 only
1016 "CompressDel" ; IS3 only
1017 "CompressEnum" ; IS3 only
1018 "CompressGet" ; IS3 only
1019 "CompressInfo" ; IS3 only
1023 "CreateProgramFolder"
1024 "DeinstallSetReference" ; IS5 only
1050 "FileSetBeginDefine" ; IS3 only
1051 "FileSetEndDefine" ; IS3 only
1052 "FileSetPerformEz" ; IS3 only
1053 "FileSetPerform" ; IS3 only
1054 "FileSetReset" ; IS3 only
1055 "FileSetRoot" ; IS3 only
1069 "GetValidDrivesList"
1084 "ListGetFirstString"
1088 "ListSetCurrentItem"
1094 "LongPathToShortPath"
1109 "PlayMMedia" ; IS5 only
1116 "RegDBGetKeyValueEx"
1117 "RegDBSetKeyValueEx"
1118 "RegDBSetDefaultRoot"
1127 "SdComponentAdvCheckSpace"
1128 "SdComponentAdvInit"
1129 "SdComponentAdvUpdateSpace"
1131 "SdComponentDialog2"
1132 "SdComponentDialogAdv"
1133 "SdComponentDialogEx"
1134 "SdComponentDlgCheckSpace"
1137 "SdConfirmRegistration"
1149 "SdGetUserCompanyInfo"
1158 "SdOptionsButtonsInit"
1159 "SdPlugInProductName"
1162 "SdRegExEnableButton"
1167 "SdSetSequentialItems"
1169 "SdSetupTypeEx" ; IS5 only
1180 "SdUpdateComponentSelection"
1186 "SetDisplayEffect" ; IS5 only
1188 "SetForegroundWindow"
1201 "StrRemoveLastSlash"
1215 "System functions defined in InstallShield 3 and 5.")
1217 (defconst installshield-system-variables-list
1221 "CORECOMPONENTHANDLING"
1247 "System variables used in InstallShield 3 and 5.")
1249 (defconst installshield-types-list
1268 "Type keywords used in InstallShield 3 and 5.")
1270 ;;; some might want to skip highlighting these to improve performance
1271 (defconst installshield-funarg-constants-list
1301 "COMP_UPDATE_VERSION"
1320 "DLG_INFO_CHECKSELECTION"
1322 "DLG_INFO_USEDECIMAL"
1323 "DLG_MSG_INFORMATION"
1344 "FILE_ATTR_ARCHIVED"
1345 "FILE_ATTR_DIRECTORY"
1348 "FILE_ATTR_READONLY"
1354 "FILE_MODE_BINARYREADONLY"
1376 "HKEY_LOCAL_MACHINE"
1421 "REGDB_APPPATH_DEFAULT"
1424 "REGDB_ERR_CONNECTIONEXISTS"
1425 "REGDB_ERR_CORRUPTEDREGSITRY"
1426 "REGDB_ERR_INITIALIZATION"
1427 "REGDB_ERR_INVALIDHANDLE"
1428 "REGDB_ERR_INVALIDNAME"
1430 "REGDB_STRING_EXPAND"
1431 "REGDB_STRING_MULTI"
1433 "REGDB_UNINSTALL_NAME"
1477 "Function argument constants used in InstallShield 3 and 5."))
1479 (defvar rul-generic-mode-syntax-table nil
1480 "Syntax table to use in `rul-generic-mode' buffers.")
1482 (setq rul-generic-mode-syntax-table
1483 (make-syntax-table c
++-mode-syntax-table
))
1485 (modify-syntax-entry ?
\r "> b" rul-generic-mode-syntax-table
)
1486 (modify-syntax-entry ?
\n "> b" rul-generic-mode-syntax-table
)
1488 (modify-syntax-entry ?
/ ". 124b" rul-generic-mode-syntax-table
)
1489 (modify-syntax-entry ?
* ". 23" rul-generic-mode-syntax-table
)
1491 ;; here manually instead
1492 (defun generic-rul-mode-setup-function ()
1493 (make-local-variable 'parse-sexp-ignore-comments
)
1494 (make-local-variable 'comment-start
)
1495 (make-local-variable 'comment-start-skip
)
1496 (make-local-variable 'comment-end
)
1497 (setq imenu-generic-expression
1498 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1))
1499 parse-sexp-ignore-comments t
1503 ;;; comment-start "//"
1504 ;;; comment-start-skip ""
1506 ;; (set-syntax-table rul-generic-mode-syntax-table)
1507 (setq font-lock-syntax-table rul-generic-mode-syntax-table
))
1509 ;; moved mode-definition behind defun-definition to be warning-free - 15.11.02/RSan
1510 (define-generic-mode rul-generic-mode
1511 ;; Using "/*" and "*/" doesn't seem to be working right
1512 '("//" ("/*" .
"*/" ))
1513 (eval-when-compile installshield-statement-keyword-list
)
1516 ;; preprocessor constructs
1517 '("#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)"
1518 1 font-lock-string-face
)
1519 '("#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
1520 (1 font-lock-reference-face
)
1521 (2 font-lock-variable-name-face nil t
))
1522 ;; indirect string constants
1523 '("\\(@[A-Za-z][A-Za-z0-9_]+\\)" 1 font-lock-builtin-face
)
1525 '("[ \t]*\\(\\sw+:\\)" 1 font-lock-reference-face
)
1526 '("\\<\\(goto\\)\\>[ \t]*\\(\\sw+\\)?"
1527 (1 font-lock-keyword-face
)
1528 (2 font-lock-reference-face nil t
))
1530 (generic-make-keywords-list
1531 installshield-system-variables-list
1532 font-lock-variable-name-face
"[^_]" "[^_]")
1534 (generic-make-keywords-list
1535 installshield-system-functions-list
1536 font-lock-function-name-face
"[^_]" "[^_]")
1538 (generic-make-keywords-list
1539 installshield-types-list
1540 font-lock-type-face
"[^_]" "[^_]")
1541 ;; function argument constants
1542 (generic-make-keywords-list
1543 installshield-funarg-constants-list
1544 font-lock-variable-name-face
"[^_]" "[^_]"))) ; is this face the best choice?
1545 '("\\.[rR][uU][lL]\\'")
1546 '(generic-rul-mode-setup-function)
1547 "Generic mode for InstallShield RUL files.")
1549 (define-skeleton rul-if
1550 "Insert an if statement."
1552 "if(" str
") then" \n
1554 ( "other condition, %s: "
1555 > "elseif(" str
") then" \n
1562 (define-skeleton rul-function
1563 "Insert a function statement."
1565 "function " str
" ()" \n
1566 ( "local variables, %s: "
1573 ;; Additions by ACorreir@pervasive-sw.com (Alfred Correira)
1574 (when (memq 'mailrc-generic-mode generic-extras-enable-list
)
1576 (define-generic-mode mailrc-generic-mode
1587 '(("^\\s-*\\(alias\\|group\\)\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1588 (2 font-lock-constant-face
)
1589 (3 font-lock-variable-name-face
))
1590 ("^\\s-*\\(unset\\|set\\|ignore\\)\\s-+\\([-A-Za-z0-9_]+\\)=?\\([^\n\r#]*\\)\\(#.*\\)?$"
1591 (2 font-lock-constant-face
)
1592 (3 font-lock-variable-name-face
))
1593 ("^\\s-*\\(source\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1594 (2 font-lock-variable-name-face
)))
1597 "Mode for mailrc files."))
1600 (when (memq 'inetd-conf-generic-mode generic-extras-enable-list
)
1602 (define-generic-mode inetd-conf-generic-mode
1611 '(("^\\([-A-Za-z0-9_]+\\)" 1 font-lock-type-face
))
1612 '("/etc/inetd.conf\\'")
1616 (setq imenu-generic-expression
1617 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1620 (when (memq 'etc-services-generic-mode generic-extras-enable-list
)
1622 (define-generic-mode etc-services-generic-mode
1627 '(("^\\([-A-Za-z0-9_]+\\)\\s-+\\([0-9]+\\)/"
1628 (1 font-lock-type-face
)
1629 (2 font-lock-variable-name-face
)))
1630 '("/etc/services\\'")
1634 (setq imenu-generic-expression
1635 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1637 ;; Password and Group files
1638 (when (memq 'etc-passwd-generic-mode generic-extras-enable-list
)
1640 (define-generic-mode etc-passwd-generic-mode
1641 nil
;; No comment characters
1642 '("root") ;; Only one keyword
1648 ;; User name -- Never blank!
1651 ;; Password, UID and GID
1654 (make-list 3 "\\([^:]+\\)")
1657 ;; GECOS/Name -- might be blank
1660 ;; Home directory and shell
1665 '(1 font-lock-type-face
)
1666 '(5 font-lock-variable-name-face
)
1667 '(6 font-lock-constant-face
)
1668 '(7 font-lock-warning-face
))
1669 '("^\\([^:]+\\):\\([^:]*\\):\\([0-9]+\\):\\(.*\\)$"
1670 (1 font-lock-type-face
)
1671 (4 font-lock-variable-name-face
))))
1672 '("/etc/passwd\\'" "/etc/group\\'")
1676 (setq imenu-generic-expression
1677 '((nil "^\\([-A-Za-z0-9_]+\\):" 1))))))))
1680 (when (memq 'etc-fstab-generic-mode generic-extras-enable-list
)
1682 (define-generic-mode etc-fstab-generic-mode
1719 '(("^\\([/-A-Za-z0-9_]+\\)\\s-+\\([/-A-Za-z0-9_]+\\)"
1720 (1 font-lock-type-face t
)
1721 (2 font-lock-variable-name-face t
)))
1722 '("/etc/[v]*fstab\\'")
1726 (setq imenu-generic-expression
1727 '((nil "^\\([/-A-Za-z0-9_]+\\)\\s-+" 1))))))))
1729 ;; From Jacques Duthen <jacques.duthen@sncf.fr>
1730 (when (memq 'show-tabs-generic-mode generic-extras-enable-list
)
1734 (defconst show-tabs-generic-mode-font-lock-defaults-1
1735 '(;; trailing spaces must come before...
1736 ("[ \t]+$" .
'show-tabs-space-face
)
1738 ("[^\n\t]\\(\t+\\)" (1 'show-tabs-tab-face
))))
1740 (defconst show-tabs-generic-mode-font-lock-defaults-2
1741 '(;; trailing spaces must come before...
1742 ("[ \t]+$" .
'show-tabs-space-face
)
1744 ("\t+" .
'show-tabs-tab-face
))))
1746 (defface show-tabs-tab-face
1747 '((((class grayscale
) (background light
)) (:background
"DimGray" :weight bold
))
1748 (((class grayscale
) (background dark
)) (:background
"LightGray" :weight bold
))
1749 (((class color
) (min-colors 88)) (:background
"red1"))
1750 (((class color
)) (:background
"red"))
1752 "Font Lock mode face used to highlight TABs."
1755 (defface show-tabs-space-face
1756 '((((class grayscale
) (background light
)) (:background
"DimGray" :weight bold
))
1757 (((class grayscale
) (background dark
)) (:background
"LightGray" :weight bold
))
1758 (((class color
) (min-colors 88)) (:background
"yellow1"))
1759 (((class color
)) (:background
"yellow"))
1761 "Font Lock mode face used to highlight spaces."
1764 (define-generic-mode show-tabs-generic-mode
1765 nil
;; no comment char
1767 (eval-when-compile show-tabs-generic-mode-font-lock-defaults-1
)
1768 nil
;; no auto-mode-alist
1769 ;; '(show-tabs-generic-mode-hook-fun)
1771 "Generic mode to show tabs and trailing spaces"))
1773 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1775 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1777 (when (memq 'named-boot-generic-mode generic-extras-enable-list
)
1779 (define-generic-mode named-boot-generic-mode
1780 ;; List of comment characters
1783 '("cache" "primary" "secondary" "forwarders" "limit" "options"
1784 "directory" "check-names")
1785 ;; List of additional font-lock-expressions
1786 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face
)
1787 ("^directory\\s-+\\(.*\\)" 1 font-lock-variable-name-face
)
1788 ("^\\(primary\\|cache\\)\\s-+\\([.A-Za-z]+\\)\\s-+\\(.*\\)"
1789 (2 font-lock-variable-name-face
)
1790 (3 font-lock-constant-face
)))
1791 ;; List of additional automode-alist expressions
1792 '("/etc/named.boot\\'")
1793 ;; List of set up functions to call
1796 (when (memq 'named-database-generic-mode generic-extras-enable-list
)
1798 (define-generic-mode named-database-generic-mode
1799 ;; List of comment characters
1802 '("IN" "NS" "CNAME" "SOA" "PTR" "MX" "A")
1803 ;; List of additional font-lock-expressions
1804 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face
)
1805 ("^\\([.A-Za-z0-9]+\\)" 1 font-lock-variable-name-face
))
1806 ;; List of additional auto-mode-alist expressions
1808 ;; List of set up functions to call
1811 (defvar named-database-time-string
"%Y%m%d%H"
1812 "Timestring for named serial numbers.")
1814 (defun named-database-print-serial ()
1815 "Print a serial number based on the current date."
1817 (insert (format-time-string named-database-time-string
(current-time)))))
1819 (when (memq 'resolve-conf-generic-mode generic-extras-enable-list
)
1821 (define-generic-mode resolve-conf-generic-mode
1822 ;; List of comment characters
1825 '("nameserver" "domain" "search" "sortlist" "options")
1826 ;; List of additional font-lock-expressions
1828 ;; List of additional auto-mode-alist expressions
1829 '("/etc/resolv[e]?.conf\\'")
1830 ;; List of set up functions to call
1833 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1834 ;; Modes for spice and common electrical engineering circuit netlist formats
1835 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1837 (when (memq 'spice-generic-mode generic-extras-enable-list
)
1839 (define-generic-mode spice-generic-mode
1856 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1857 (" \\(\\$ .*\\)$" 1 font-lock-comment-face
)
1858 ("^\\(\\$ .*\\)$" 1 font-lock-comment-face
)
1859 ("\\([*].*\\)" 1 font-lock-comment-face
)
1860 ("^\\([+]\\)" 1 font-lock-string-face
)
1861 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face
)
1862 ("\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
)
1863 ("\\('[^']+'\\)" 1 font-lock-string-face
)
1864 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face
))
1866 "\\.[sS][pP][iI]\\'"
1867 "\\.[sS][pP][iI][cC][eE]\\'"
1868 "\\.[iI][nN][cC]\\'")
1870 'generic-bracket-support
1871 ;; Make keywords case-insensitive
1874 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
)))))
1875 "Generic mode for SPICE circuit netlist files."))
1877 (when (memq 'ibis-generic-mode generic-extras-enable-list
)
1879 (define-generic-mode ibis-generic-mode
1882 '(("[[]\\([^]]*\\)[]]" 1 font-lock-keyword-face
)
1883 ("\\(\\(_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
))
1884 '("\\.[iI][bB][sS]\\'")
1885 '(generic-bracket-support)
1886 "Generic mode for IBIS circuit netlist files."))
1888 (when (memq 'astap-generic-mode generic-extras-enable-list
)
1890 (define-generic-mode astap-generic-mode
1905 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1906 (";\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1907 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face
)
1908 ("\\('[^']+'\\)" 1 font-lock-string-face
)
1909 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face
)
1910 ("[(,]\\s-*\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
))
1912 "\\.[aA][sS][xX]\\'"
1913 "\\.[aA][sS][tT][aA][pP]\\'"
1914 "\\.[pP][sS][pP]\\'"
1915 "\\.[dD][eE][cC][kK]\\'"
1916 "\\.[gG][oO][dD][aA][tT][aA]")
1918 'generic-bracket-support
1919 ;; Make keywords case-insensitive
1922 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
)))))
1923 "Generic mode for ASTAP circuit netlist files."))
1925 (when (memq 'etc-modules-conf-generic-mode generic-extras-enable-list
)
1927 (define-generic-mode etc-modules-conf-generic-mode
1928 ;; List of comment characters
1946 "generic_stringfile"
1962 ;; List of additional font-lock-expressions
1964 ;; List of additional automode-alist expressions
1965 '("/etc/modules.conf" "/etc/conf.modules")
1966 ;; List of set up functions to call
1969 (provide 'generic-x
)
1971 ;;; arch-tag: cde692a5-9ff6-4506-9999-c67999c2bdb5
1972 ;;; generic-x.el ends here