1 ;;; generic-x.el --- A collection of generic modes
3 ;; Copyright (C) 1997, 1998, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006 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 2, 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 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 effects 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 effects 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
386 (when (memq 'inf-generic-mode generic-extras-enable-list
)
388 (define-generic-mode inf-generic-mode
391 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face
))
392 '("\\.[iI][nN][fF]\\'")
393 '(generic-bracket-support)
394 "Generic mode for MS-Windows INF files."))
396 ;;; Windows INI files
397 ;; Should define escape character as well!
398 (when (memq 'ini-generic-mode generic-extras-enable-list
)
400 (define-generic-mode ini-generic-mode
403 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face
)
404 ("^\\([^=\n\r]*\\)=\\([^\n\r]*\\)$"
405 (1 font-lock-function-name-face
)
406 (2 font-lock-variable-name-face
)))
407 '("\\.[iI][nN][iI]\\'")
411 (setq imenu-generic-expression
412 '((nil "^\\[\\(.*\\)\\]" 1)
413 ("*Variables*" "^\\s-*\\([^=]+\\)\\s-*=" 1))))))
414 "Generic mode for MS-Windows INI files.
415 You can use `ini-generic-mode-find-file-hook' to enter this mode
416 automatically for INI files whose names do not end in \".ini\".")
418 (defun ini-generic-mode-find-file-hook ()
419 "Hook function to enter Ini-Generic mode automatically for INI files.
420 Done if the first few lines of a file in Fundamental mode look
421 like an INI file. You can add this hook to `find-file-hook'."
422 (and (eq major-mode
'fundamental-mode
)
424 (goto-char (point-min))
425 (and (looking-at "^\\s-*\\[.*\\]")
426 (ini-generic-mode)))))
427 (defalias 'generic-mode-ini-file-find-file-hook
'ini-generic-mode-find-file-hook
))
429 ;;; Windows REG files
430 ;;; Unfortunately, Windows 95 and Windows NT have different REG file syntax!
431 (when (memq 'reg-generic-mode generic-extras-enable-list
)
433 (define-generic-mode reg-generic-mode
435 '("key" "classes_root" "REGEDIT" "REGEDIT4")
436 '(("\\(\\[.*\\]\\)" 1 font-lock-constant-face
)
437 ("^\\([^\n\r]*\\)\\s-*=" 1 font-lock-variable-name-face
))
438 '("\\.[rR][eE][gG]\\'")
442 (setq imenu-generic-expression
443 '((nil "^\\s-*\\(.*\\)\\s-*=" 1))))))
444 "Generic mode for MS-Windows Registry files."))
446 ;;; DOS/Windows BAT files
447 (when (memq 'bat-generic-mode generic-extras-enable-list
)
449 (define-generic-mode bat-generic-mode
454 ;; Make this one first in the list, otherwise comments will
455 ;; be over-written by other variables
456 '("^[@ \t]*\\([rR][eE][mM][^\n\r]*\\)" 1 font-lock-comment-face t
)
457 '("^[ \t]*\\(::.*\\)" 1 font-lock-comment-face t
)
458 '("^[@ \t]*\\([bB][rR][eE][aA][kK]\\|[vV][eE][rR][iI][fF][yY]\\)[ \t]+\\([oO]\\([nN]\\|[fF][fF]\\)\\)"
459 (1 font-lock-builtin-face
)
460 (2 font-lock-constant-face t t
))
461 ;; Any text (except ON/OFF) following ECHO is a string.
462 '("^[@ \t]*\\([eE][cC][hH][oO]\\)[ \t]+\\(\\([oO]\\([nN]\\|[fF][fF]\\)\\)\\|\\([^>|\r\n]+\\)\\)"
463 (1 font-lock-builtin-face
)
464 (3 font-lock-constant-face t t
)
465 (5 font-lock-string-face t t
))
466 ;; These keywords appear as the first word on a line. (Actually, they
467 ;; can also appear after "if ..." or "for ..." clause, but since they
468 ;; are frequently used in simple text, we punt.)
469 ;; In `generic-bat-mode-setup-function' we make the keywords
471 (generic-make-keywords-list
474 font-lock-keyword-face
"^[@ \t]*")
475 ;; These keywords can be anywhere on a line
476 ;; In `generic-bat-mode-setup-function' we make the keywords
478 (generic-make-keywords-list
484 font-lock-keyword-face
)
485 ;; These are built-in commands. Only frequently-used ones are listed.
486 (generic-make-keywords-list
487 '("CALL" "call" "Call"
495 "PAUSE" "pause" "Pause"
496 "PROMPT" "prompt" "Prompt"
500 "START" "start" "Start"
501 "SHIFT" "shift" "Shift")
502 font-lock-builtin-face
"[ \t|\n]")
503 '("^[ \t]*\\(:\\sw+\\)" 1 font-lock-function-name-face t
)
504 '("\\(%\\sw+%\\)" 1 font-lock-variable-name-face t
)
505 '("\\(%[0-9]\\)" 1 font-lock-variable-name-face t
)
506 '("\\(/[^/ \"\t\n]+\\)" 1 font-lock-type-face
)
507 '("[\t ]+\\([+-][^\t\n\" ]+\\)" 1 font-lock-type-face
)
508 '("[ \t\n|]\\<\\([gG][oO][tT][oO]\\)\\>[ \t]*\\(\\sw+\\)?"
509 (1 font-lock-keyword-face
)
510 (2 font-lock-function-name-face nil t
))
511 '("[ \t\n|]\\<\\([sS][eE][tT]\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*=?"
512 (1 font-lock-builtin-face
)
513 (2 font-lock-variable-name-face t t
))))
514 '("\\.[bB][aA][tT]\\'"
516 "\\`[cC][oO][nN][fF][iI][gG]\\."
517 "\\`[aA][uU][tT][oO][eE][xX][eE][cC]\\.")
518 '(generic-bat-mode-setup-function)
519 "Generic mode for MS-Windows batch files.")
521 (defvar bat-generic-mode-syntax-table nil
522 "Syntax table in use in `bat-generic-mode' buffers.")
524 (defvar bat-generic-mode-keymap
(make-sparse-keymap)
525 "Keymap for bet-generic-mode.")
527 (defun bat-generic-mode-compile ()
528 "Run the current BAT file in a compilation buffer."
530 (let ((compilation-buffer-name-function
533 (concat "*" (buffer-file-name) "*")))))
535 (concat (w32-shell-name) " -c " (buffer-file-name)))))
537 (eval-when-compile (require 'comint
))
538 (defun bat-generic-mode-run-as-comint ()
539 "Run the current BAT file in a comint buffer."
542 (let* ((file (buffer-file-name))
543 (buf-name (concat "*" file
"*")))
546 (get-buffer-create buf-name
))
555 (display-buffer buf-name
))))
557 (define-key bat-generic-mode-keymap
"\C-c\C-c" 'bat-generic-mode-compile
)
559 ;; Make underscores count as words
560 (unless bat-generic-mode-syntax-table
561 (setq bat-generic-mode-syntax-table
(make-syntax-table))
562 (modify-syntax-entry ?_
"w" bat-generic-mode-syntax-table
))
564 ;; bat-generic-mode doesn't use the comment functionality of
565 ;; define-generic-mode because it has a three-letter comment-string,
566 ;; so we do it here manually instead
567 (defun generic-bat-mode-setup-function ()
568 (make-local-variable 'parse-sexp-ignore-comments
)
569 (make-local-variable 'comment-start
)
570 (make-local-variable 'comment-start-skip
)
571 (make-local-variable 'comment-end
)
572 (setq imenu-generic-expression
'((nil "^:\\(\\sw+\\)" 1))
573 parse-sexp-ignore-comments t
576 comment-start-skip
"[Rr][Ee][Mm] *")
577 (set-syntax-table bat-generic-mode-syntax-table
)
578 ;; Make keywords case-insensitive
579 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
))
580 (use-local-map bat-generic-mode-keymap
)))
583 ;; Mailagent is a Unix mail filtering program. Anyone wanna do a
584 ;; generic mode for procmail?
585 (when (memq 'mailagent-rules-generic-mode generic-extras-enable-list
)
587 (define-generic-mode mailagent-rules-generic-mode
589 '("SAVE" "DELETE" "PIPE" "ANNOTATE" "REJECT")
590 '(("^\\(\\sw+\\)\\s-*=" 1 font-lock-variable-name-face
)
591 ("\\s-/\\([^/]+\\)/[i, \t\n]" 1 font-lock-constant-face
))
596 (setq imenu-generic-expression
597 '((nil "\\s-/\\([^/]+\\)/[i, \t\n]" 1))))))
598 "Mode for Mailagent rules files."))
600 ;; Solaris/Sys V prototype files
601 (when (memq 'prototype-generic-mode generic-extras-enable-list
)
603 (define-generic-mode prototype-generic-mode
606 '(("^\\([0-9]\\)?\\s-*\\([a-z]\\)\\s-+\\([A-Za-z_]+\\)\\s-+\\([^\n\r]*\\)$"
607 (2 font-lock-constant-face
)
608 (3 font-lock-keyword-face
))
609 ("^\\([a-z]\\) \\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
610 (1 font-lock-constant-face
)
611 (2 font-lock-keyword-face
)
612 (3 font-lock-variable-name-face
))
613 ("^\\(!\\s-*\\(search\\|include\\|default\\)\\)\\s-*\\([^\n\r]*\\)$"
614 (1 font-lock-keyword-face
)
615 (3 font-lock-variable-name-face
))
616 ("^\\(!\\s-*\\sw+\\)=\\([^\n\r]*\\)$"
617 (1 font-lock-keyword-face
)
618 (2 font-lock-variable-name-face
)))
621 "Mode for Sys V prototype files."))
623 ;; Solaris/Sys V pkginfo files
624 (when (memq 'pkginfo-generic-mode generic-extras-enable-list
)
626 (define-generic-mode pkginfo-generic-mode
629 '(("^\\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
630 (1 font-lock-keyword-face
)
631 (2 font-lock-variable-name-face
)))
634 "Mode for Sys V pkginfo files."))
637 ;; Includes extra keywords from Armando Singer [asinger@MAIL.COLGATE.EDU]
638 (when (memq 'javascript-generic-mode generic-extras-enable-list
)
640 (define-generic-mode javascript-generic-mode
641 '("//" ("/*" .
"*/"))
664 ;; words reserved for ECMA extensions below
675 ;; Java Keywords reserved by JavaScript
702 '(("^\\s-*function\\s-+\\([A-Za-z0-9_]+\\)"
703 (1 font-lock-function-name-face
))
704 ("^\\s-*var\\s-+\\([A-Za-z0-9_]+\\)"
705 (1 font-lock-variable-name-face
)))
710 (setq imenu-generic-expression
711 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1)
712 ("*Variables*" "^var\\s-+\\([A-Za-z0-9_]+\\)" 1))))))
713 "Mode for JavaScript files."))
716 (when (memq 'vrml-generic-mode generic-extras-enable-list
)
718 (define-generic-mode vrml-generic-mode
748 '(("USE\\s-+\\([-A-Za-z0-9_]+\\)"
749 (1 font-lock-constant-face
))
750 ("DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
751 (1 font-lock-type-face
)
752 (2 font-lock-constant-face
))
753 ("^\\s-*\\([-A-Za-z0-9_]+\\)\\s-*{"
754 (1 font-lock-function-name-face
))
755 ("^\\s-*\\(geometry\\|appearance\\|material\\)\\s-+\\([-A-Za-z0-9_]+\\)"
756 (2 font-lock-variable-name-face
)))
761 (setq imenu-generic-expression
762 '((nil "^\\([A-Za-z0-9_]+\\)\\s-*{" 1)
764 "DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
766 "Generic Mode for VRML files."))
769 (when (memq 'java-manifest-generic-mode generic-extras-enable-list
)
771 (define-generic-mode java-manifest-generic-mode
781 '(("^Name:\\s-+\\([^\n\r]*\\)$"
782 (1 font-lock-variable-name-face
))
783 ("^\\(Manifest\\|Required\\|Signature\\)-Version:\\s-+\\([^\n\r]*\\)$"
784 (2 font-lock-constant-face
)))
785 '("[mM][aA][nN][iI][fF][eE][sS][tT]\\.[mM][fF]\\'")
787 "Mode for Java Manifest files"))
789 ;; Java properties files
790 (when (memq 'java-properties-generic-mode generic-extras-enable-list
)
792 (define-generic-mode java-properties-generic-mode
796 (let ((java-properties-key
797 "\\(\\([-A-Za-z0-9_\\./]\\|\\(\\\\[ =:]\\)\\)+\\)")
798 (java-properties-value
800 ;; Property and value can be separated in a number of different ways:
808 (concat "^" java-properties-key elt java-properties-value
"$")
809 '(1 font-lock-constant-face
)
810 '(4 font-lock-variable-name-face
))))
811 ;; These are the separators
812 '(":\\s-*" "\\s-+" "\\s-*=\\s-*"))))
817 (setq imenu-generic-expression
818 '((nil "^\\([^#! \t\n\r=:]+\\)" 1))))))
819 "Mode for Java properties files."))
821 ;; C shell alias definitions
822 (when (memq 'alias-generic-mode generic-extras-enable-list
)
824 (define-generic-mode alias-generic-mode
827 '(("^alias\\s-+\\([-A-Za-z0-9_]+\\)\\s-+"
828 (1 font-lock-variable-name-face
))
829 ("^unalias\\s-+\\([-A-Za-z0-9_]+\\)\\s-*$"
830 (1 font-lock-variable-name-face
)))
835 (setq imenu-generic-expression
836 '((nil "^\\(alias\\|unalias\\)\\s-+\\([-a-zA-Z0-9_]+\\)" 2))))))
837 "Mode for C Shell alias files."))
840 ;; Contributed by ACorreir@pervasive-sw.com (Alfred Correira)
841 (when (memq 'rc-generic-mode generic-extras-enable-list
)
843 (define-generic-mode rc-generic-mode
898 ;; the choice of what tokens go where is somewhat arbitrary,
899 ;; as is the choice of which value tokens are included, as
900 ;; the choice of face for each token group
903 (generic-make-keywords-list
912 (generic-make-keywords-list
917 font-lock-function-name-face
)
918 '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face
)
919 '("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face
)
920 '("^#[ \t]*\\(elif\\|if\\)\\>"
921 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil
922 (1 font-lock-constant-face
)
923 (2 font-lock-variable-name-face nil t
)))
924 '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
925 (1 font-lock-constant-face
)
926 (2 font-lock-variable-name-face nil t
))))
929 "Generic mode for MS-Windows Resource files."))
931 ;; InstallShield RUL files
932 ;; Contributed by Alfred.Correira@Pervasive.Com
933 ;; Bugfixes by "Rolf Sandau" <Rolf.Sandau@marconi.com>
934 (when (memq 'rul-generic-mode generic-extras-enable-list
)
938 ;;; build the regexp strings using regexp-opt
939 (defconst installshield-statement-keyword-list
958 ;; "goto" -- handled elsewhere
972 "Statement keywords used in InstallShield 3 and 5.")
974 (defconst installshield-system-functions-list
994 "ComponentAddItem" ; differs between IS3 and IS5
995 "ComponentCompareSizeRequired" ; IS5 only
997 "ComponentError" ; IS5 only
998 "ComponentFileEnum" ; IS5 only
999 "ComponentFileInfo" ; IS5 only
1000 "ComponentFilterLanguage" ; IS5 only
1001 "ComponentFilterOS" ; IS5 only
1002 "ComponentGetData" ; IS5 only
1003 "ComponentGetItemInfo" ; IS3 only
1004 "ComponentGetItemSize" ; differs between IS3 and IS5
1005 "ComponentIsItemSelected" ; differs between IS3 and IS5
1006 "ComponentListItems"
1007 "ComponentMoveData" ; IS5 only
1008 "ComponentSelectItem" ; differs between IS3 and IS5
1009 "ComponentSetData" ; IS5 only
1010 "ComponentSetItemInfo" ; IS3 only
1011 "ComponentSetTarget" ; IS5 only
1012 "ComponentSetupTypeEnum" ; IS5 only
1013 "ComponentSetupTypeGetData" ; IS5 only
1014 "ComponentSetupTypeSet" ; IS5 only
1015 "ComponentTotalSize"
1016 "ComponentValidate" ; IS5 only
1017 "CompressAdd" ; IS3 only
1018 "CompressDel" ; IS3 only
1019 "CompressEnum" ; IS3 only
1020 "CompressGet" ; IS3 only
1021 "CompressInfo" ; IS3 only
1025 "CreateProgramFolder"
1026 "DeinstallSetReference" ; IS5 only
1052 "FileSetBeginDefine" ; IS3 only
1053 "FileSetEndDefine" ; IS3 only
1054 "FileSetPerformEz" ; IS3 only
1055 "FileSetPerform" ; IS3 only
1056 "FileSetReset" ; IS3 only
1057 "FileSetRoot" ; IS3 only
1071 "GetValidDrivesList"
1086 "ListGetFirstString"
1090 "ListSetCurrentItem"
1096 "LongPathToShortPath"
1111 "PlayMMedia" ; IS5 only
1118 "RegDBGetKeyValueEx"
1119 "RegDBSetKeyValueEx"
1120 "RegDBSetDefaultRoot"
1129 "SdComponentAdvCheckSpace"
1130 "SdComponentAdvInit"
1131 "SdComponentAdvUpdateSpace"
1133 "SdComponentDialog2"
1134 "SdComponentDialogAdv"
1135 "SdComponentDialogEx"
1136 "SdComponentDlgCheckSpace"
1139 "SdConfirmRegistration"
1151 "SdGetUserCompanyInfo"
1160 "SdOptionsButtonsInit"
1161 "SdPlugInProductName"
1164 "SdRegExEnableButton"
1169 "SdSetSequentialItems"
1171 "SdSetupTypeEx" ; IS5 only
1182 "SdUpdateComponentSelection"
1188 "SetDisplayEffect" ; IS5 only
1190 "SetForegroundWindow"
1203 "StrRemoveLastSlash"
1217 "System functions defined in InstallShield 3 and 5.")
1219 (defconst installshield-system-variables-list
1223 "CORECOMPONENTHANDLING"
1249 "System variables used in InstallShield 3 and 5.")
1251 (defconst installshield-types-list
1270 "Type keywords used in InstallShield 3 and 5.")
1272 ;;; some might want to skip highlighting these to improve performance
1273 (defconst installshield-funarg-constants-list
1303 "COMP_UPDATE_VERSION"
1322 "DLG_INFO_CHECKSELECTION"
1324 "DLG_INFO_USEDECIMAL"
1325 "DLG_MSG_INFORMATION"
1346 "FILE_ATTR_ARCHIVED"
1347 "FILE_ATTR_DIRECTORY"
1350 "FILE_ATTR_READONLY"
1356 "FILE_MODE_BINARYREADONLY"
1378 "HKEY_LOCAL_MACHINE"
1423 "REGDB_APPPATH_DEFAULT"
1426 "REGDB_ERR_CONNECTIONEXISTS"
1427 "REGDB_ERR_CORRUPTEDREGSITRY"
1428 "REGDB_ERR_INITIALIZATION"
1429 "REGDB_ERR_INVALIDHANDLE"
1430 "REGDB_ERR_INVALIDNAME"
1432 "REGDB_STRING_EXPAND"
1433 "REGDB_STRING_MULTI"
1435 "REGDB_UNINSTALL_NAME"
1479 "Function argument constants used in InstallShield 3 and 5."))
1481 (defvar rul-generic-mode-syntax-table nil
1482 "Syntax table to use in `rul-generic-mode' buffers.")
1484 (setq rul-generic-mode-syntax-table
1485 (make-syntax-table c
++-mode-syntax-table
))
1487 (modify-syntax-entry ?
\r "> b" rul-generic-mode-syntax-table
)
1488 (modify-syntax-entry ?
\n "> b" rul-generic-mode-syntax-table
)
1490 (modify-syntax-entry ?
/ ". 124b" rul-generic-mode-syntax-table
)
1491 (modify-syntax-entry ?
* ". 23" rul-generic-mode-syntax-table
)
1493 ;; here manually instead
1494 (defun generic-rul-mode-setup-function ()
1495 (make-local-variable 'parse-sexp-ignore-comments
)
1496 (make-local-variable 'comment-start
)
1497 (make-local-variable 'comment-start-skip
)
1498 (make-local-variable 'comment-end
)
1499 (setq imenu-generic-expression
1500 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1))
1501 parse-sexp-ignore-comments t
1505 ;;; comment-start "//"
1506 ;;; comment-start-skip ""
1508 ;; (set-syntax-table rul-generic-mode-syntax-table)
1509 (setq font-lock-syntax-table rul-generic-mode-syntax-table
))
1511 ;; moved mode-definition behind defun-definition to be warning-free - 15.11.02/RSan
1512 (define-generic-mode rul-generic-mode
1513 ;; Using "/*" and "*/" doesn't seem to be working right
1514 '("//" ("/*" .
"*/" ))
1515 (eval-when-compile installshield-statement-keyword-list
)
1518 ;; preprocessor constructs
1519 '("#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)"
1520 1 font-lock-string-face
)
1521 '("#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
1522 (1 font-lock-reference-face
)
1523 (2 font-lock-variable-name-face nil t
))
1524 ;; indirect string constants
1525 '("\\(@[A-Za-z][A-Za-z0-9_]+\\)" 1 font-lock-builtin-face
)
1527 '("[ \t]*\\(\\sw+:\\)" 1 font-lock-reference-face
)
1528 '("\\<\\(goto\\)\\>[ \t]*\\(\\sw+\\)?"
1529 (1 font-lock-keyword-face
)
1530 (2 font-lock-reference-face nil t
))
1532 (generic-make-keywords-list
1533 installshield-system-variables-list
1534 font-lock-variable-name-face
"[^_]" "[^_]")
1536 (generic-make-keywords-list
1537 installshield-system-functions-list
1538 font-lock-function-name-face
"[^_]" "[^_]")
1540 (generic-make-keywords-list
1541 installshield-types-list
1542 font-lock-type-face
"[^_]" "[^_]")
1543 ;; function argument constants
1544 (generic-make-keywords-list
1545 installshield-funarg-constants-list
1546 font-lock-variable-name-face
"[^_]" "[^_]"))) ; is this face the best choice?
1547 '("\\.[rR][uU][lL]\\'")
1548 '(generic-rul-mode-setup-function)
1549 "Generic mode for InstallShield RUL files.")
1551 (define-skeleton rul-if
1552 "Insert an if statement."
1554 "if(" str
") then" \n
1556 ( "other condition, %s: "
1557 > "elseif(" str
") then" \n
1564 (define-skeleton rul-function
1565 "Insert a function statement."
1567 "function " str
" ()" \n
1568 ( "local variables, %s: "
1575 ;; Additions by ACorreir@pervasive-sw.com (Alfred Correira)
1576 (when (memq 'mailrc-generic-mode generic-extras-enable-list
)
1578 (define-generic-mode mailrc-generic-mode
1589 '(("^\\s-*\\(alias\\|group\\)\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1590 (2 font-lock-constant-face
)
1591 (3 font-lock-variable-name-face
))
1592 ("^\\s-*\\(unset\\|set\\|ignore\\)\\s-+\\([-A-Za-z0-9_]+\\)=?\\([^\n\r#]*\\)\\(#.*\\)?$"
1593 (2 font-lock-constant-face
)
1594 (3 font-lock-variable-name-face
))
1595 ("^\\s-*\\(source\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1596 (2 font-lock-variable-name-face
)))
1599 "Mode for mailrc files."))
1602 (when (memq 'inetd-conf-generic-mode generic-extras-enable-list
)
1604 (define-generic-mode inetd-conf-generic-mode
1613 '(("^\\([-A-Za-z0-9_]+\\)" 1 font-lock-type-face
))
1614 '("/etc/inetd.conf\\'")
1618 (setq imenu-generic-expression
1619 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1622 (when (memq 'etc-services-generic-mode generic-extras-enable-list
)
1624 (define-generic-mode etc-services-generic-mode
1629 '(("^\\([-A-Za-z0-9_]+\\)\\s-+\\([0-9]+\\)/"
1630 (1 font-lock-type-face
)
1631 (2 font-lock-variable-name-face
)))
1632 '("/etc/services\\'")
1636 (setq imenu-generic-expression
1637 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1639 ;; Password and Group files
1640 (when (memq 'etc-passwd-generic-mode generic-extras-enable-list
)
1642 (define-generic-mode etc-passwd-generic-mode
1643 nil
;; No comment characters
1644 '("root") ;; Only one keyword
1650 ;; User name -- Never blank!
1653 ;; Password, UID and GID
1656 (make-list 3 "\\([^:]+\\)")
1659 ;; GECOS/Name -- might be blank
1662 ;; Home directory and shell
1667 '(1 font-lock-type-face
)
1668 '(5 font-lock-variable-name-face
)
1669 '(6 font-lock-constant-face
)
1670 '(7 font-lock-warning-face
))
1671 '("^\\([^:]+\\):\\([^:]*\\):\\([0-9]+\\):\\(.*\\)$"
1672 (1 font-lock-type-face
)
1673 (4 font-lock-variable-name-face
))))
1674 '("/etc/passwd\\'" "/etc/group\\'")
1678 (setq imenu-generic-expression
1679 '((nil "^\\([-A-Za-z0-9_]+\\):" 1))))))))
1682 (when (memq 'etc-fstab-generic-mode generic-extras-enable-list
)
1684 (define-generic-mode etc-fstab-generic-mode
1723 '(("^\\([^# \t]+\\)\\s-+\\([^# \t]+\\)"
1724 (1 font-lock-type-face t
)
1725 (2 font-lock-variable-name-face t
)))
1726 '("/etc/[v]*fstab\\'")
1730 (setq imenu-generic-expression
1731 '((nil "^\\([^# \t]+\\)\\s-+" 1))))))))
1733 ;; From Jacques Duthen <jacques.duthen@sncf.fr>
1734 (when (memq 'show-tabs-generic-mode generic-extras-enable-list
)
1738 (defconst show-tabs-generic-mode-font-lock-defaults-1
1739 '(;; trailing spaces must come before...
1740 ("[ \t]+$" .
'show-tabs-space
)
1742 ("[^\n\t]\\(\t+\\)" (1 'show-tabs-tab
))))
1744 (defconst show-tabs-generic-mode-font-lock-defaults-2
1745 '(;; trailing spaces must come before...
1746 ("[ \t]+$" .
'show-tabs-space
)
1748 ("\t+" .
'show-tabs-tab
))))
1750 (defface show-tabs-tab
1751 '((((class grayscale
) (background light
)) (:background
"DimGray" :weight bold
))
1752 (((class grayscale
) (background dark
)) (:background
"LightGray" :weight bold
))
1753 (((class color
) (min-colors 88)) (:background
"red1"))
1754 (((class color
)) (:background
"red"))
1756 "Font Lock mode face used to highlight TABs."
1758 ;; backward-compatibility alias
1759 (put 'show-tabs-tab-face
'face-alias
'show-tabs-tab
)
1761 (defface show-tabs-space
1762 '((((class grayscale
) (background light
)) (:background
"DimGray" :weight bold
))
1763 (((class grayscale
) (background dark
)) (:background
"LightGray" :weight bold
))
1764 (((class color
) (min-colors 88)) (:background
"yellow1"))
1765 (((class color
)) (:background
"yellow"))
1767 "Font Lock mode face used to highlight spaces."
1769 ;; backward-compatibility alias
1770 (put 'show-tabs-space-face
'face-alias
'show-tabs-space
)
1772 (define-generic-mode show-tabs-generic-mode
1773 nil
;; no comment char
1775 (eval-when-compile show-tabs-generic-mode-font-lock-defaults-1
)
1776 nil
;; no auto-mode-alist
1777 ;; '(show-tabs-generic-mode-hook-fun)
1779 "Generic mode to show tabs and trailing spaces"))
1781 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1783 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1785 (when (memq 'named-boot-generic-mode generic-extras-enable-list
)
1787 (define-generic-mode named-boot-generic-mode
1788 ;; List of comment characters
1791 '("cache" "primary" "secondary" "forwarders" "limit" "options"
1792 "directory" "check-names")
1793 ;; List of additional font-lock-expressions
1794 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face
)
1795 ("^directory\\s-+\\(.*\\)" 1 font-lock-variable-name-face
)
1796 ("^\\(primary\\|cache\\)\\s-+\\([.A-Za-z]+\\)\\s-+\\(.*\\)"
1797 (2 font-lock-variable-name-face
)
1798 (3 font-lock-constant-face
)))
1799 ;; List of additional automode-alist expressions
1800 '("/etc/named.boot\\'")
1801 ;; List of set up functions to call
1804 (when (memq 'named-database-generic-mode generic-extras-enable-list
)
1806 (define-generic-mode named-database-generic-mode
1807 ;; List of comment characters
1810 '("IN" "NS" "CNAME" "SOA" "PTR" "MX" "A")
1811 ;; List of additional font-lock-expressions
1812 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face
)
1813 ("^\\([.A-Za-z0-9]+\\)" 1 font-lock-variable-name-face
))
1814 ;; List of additional auto-mode-alist expressions
1816 ;; List of set up functions to call
1819 (defvar named-database-time-string
"%Y%m%d%H"
1820 "Timestring for named serial numbers.")
1822 (defun named-database-print-serial ()
1823 "Print a serial number based on the current date."
1825 (insert (format-time-string named-database-time-string
(current-time)))))
1827 (when (memq 'resolve-conf-generic-mode generic-extras-enable-list
)
1829 (define-generic-mode resolve-conf-generic-mode
1830 ;; List of comment characters
1833 '("nameserver" "domain" "search" "sortlist" "options")
1834 ;; List of additional font-lock-expressions
1836 ;; List of additional auto-mode-alist expressions
1837 '("/etc/resolv[e]?.conf\\'")
1838 ;; List of set up functions to call
1841 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1842 ;; Modes for spice and common electrical engineering circuit netlist formats
1843 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1845 (when (memq 'spice-generic-mode generic-extras-enable-list
)
1847 (define-generic-mode spice-generic-mode
1864 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1865 (" \\(\\$ .*\\)$" 1 font-lock-comment-face
)
1866 ("^\\(\\$ .*\\)$" 1 font-lock-comment-face
)
1867 ("\\([*].*\\)" 1 font-lock-comment-face
)
1868 ("^\\([+]\\)" 1 font-lock-string-face
)
1869 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face
)
1870 ("\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
)
1871 ("\\('[^']+'\\)" 1 font-lock-string-face
)
1872 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face
))
1874 "\\.[sS][pP][iI]\\'"
1875 "\\.[sS][pP][iI][cC][eE]\\'"
1876 "\\.[iI][nN][cC]\\'")
1878 'generic-bracket-support
1879 ;; Make keywords case-insensitive
1882 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
)))))
1883 "Generic mode for SPICE circuit netlist files."))
1885 (when (memq 'ibis-generic-mode generic-extras-enable-list
)
1887 (define-generic-mode ibis-generic-mode
1890 '(("[[]\\([^]]*\\)[]]" 1 font-lock-keyword-face
)
1891 ("\\(\\(_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
))
1892 '("\\.[iI][bB][sS]\\'")
1893 '(generic-bracket-support)
1894 "Generic mode for IBIS circuit netlist files."))
1896 (when (memq 'astap-generic-mode generic-extras-enable-list
)
1898 (define-generic-mode astap-generic-mode
1913 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1914 (";\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1915 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face
)
1916 ("\\('[^']+'\\)" 1 font-lock-string-face
)
1917 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face
)
1918 ("[(,]\\s-*\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
))
1920 "\\.[aA][sS][xX]\\'"
1921 "\\.[aA][sS][tT][aA][pP]\\'"
1922 "\\.[pP][sS][pP]\\'"
1923 "\\.[dD][eE][cC][kK]\\'"
1924 "\\.[gG][oO][dD][aA][tT][aA]")
1926 'generic-bracket-support
1927 ;; Make keywords case-insensitive
1930 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
)))))
1931 "Generic mode for ASTAP circuit netlist files."))
1933 (when (memq 'etc-modules-conf-generic-mode generic-extras-enable-list
)
1935 (define-generic-mode etc-modules-conf-generic-mode
1936 ;; List of comment characters
1954 "generic_stringfile"
1970 ;; List of additional font-lock-expressions
1972 ;; List of additional automode-alist expressions
1973 '("/etc/modules.conf" "/etc/conf.modules")
1974 ;; List of set up functions to call
1977 (provide 'generic-x
)
1979 ;;; arch-tag: cde692a5-9ff6-4506-9999-c67999c2bdb5
1980 ;;; generic-x.el ends here