1 ;;; generic-x.el --- A collection of generic modes
3 ;; Copyright (C) 1997, 1998, 2002, 2003, 2004,
4 ;; 2005 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]\\'"
515 "\\`[cC][oO][nN][fF][iI][gG]\\."
516 "\\`[aA][uU][tT][oO][eE][xX][eE][cC]\\.")
517 '(generic-bat-mode-setup-function)
518 "Generic mode for MS-Windows BAT files.")
520 (defvar bat-generic-mode-syntax-table nil
521 "Syntax table in use in `bat-generic-mode' buffers.")
523 (defvar bat-generic-mode-keymap
(make-sparse-keymap)
524 "Keymap for bet-generic-mode.")
526 (defun bat-generic-mode-compile ()
527 "Run the current BAT file in a compilation buffer."
529 (let ((compilation-buffer-name-function
532 (concat "*" (buffer-file-name) "*")))))
534 (concat (w32-shell-name) " -c " (buffer-file-name)))))
536 (eval-when-compile (require 'comint
))
537 (defun bat-generic-mode-run-as-comint ()
538 "Run the current BAT file in a comint buffer."
541 (let* ((file (buffer-file-name))
542 (buf-name (concat "*" file
"*")))
545 (get-buffer-create buf-name
))
554 (display-buffer buf-name
))))
556 (define-key bat-generic-mode-keymap
"\C-c\C-c" 'bat-generic-mode-compile
)
558 ;; Make underscores count as words
559 (unless bat-generic-mode-syntax-table
560 (setq bat-generic-mode-syntax-table
(make-syntax-table))
561 (modify-syntax-entry ?_
"w" bat-generic-mode-syntax-table
))
563 ;; bat-generic-mode doesn't use the comment functionality of
564 ;; define-generic-mode because it has a three-letter comment-string,
565 ;; so we do it here manually instead
566 (defun generic-bat-mode-setup-function ()
567 (make-local-variable 'parse-sexp-ignore-comments
)
568 (make-local-variable 'comment-start
)
569 (make-local-variable 'comment-start-skip
)
570 (make-local-variable 'comment-end
)
571 (setq imenu-generic-expression
'((nil "^:\\(\\sw+\\)" 1))
572 parse-sexp-ignore-comments t
575 comment-start-skip
"[Rr][Ee][Mm] *")
576 (set-syntax-table bat-generic-mode-syntax-table
)
577 ;; Make keywords case-insensitive
578 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
))
579 (use-local-map bat-generic-mode-keymap
)))
582 ;; Mailagent is a Unix mail filtering program. Anyone wanna do a
583 ;; generic mode for procmail?
584 (when (memq 'mailagent-rules-generic-mode generic-extras-enable-list
)
586 (define-generic-mode mailagent-rules-generic-mode
588 '("SAVE" "DELETE" "PIPE" "ANNOTATE" "REJECT")
589 '(("^\\(\\sw+\\)\\s-*=" 1 font-lock-variable-name-face
)
590 ("\\s-/\\([^/]+\\)/[i, \t\n]" 1 font-lock-constant-face
))
595 (setq imenu-generic-expression
596 '((nil "\\s-/\\([^/]+\\)/[i, \t\n]" 1))))))
597 "Mode for Mailagent rules files."))
599 ;; Solaris/Sys V prototype files
600 (when (memq 'prototype-generic-mode generic-extras-enable-list
)
602 (define-generic-mode prototype-generic-mode
605 '(("^\\([0-9]\\)?\\s-*\\([a-z]\\)\\s-+\\([A-Za-z_]+\\)\\s-+\\([^\n\r]*\\)$"
606 (2 font-lock-constant-face
)
607 (3 font-lock-keyword-face
))
608 ("^\\([a-z]\\) \\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
609 (1 font-lock-constant-face
)
610 (2 font-lock-keyword-face
)
611 (3 font-lock-variable-name-face
))
612 ("^\\(!\\s-*\\(search\\|include\\|default\\)\\)\\s-*\\([^\n\r]*\\)$"
613 (1 font-lock-keyword-face
)
614 (3 font-lock-variable-name-face
))
615 ("^\\(!\\s-*\\sw+\\)=\\([^\n\r]*\\)$"
616 (1 font-lock-keyword-face
)
617 (2 font-lock-variable-name-face
)))
620 "Mode for Sys V prototype files."))
622 ;; Solaris/Sys V pkginfo files
623 (when (memq 'pkginfo-generic-mode generic-extras-enable-list
)
625 (define-generic-mode pkginfo-generic-mode
628 '(("^\\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
629 (1 font-lock-keyword-face
)
630 (2 font-lock-variable-name-face
)))
633 "Mode for Sys V pkginfo files."))
636 ;; Includes extra keywords from Armando Singer [asinger@MAIL.COLGATE.EDU]
637 (when (memq 'javascript-generic-mode generic-extras-enable-list
)
639 (define-generic-mode javascript-generic-mode
640 '("//" ("/*" .
"*/"))
663 ;; words reserved for ECMA extensions below
674 ;; Java Keywords reserved by JavaScript
701 '(("^\\s-*function\\s-+\\([A-Za-z0-9_]+\\)"
702 (1 font-lock-function-name-face
))
703 ("^\\s-*var\\s-+\\([A-Za-z0-9_]+\\)"
704 (1 font-lock-variable-name-face
)))
709 (setq imenu-generic-expression
710 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1)
711 ("*Variables*" "^var\\s-+\\([A-Za-z0-9_]+\\)" 1))))))
712 "Mode for JavaScript files."))
715 (when (memq 'vrml-generic-mode generic-extras-enable-list
)
717 (define-generic-mode vrml-generic-mode
747 '(("USE\\s-+\\([-A-Za-z0-9_]+\\)"
748 (1 font-lock-constant-face
))
749 ("DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
750 (1 font-lock-type-face
)
751 (2 font-lock-constant-face
))
752 ("^\\s-*\\([-A-Za-z0-9_]+\\)\\s-*{"
753 (1 font-lock-function-name-face
))
754 ("^\\s-*\\(geometry\\|appearance\\|material\\)\\s-+\\([-A-Za-z0-9_]+\\)"
755 (2 font-lock-variable-name-face
)))
760 (setq imenu-generic-expression
761 '((nil "^\\([A-Za-z0-9_]+\\)\\s-*{" 1)
763 "DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
765 "Generic Mode for VRML files."))
768 (when (memq 'java-manifest-generic-mode generic-extras-enable-list
)
770 (define-generic-mode java-manifest-generic-mode
780 '(("^Name:\\s-+\\([^\n\r]*\\)$"
781 (1 font-lock-variable-name-face
))
782 ("^\\(Manifest\\|Required\\|Signature\\)-Version:\\s-+\\([^\n\r]*\\)$"
783 (2 font-lock-constant-face
)))
784 '("[mM][aA][nN][iI][fF][eE][sS][tT]\\.[mM][fF]\\'")
786 "Mode for Java Manifest files"))
788 ;; Java properties files
789 (when (memq 'java-properties-generic-mode generic-extras-enable-list
)
791 (define-generic-mode java-properties-generic-mode
795 (let ((java-properties-key
796 "\\(\\([-A-Za-z0-9_\\./]\\|\\(\\\\[ =:]\\)\\)+\\)")
797 (java-properties-value
799 ;; Property and value can be separated in a number of different ways:
807 (concat "^" java-properties-key elt java-properties-value
"$")
808 '(1 font-lock-constant-face
)
809 '(4 font-lock-variable-name-face
))))
810 ;; These are the separators
811 '(":\\s-*" "\\s-+" "\\s-*=\\s-*"))))
816 (setq imenu-generic-expression
817 '((nil "^\\([^#! \t\n\r=:]+\\)" 1))))))
818 "Mode for Java properties files."))
820 ;; C shell alias definitions
821 (when (memq 'alias-generic-mode generic-extras-enable-list
)
823 (define-generic-mode alias-generic-mode
826 '(("^alias\\s-+\\([-A-Za-z0-9_]+\\)\\s-+"
827 (1 font-lock-variable-name-face
))
828 ("^unalias\\s-+\\([-A-Za-z0-9_]+\\)\\s-*$"
829 (1 font-lock-variable-name-face
)))
834 (setq imenu-generic-expression
835 '((nil "^\\(alias\\|unalias\\)\\s-+\\([-a-zA-Z0-9_]+\\)" 2))))))
836 "Mode for C Shell alias files."))
839 ;; Contributed by ACorreir@pervasive-sw.com (Alfred Correira)
840 (when (memq 'rc-generic-mode generic-extras-enable-list
)
842 (define-generic-mode rc-generic-mode
897 ;; the choice of what tokens go where is somewhat arbitrary,
898 ;; as is the choice of which value tokens are included, as
899 ;; the choice of face for each token group
902 (generic-make-keywords-list
911 (generic-make-keywords-list
916 font-lock-function-name-face
)
917 '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face
)
918 '("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face
)
919 '("^#[ \t]*\\(elif\\|if\\)\\>"
920 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil
921 (1 font-lock-constant-face
)
922 (2 font-lock-variable-name-face nil t
)))
923 '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
924 (1 font-lock-constant-face
)
925 (2 font-lock-variable-name-face nil t
))))
928 "Generic mode for MS-Windows Resource files."))
930 ;; InstallShield RUL files
931 ;; Contributed by Alfred.Correira@Pervasive.Com
932 ;; Bugfixes by "Rolf Sandau" <Rolf.Sandau@marconi.com>
933 (when (memq 'rul-generic-mode generic-extras-enable-list
)
937 ;;; build the regexp strings using regexp-opt
938 (defconst installshield-statement-keyword-list
957 ;; "goto" -- handled elsewhere
971 "Statement keywords used in InstallShield 3 and 5.")
973 (defconst installshield-system-functions-list
993 "ComponentAddItem" ; differs between IS3 and IS5
994 "ComponentCompareSizeRequired" ; IS5 only
996 "ComponentError" ; IS5 only
997 "ComponentFileEnum" ; IS5 only
998 "ComponentFileInfo" ; IS5 only
999 "ComponentFilterLanguage" ; IS5 only
1000 "ComponentFilterOS" ; IS5 only
1001 "ComponentGetData" ; IS5 only
1002 "ComponentGetItemInfo" ; IS3 only
1003 "ComponentGetItemSize" ; differs between IS3 and IS5
1004 "ComponentIsItemSelected" ; differs between IS3 and IS5
1005 "ComponentListItems"
1006 "ComponentMoveData" ; IS5 only
1007 "ComponentSelectItem" ; differs between IS3 and IS5
1008 "ComponentSetData" ; IS5 only
1009 "ComponentSetItemInfo" ; IS3 only
1010 "ComponentSetTarget" ; IS5 only
1011 "ComponentSetupTypeEnum" ; IS5 only
1012 "ComponentSetupTypeGetData" ; IS5 only
1013 "ComponentSetupTypeSet" ; IS5 only
1014 "ComponentTotalSize"
1015 "ComponentValidate" ; IS5 only
1016 "CompressAdd" ; IS3 only
1017 "CompressDel" ; IS3 only
1018 "CompressEnum" ; IS3 only
1019 "CompressGet" ; IS3 only
1020 "CompressInfo" ; IS3 only
1024 "CreateProgramFolder"
1025 "DeinstallSetReference" ; IS5 only
1051 "FileSetBeginDefine" ; IS3 only
1052 "FileSetEndDefine" ; IS3 only
1053 "FileSetPerformEz" ; IS3 only
1054 "FileSetPerform" ; IS3 only
1055 "FileSetReset" ; IS3 only
1056 "FileSetRoot" ; IS3 only
1070 "GetValidDrivesList"
1085 "ListGetFirstString"
1089 "ListSetCurrentItem"
1095 "LongPathToShortPath"
1110 "PlayMMedia" ; IS5 only
1117 "RegDBGetKeyValueEx"
1118 "RegDBSetKeyValueEx"
1119 "RegDBSetDefaultRoot"
1128 "SdComponentAdvCheckSpace"
1129 "SdComponentAdvInit"
1130 "SdComponentAdvUpdateSpace"
1132 "SdComponentDialog2"
1133 "SdComponentDialogAdv"
1134 "SdComponentDialogEx"
1135 "SdComponentDlgCheckSpace"
1138 "SdConfirmRegistration"
1150 "SdGetUserCompanyInfo"
1159 "SdOptionsButtonsInit"
1160 "SdPlugInProductName"
1163 "SdRegExEnableButton"
1168 "SdSetSequentialItems"
1170 "SdSetupTypeEx" ; IS5 only
1181 "SdUpdateComponentSelection"
1187 "SetDisplayEffect" ; IS5 only
1189 "SetForegroundWindow"
1202 "StrRemoveLastSlash"
1216 "System functions defined in InstallShield 3 and 5.")
1218 (defconst installshield-system-variables-list
1222 "CORECOMPONENTHANDLING"
1248 "System variables used in InstallShield 3 and 5.")
1250 (defconst installshield-types-list
1269 "Type keywords used in InstallShield 3 and 5.")
1271 ;;; some might want to skip highlighting these to improve performance
1272 (defconst installshield-funarg-constants-list
1302 "COMP_UPDATE_VERSION"
1321 "DLG_INFO_CHECKSELECTION"
1323 "DLG_INFO_USEDECIMAL"
1324 "DLG_MSG_INFORMATION"
1345 "FILE_ATTR_ARCHIVED"
1346 "FILE_ATTR_DIRECTORY"
1349 "FILE_ATTR_READONLY"
1355 "FILE_MODE_BINARYREADONLY"
1377 "HKEY_LOCAL_MACHINE"
1422 "REGDB_APPPATH_DEFAULT"
1425 "REGDB_ERR_CONNECTIONEXISTS"
1426 "REGDB_ERR_CORRUPTEDREGSITRY"
1427 "REGDB_ERR_INITIALIZATION"
1428 "REGDB_ERR_INVALIDHANDLE"
1429 "REGDB_ERR_INVALIDNAME"
1431 "REGDB_STRING_EXPAND"
1432 "REGDB_STRING_MULTI"
1434 "REGDB_UNINSTALL_NAME"
1478 "Function argument constants used in InstallShield 3 and 5."))
1480 (defvar rul-generic-mode-syntax-table nil
1481 "Syntax table to use in `rul-generic-mode' buffers.")
1483 (setq rul-generic-mode-syntax-table
1484 (make-syntax-table c
++-mode-syntax-table
))
1486 (modify-syntax-entry ?
\r "> b" rul-generic-mode-syntax-table
)
1487 (modify-syntax-entry ?
\n "> b" rul-generic-mode-syntax-table
)
1489 (modify-syntax-entry ?
/ ". 124b" rul-generic-mode-syntax-table
)
1490 (modify-syntax-entry ?
* ". 23" rul-generic-mode-syntax-table
)
1492 ;; here manually instead
1493 (defun generic-rul-mode-setup-function ()
1494 (make-local-variable 'parse-sexp-ignore-comments
)
1495 (make-local-variable 'comment-start
)
1496 (make-local-variable 'comment-start-skip
)
1497 (make-local-variable 'comment-end
)
1498 (setq imenu-generic-expression
1499 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1))
1500 parse-sexp-ignore-comments t
1504 ;;; comment-start "//"
1505 ;;; comment-start-skip ""
1507 ;; (set-syntax-table rul-generic-mode-syntax-table)
1508 (setq font-lock-syntax-table rul-generic-mode-syntax-table
))
1510 ;; moved mode-definition behind defun-definition to be warning-free - 15.11.02/RSan
1511 (define-generic-mode rul-generic-mode
1512 ;; Using "/*" and "*/" doesn't seem to be working right
1513 '("//" ("/*" .
"*/" ))
1514 (eval-when-compile installshield-statement-keyword-list
)
1517 ;; preprocessor constructs
1518 '("#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)"
1519 1 font-lock-string-face
)
1520 '("#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
1521 (1 font-lock-reference-face
)
1522 (2 font-lock-variable-name-face nil t
))
1523 ;; indirect string constants
1524 '("\\(@[A-Za-z][A-Za-z0-9_]+\\)" 1 font-lock-builtin-face
)
1526 '("[ \t]*\\(\\sw+:\\)" 1 font-lock-reference-face
)
1527 '("\\<\\(goto\\)\\>[ \t]*\\(\\sw+\\)?"
1528 (1 font-lock-keyword-face
)
1529 (2 font-lock-reference-face nil t
))
1531 (generic-make-keywords-list
1532 installshield-system-variables-list
1533 font-lock-variable-name-face
"[^_]" "[^_]")
1535 (generic-make-keywords-list
1536 installshield-system-functions-list
1537 font-lock-function-name-face
"[^_]" "[^_]")
1539 (generic-make-keywords-list
1540 installshield-types-list
1541 font-lock-type-face
"[^_]" "[^_]")
1542 ;; function argument constants
1543 (generic-make-keywords-list
1544 installshield-funarg-constants-list
1545 font-lock-variable-name-face
"[^_]" "[^_]"))) ; is this face the best choice?
1546 '("\\.[rR][uU][lL]\\'")
1547 '(generic-rul-mode-setup-function)
1548 "Generic mode for InstallShield RUL files.")
1550 (define-skeleton rul-if
1551 "Insert an if statement."
1553 "if(" str
") then" \n
1555 ( "other condition, %s: "
1556 > "elseif(" str
") then" \n
1563 (define-skeleton rul-function
1564 "Insert a function statement."
1566 "function " str
" ()" \n
1567 ( "local variables, %s: "
1574 ;; Additions by ACorreir@pervasive-sw.com (Alfred Correira)
1575 (when (memq 'mailrc-generic-mode generic-extras-enable-list
)
1577 (define-generic-mode mailrc-generic-mode
1588 '(("^\\s-*\\(alias\\|group\\)\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1589 (2 font-lock-constant-face
)
1590 (3 font-lock-variable-name-face
))
1591 ("^\\s-*\\(unset\\|set\\|ignore\\)\\s-+\\([-A-Za-z0-9_]+\\)=?\\([^\n\r#]*\\)\\(#.*\\)?$"
1592 (2 font-lock-constant-face
)
1593 (3 font-lock-variable-name-face
))
1594 ("^\\s-*\\(source\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1595 (2 font-lock-variable-name-face
)))
1598 "Mode for mailrc files."))
1601 (when (memq 'inetd-conf-generic-mode generic-extras-enable-list
)
1603 (define-generic-mode inetd-conf-generic-mode
1612 '(("^\\([-A-Za-z0-9_]+\\)" 1 font-lock-type-face
))
1613 '("/etc/inetd.conf\\'")
1617 (setq imenu-generic-expression
1618 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1621 (when (memq 'etc-services-generic-mode generic-extras-enable-list
)
1623 (define-generic-mode etc-services-generic-mode
1628 '(("^\\([-A-Za-z0-9_]+\\)\\s-+\\([0-9]+\\)/"
1629 (1 font-lock-type-face
)
1630 (2 font-lock-variable-name-face
)))
1631 '("/etc/services\\'")
1635 (setq imenu-generic-expression
1636 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1638 ;; Password and Group files
1639 (when (memq 'etc-passwd-generic-mode generic-extras-enable-list
)
1641 (define-generic-mode etc-passwd-generic-mode
1642 nil
;; No comment characters
1643 '("root") ;; Only one keyword
1649 ;; User name -- Never blank!
1652 ;; Password, UID and GID
1655 (make-list 3 "\\([^:]+\\)")
1658 ;; GECOS/Name -- might be blank
1661 ;; Home directory and shell
1666 '(1 font-lock-type-face
)
1667 '(5 font-lock-variable-name-face
)
1668 '(6 font-lock-constant-face
)
1669 '(7 font-lock-warning-face
))
1670 '("^\\([^:]+\\):\\([^:]*\\):\\([0-9]+\\):\\(.*\\)$"
1671 (1 font-lock-type-face
)
1672 (4 font-lock-variable-name-face
))))
1673 '("/etc/passwd\\'" "/etc/group\\'")
1677 (setq imenu-generic-expression
1678 '((nil "^\\([-A-Za-z0-9_]+\\):" 1))))))))
1681 (when (memq 'etc-fstab-generic-mode generic-extras-enable-list
)
1683 (define-generic-mode etc-fstab-generic-mode
1720 '(("^\\([/-A-Za-z0-9_]+\\)\\s-+\\([/-A-Za-z0-9_]+\\)"
1721 (1 font-lock-type-face t
)
1722 (2 font-lock-variable-name-face t
)))
1723 '("/etc/[v]*fstab\\'")
1727 (setq imenu-generic-expression
1728 '((nil "^\\([/-A-Za-z0-9_]+\\)\\s-+" 1))))))))
1730 ;; From Jacques Duthen <jacques.duthen@sncf.fr>
1731 (when (memq 'show-tabs-generic-mode generic-extras-enable-list
)
1735 (defconst show-tabs-generic-mode-font-lock-defaults-1
1736 '(;; trailing spaces must come before...
1737 ("[ \t]+$" .
'show-tabs-space
)
1739 ("[^\n\t]\\(\t+\\)" (1 'show-tabs-tab
))))
1741 (defconst show-tabs-generic-mode-font-lock-defaults-2
1742 '(;; trailing spaces must come before...
1743 ("[ \t]+$" .
'show-tabs-space
)
1745 ("\t+" .
'show-tabs-tab
))))
1747 (defface show-tabs-tab
1748 '((((class grayscale
) (background light
)) (:background
"DimGray" :weight bold
))
1749 (((class grayscale
) (background dark
)) (:background
"LightGray" :weight bold
))
1750 (((class color
) (min-colors 88)) (:background
"red1"))
1751 (((class color
)) (:background
"red"))
1753 "Font Lock mode face used to highlight TABs."
1755 ;; backward-compatibility alias
1756 (put 'show-tabs-tab-face
'face-alias
'show-tabs-tab
)
1758 (defface show-tabs-space
1759 '((((class grayscale
) (background light
)) (:background
"DimGray" :weight bold
))
1760 (((class grayscale
) (background dark
)) (:background
"LightGray" :weight bold
))
1761 (((class color
) (min-colors 88)) (:background
"yellow1"))
1762 (((class color
)) (:background
"yellow"))
1764 "Font Lock mode face used to highlight spaces."
1766 ;; backward-compatibility alias
1767 (put 'show-tabs-space-face
'face-alias
'show-tabs-space
)
1769 (define-generic-mode show-tabs-generic-mode
1770 nil
;; no comment char
1772 (eval-when-compile show-tabs-generic-mode-font-lock-defaults-1
)
1773 nil
;; no auto-mode-alist
1774 ;; '(show-tabs-generic-mode-hook-fun)
1776 "Generic mode to show tabs and trailing spaces"))
1778 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1780 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1782 (when (memq 'named-boot-generic-mode generic-extras-enable-list
)
1784 (define-generic-mode named-boot-generic-mode
1785 ;; List of comment characters
1788 '("cache" "primary" "secondary" "forwarders" "limit" "options"
1789 "directory" "check-names")
1790 ;; List of additional font-lock-expressions
1791 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face
)
1792 ("^directory\\s-+\\(.*\\)" 1 font-lock-variable-name-face
)
1793 ("^\\(primary\\|cache\\)\\s-+\\([.A-Za-z]+\\)\\s-+\\(.*\\)"
1794 (2 font-lock-variable-name-face
)
1795 (3 font-lock-constant-face
)))
1796 ;; List of additional automode-alist expressions
1797 '("/etc/named.boot\\'")
1798 ;; List of set up functions to call
1801 (when (memq 'named-database-generic-mode generic-extras-enable-list
)
1803 (define-generic-mode named-database-generic-mode
1804 ;; List of comment characters
1807 '("IN" "NS" "CNAME" "SOA" "PTR" "MX" "A")
1808 ;; List of additional font-lock-expressions
1809 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face
)
1810 ("^\\([.A-Za-z0-9]+\\)" 1 font-lock-variable-name-face
))
1811 ;; List of additional auto-mode-alist expressions
1813 ;; List of set up functions to call
1816 (defvar named-database-time-string
"%Y%m%d%H"
1817 "Timestring for named serial numbers.")
1819 (defun named-database-print-serial ()
1820 "Print a serial number based on the current date."
1822 (insert (format-time-string named-database-time-string
(current-time)))))
1824 (when (memq 'resolve-conf-generic-mode generic-extras-enable-list
)
1826 (define-generic-mode resolve-conf-generic-mode
1827 ;; List of comment characters
1830 '("nameserver" "domain" "search" "sortlist" "options")
1831 ;; List of additional font-lock-expressions
1833 ;; List of additional auto-mode-alist expressions
1834 '("/etc/resolv[e]?.conf\\'")
1835 ;; List of set up functions to call
1838 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1839 ;; Modes for spice and common electrical engineering circuit netlist formats
1840 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1842 (when (memq 'spice-generic-mode generic-extras-enable-list
)
1844 (define-generic-mode spice-generic-mode
1861 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1862 (" \\(\\$ .*\\)$" 1 font-lock-comment-face
)
1863 ("^\\(\\$ .*\\)$" 1 font-lock-comment-face
)
1864 ("\\([*].*\\)" 1 font-lock-comment-face
)
1865 ("^\\([+]\\)" 1 font-lock-string-face
)
1866 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face
)
1867 ("\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
)
1868 ("\\('[^']+'\\)" 1 font-lock-string-face
)
1869 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face
))
1871 "\\.[sS][pP][iI]\\'"
1872 "\\.[sS][pP][iI][cC][eE]\\'"
1873 "\\.[iI][nN][cC]\\'")
1875 'generic-bracket-support
1876 ;; Make keywords case-insensitive
1879 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
)))))
1880 "Generic mode for SPICE circuit netlist files."))
1882 (when (memq 'ibis-generic-mode generic-extras-enable-list
)
1884 (define-generic-mode ibis-generic-mode
1887 '(("[[]\\([^]]*\\)[]]" 1 font-lock-keyword-face
)
1888 ("\\(\\(_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
))
1889 '("\\.[iI][bB][sS]\\'")
1890 '(generic-bracket-support)
1891 "Generic mode for IBIS circuit netlist files."))
1893 (when (memq 'astap-generic-mode generic-extras-enable-list
)
1895 (define-generic-mode astap-generic-mode
1910 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1911 (";\\s-*\\([*].*\\)" 1 font-lock-comment-face
)
1912 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face
)
1913 ("\\('[^']+'\\)" 1 font-lock-string-face
)
1914 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face
)
1915 ("[(,]\\s-*\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face
))
1917 "\\.[aA][sS][xX]\\'"
1918 "\\.[aA][sS][tT][aA][pP]\\'"
1919 "\\.[pP][sS][pP]\\'"
1920 "\\.[dD][eE][cC][kK]\\'"
1921 "\\.[gG][oO][dD][aA][tT][aA]")
1923 'generic-bracket-support
1924 ;; Make keywords case-insensitive
1927 (setq font-lock-defaults
'(generic-font-lock-keywords nil t
)))))
1928 "Generic mode for ASTAP circuit netlist files."))
1930 (when (memq 'etc-modules-conf-generic-mode generic-extras-enable-list
)
1932 (define-generic-mode etc-modules-conf-generic-mode
1933 ;; List of comment characters
1951 "generic_stringfile"
1967 ;; List of additional font-lock-expressions
1969 ;; List of additional automode-alist expressions
1970 '("/etc/modules.conf" "/etc/conf.modules")
1971 ;; List of set up functions to call
1974 (provide 'generic-x
)
1976 ;;; arch-tag: cde692a5-9ff6-4506-9999-c67999c2bdb5
1977 ;;; generic-x.el ends here