1 ;;; generic-x.el --- Extra Modes for generic-mode
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 some pre-defined 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'. Some platform-specific modes are
38 ;; affected by the variables `generic-define-mswindows-modes' and
39 ;; `generic-define-unix-modes' (which see).
41 ;; You can also send in new modes; if the file types a reasonably common,
42 ;; we would like to install them.
44 ;; DEFAULT GENERIC MODE:
46 ;; This file provides a hook which automatically puts a file into
47 ;; `default-generic-mode' if the first few lines of a file in
48 ;; fundamental mode start with a hash comment character. To disable
49 ;; this functionality, set the variable `generic-use-find-file-hook'
50 ;; to nil BEFORE loading generic-x. See the variables
51 ;; `generic-lines-to-scan' and `generic-find-file-regexp' for
52 ;; customization options.
54 ;; PROBLEMS WHEN USED WITH FOLDING MODE:
56 ;; [The following relates to the obsolete selective-display technique.
57 ;; Folding mode should use invisible text properties instead. -- Dave
60 ;; From Anders Lindgren <andersl@csd.uu.se>
62 ;; Problem summary: Wayne Adams has found a problem when using folding
63 ;; mode in conjuction with font-lock for a mode defined in
66 ;; The problem, as Wayne described it, was that error messages of the
67 ;; following form appeared when both font-lock and folding are used:
69 ;; > - various msgs including "Fontifying region...(error Stack
70 ;; > overflow in regexp matcher)" appear
72 ;; I have just tracked down the cause of the problem. The regexp:s in
73 ;; `generic-x.el' does not take into account the way that folding
74 ;; hides sections of the buffer. The technique is known as
75 ;; `selective-display' and has been available for a very long time (I
76 ;; started using it back in the good old' Emacs 18 days). Basically, a
77 ;; section is hidden by creating one very long line were the newline
78 ;; character (C-j) is replaced by a linefeed (C-m) character.
80 ;; Many other hiding packages, besides folding, use the same technique,
81 ;; the problem should occur when using them as well.
83 ;; The erroronous lines in `generic-extras' look like the following (this
84 ;; example is from the `ini' section):
86 ;; '(("^\\(\\[.*\\]\\)" 1 'font-lock-constant-face)
87 ;; ("^\\(.*\\)=" 1 'font-lock-variable-name-face)
89 ;; The intention of these lines is to highlight lines of the following
95 ;; However, since the `.' regexp symbol match the linefeed character the
96 ;; entire folded section is searched, resulting in a regexp stack
99 ;; Solution suggestion 2: Instead of using ".", use the sequence
100 ;; "[^\n\r]". This will make the rules behave just as before, but they
101 ;; will work together with selective-display.
107 (defgroup generic-x nil
108 "A collection of generic modes."
113 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
114 ;; Default-Generic mode
115 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
117 (defcustom generic-use-find-file-hook t
118 "*If non-nil, add a hook to enter `default-generic-mode' automatically.
119 This is done if the first few lines of a file in fundamental mode
120 start with a hash comment character."
124 (defcustom generic-lines-to-scan 3
125 "*Number of lines that `generic-mode-find-file-hook' looks at.
126 Relevant when deciding whether to enter Default-Generic mode automatically.
127 This variable should be set to a small positive number."
131 (defcustom generic-find-file-regexp "^#"
132 "*Regular expression used by `generic-mode-find-file-hook'.
133 Files in fundamental mode whose first few lines contain a match
134 for this regexp, should be put into Default-Generic mode instead.
135 The number of lines tested for the matches is specified by the
136 value of the variable `generic-lines-to-scan', which see."
140 (defcustom generic-ignore-files-regexp "[Tt][Aa][Gg][Ss]\\'"
141 "*Regular expression used by `generic-mode-find-file-hook'.
142 Files whose names match this regular expression should not be put
143 into Default-Generic mode, even if they have lines which match
144 the regexp in `generic-find-file-regexp'. If the value is nil,
145 `generic-mode-find-file-hook' does not check the file names."
147 :type '(choice (const :tag "Don't check file names" nil) regexp))
149 ;; This generic mode is always defined
150 (define-generic-mode default-generic-mode (list ?#) nil nil nil nil :group 'generic)
152 ;; A more general solution would allow us to enter generic-mode for
153 ;; *any* comment character, but would require us to synthesize a new
154 ;; generic-mode on the fly. I think this gives us most of what we
156 (defun generic-mode-find-file-hook ()
157 "Hook function to enter Default-Generic mode automatically.
159 Done if the first few lines of a file in Fundamental mode start
160 with a match for the regexp in `generic-find-file-regexp', unless
161 the file's name matches the regexp which is the value of the
162 variable `generic-ignore-files-regexp'.
164 This hook will be installed if the variable
165 `generic-use-find-file-hook' is non-nil. The variable
166 `generic-lines-to-scan' determines the number of lines to look at."
167 (when (and (eq major-mode 'fundamental-mode)
168 (or (null generic-ignore-files-regexp)
170 generic-ignore-files-regexp
171 (file-name-sans-versions buffer-file-name)))))
173 (goto-char (point-min))
174 (when (re-search-forward generic-find-file-regexp
176 (forward-line generic-lines-to-scan)
178 (goto-char (point-min))
179 (default-generic-mode)))))
181 (and generic-use-find-file-hook
182 (add-hook 'find-file-hook 'generic-mode-find-file-hook))
184 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
185 ;; Other Generic modes
186 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
188 (defcustom generic-extras-enable-list nil
189 "*List of generic modes to enable by default.
190 Each entry in the list should be a symbol. The variables
191 `generic-define-mswindows-modes' and `generic-define-unix-modes'
192 also affect which generic modes are defined. Please note that if
193 you set this variable after generic-x is loaded, you must reload
194 generic-x to enable the specified modes."
196 :type '(repeat sexp))
198 (defcustom generic-define-mswindows-modes
199 (memq system-type '(windows-nt ms-dos))
200 "*If non-nil, some MS-Windows specific generic modes will be defined."
204 (defcustom generic-define-unix-modes
205 (not (memq system-type '(windows-nt ms-dos)))
206 "*If non-nil, some Unix specific generic modes will be defined."
210 (and generic-define-mswindows-modes
211 (setq generic-extras-enable-list
212 (append '(bat-generic-mode
219 apache-conf-generic-mode
220 apache-log-generic-mode)
221 generic-extras-enable-list)))
223 (and generic-define-unix-modes
224 (setq generic-extras-enable-list
225 (append '(apache-conf-generic-mode
226 apache-log-generic-mode
230 x-resource-generic-mode
232 inetd-conf-generic-mode
233 etc-services-generic-mode
234 etc-passwd-generic-mode
235 etc-fstab-generic-mode)
236 generic-extras-enable-list)))
239 (when (memq 'apache-conf-generic-mode generic-extras-enable-list)
241 (define-generic-mode apache-conf-generic-mode
244 '(("^\\s-*\\(<.*>\\)" 1 font-lock-constant-face)
245 ("^\\s-*\\(\\sw+\\)\\s-" 1 font-lock-variable-name-face))
246 '("srm\\.conf\\'" "httpd\\.conf\\'" "access\\.conf\\'")
250 (setq imenu-generic-expression
251 '((nil "^\\([-A-Za-z0-9_]+\\)" 1)
252 ("*Directories*" "^\\s-*<Directory\\s-*\\([^>]+\\)>" 1)
253 ("*Locations*" "^\\s-*<Location\\s-*\\([^>]+\\)>" 1))))))
254 "Generic mode for Apache or HTTPD configuration files."
257 (when (memq 'apache-log-generic-mode generic-extras-enable-list)
259 (define-generic-mode apache-log-generic-mode
262 ;; Hostname ? user date request return-code number-of-bytes
263 '(("^\\([-a-zA-z0-9.]+\\) - [-A-Za-z]+ \\(\\[.*\\]\\)"
264 (1 font-lock-constant-face)
265 (2 font-lock-variable-name-face)))
268 "Mode for Apache log files"
272 (when (memq 'samba-generic-mode generic-extras-enable-list)
274 (define-generic-mode samba-generic-mode
277 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face)
278 ("^\\s-*\\(.+\\)=\\([^\r\n]*\\)"
279 (1 font-lock-variable-name-face)
280 (2 font-lock-type-face)))
282 '(generic-bracket-support)
283 "Generic mode for Samba configuration files."
287 ;; This is pretty basic. Also, modes for other window managers could
288 ;; be defined as well.
289 (when (memq 'fvwm-generic-mode generic-extras-enable-list)
291 (define-generic-mode fvwm-generic-mode
307 '("\\.fvwmrc\\'" "\\.fvwm2rc\\'")
309 "Generic mode for FVWM configuration files."
313 ;; I'm pretty sure I've seen an actual mode to do this, but I don't
314 ;; think it's standard with Emacs
315 (when (memq 'x-resource-generic-mode generic-extras-enable-list)
317 (define-generic-mode x-resource-generic-mode
320 '(("^\\([^:\n]+:\\)" 1 font-lock-variable-name-face))
321 '("\\.Xdefaults\\'" "\\.Xresources\\'" "\\.Xenvironment\\'" "\\.ad\\'")
323 "Generic mode for X Resource configuration files."
327 (when (memq 'hosts-generic-mode generic-extras-enable-list)
329 (define-generic-mode hosts-generic-mode
332 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face))
333 '("[hH][oO][sS][tT][sS]\\'")
335 "Generic mode for HOSTS files."
338 ;;; Windows INF files
339 (when (memq 'inf-generic-mode generic-extras-enable-list)
341 (define-generic-mode inf-generic-mode
344 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face))
345 '("\\.[iI][nN][fF]\\'")
346 '(generic-bracket-support)
347 "Generic mode for MS-Windows INF files."
350 ;;; Windows INI files
351 ;; Should define escape character as well!
352 (when (memq 'ini-generic-mode generic-extras-enable-list)
354 (define-generic-mode ini-generic-mode
357 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face)
358 ("^\\([^=\n\r]*\\)=\\([^\n\r]*\\)$"
359 (1 font-lock-function-name-face)
360 (2 font-lock-variable-name-face)))
361 '("\\.[iI][nN][iI]\\'")
365 (setq imenu-generic-expression
366 '((nil "^\\[\\(.*\\)\\]" 1)
367 ("*Variables*" "^\\s-*\\([^=]+\\)\\s-*=" 1))))))
368 "Generic mode for MS-Windows INI files.
369 You can use `ini-generic-mode-find-file-hook' to enter this mode
370 automatically for INI files whose names do not end in \".ini\"."
373 (defun ini-generic-mode-find-file-hook ()
374 "Hook function to enter Ini-Generic mode automatically for INI files.
375 Done if the first few lines of a file in Fundamental mode look
376 like an INI file. You can add this hook to `find-file-hook'."
377 (and (eq major-mode 'fundamental-mode)
379 (goto-char (point-min))
380 (and (looking-at "^\\s-*\\[.*\\]")
381 (ini-generic-mode)))))
382 (defalias 'generic-mode-ini-file-find-file-hook 'ini-generic-mode-find-file-hook))
384 ;;; Windows REG files
385 ;;; Unfortunately, Windows 95 and Windows NT have different REG file syntax!
386 (when (memq 'reg-generic-mode generic-extras-enable-list)
388 (define-generic-mode reg-generic-mode
390 '("key" "classes_root" "REGEDIT" "REGEDIT4")
391 '(("\\(\\[.*]\\)" 1 font-lock-constant-face)
392 ("^\\([^\n\r]*\\)\\s-*=" 1 font-lock-variable-name-face))
393 '("\\.[rR][eE][gG]\\'")
397 (setq imenu-generic-expression
398 '((nil "^\\s-*\\(.*\\)\\s-*=" 1))))))
399 "Generic mode for MS-Windows Registry files."
402 ;;; DOS/Windows BAT files
403 (when (memq 'bat-generic-mode generic-extras-enable-list)
405 (define-generic-mode bat-generic-mode
410 ;; Make this one first in the list, otherwise comments will
411 ;; be over-written by other variables
412 '("^[@ \t]*\\([rR][eE][mM][^\n\r]*\\)" 1 font-lock-comment-face t)
413 '("^[ \t]*\\(::.*\\)" 1 font-lock-comment-face t)
414 '("^[@ \t]*\\([bB][rR][eE][aA][kK]\\|[vV][eE][rR][iI][fF][yY]\\)[ \t]+\\([oO]\\([nN]\\|[fF][fF]\\)\\)"
415 (1 font-lock-builtin-face)
416 (2 font-lock-constant-face t t))
417 ;; Any text (except ON/OFF) following ECHO is a string.
418 '("^[@ \t]*\\([eE][cC][hH][oO]\\)[ \t]+\\(\\([oO]\\([nN]\\|[fF][fF]\\)\\)\\|\\([^>|\r\n]+\\)\\)"
419 (1 font-lock-builtin-face)
420 (3 font-lock-constant-face t t)
421 (5 font-lock-string-face t t))
422 ;; These keywords appear as the first word on a line. (Actually, they
423 ;; can also appear after "if ..." or "for ..." clause, but since they
424 ;; are frequently used in simple text, we punt.)
425 ;; In `generic-bat-mode-setup-function' we make the keywords
427 (generic-make-keywords-list
430 font-lock-keyword-face "^[@ \t]*")
431 ;; These keywords can be anywhere on a line
432 ;; In `generic-bat-mode-setup-function' we make the keywords
434 (generic-make-keywords-list
440 font-lock-keyword-face)
441 ;; These are built-in commands. Only frequently-used ones are listed.
442 (generic-make-keywords-list
443 '("CALL" "call" "Call"
451 "PAUSE" "pause" "Pause"
452 "PROMPT" "prompt" "Prompt"
456 "START" "start" "Start"
457 "SHIFT" "shift" "Shift")
458 font-lock-builtin-face "[ \t|\n]")
459 '("^[ \t]*\\(:\\sw+\\)" 1 font-lock-function-name-face t)
460 '("\\(%\\sw+%\\)" 1 font-lock-variable-name-face t)
461 '("\\(%[0-9]\\)" 1 font-lock-variable-name-face t)
462 '("\\(/[^/ \"\t\n]+\\)" 1 font-lock-type-face)
463 '("[\t ]+\\([+-][^\t\n\" ]+\\)" 1 font-lock-type-face)
464 '("[ \t\n|]\\<\\([gG][oO][tT][oO]\\)\\>[ \t]*\\(\\sw+\\)?"
465 (1 font-lock-keyword-face)
466 (2 font-lock-function-name-face nil t))
467 '("[ \t\n|]\\<\\([sS][eE][tT]\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*=?"
468 (1 font-lock-builtin-face)
469 (2 font-lock-variable-name-face t t))))
470 '("\\.[bB][aA][tT]\\'"
471 "\\`[cC][oO][nN][fF][iI][gG]\\."
472 "\\`[aA][uU][tT][oO][eE][xX][eE][cC]\\.")
473 '(generic-bat-mode-setup-function)
474 "Generic mode for MS-Windows BAT files."
477 (defvar bat-generic-mode-syntax-table nil
478 "Syntax table in use in bat-generic-mode buffers.")
480 (defvar bat-generic-mode-keymap (make-sparse-keymap)
481 "Keymap for bet-generic-mode.")
483 (defun bat-generic-mode-compile ()
484 "Run the current BAT file in a compilation buffer."
486 (let ((compilation-buffer-name-function
489 (concat "*" (buffer-file-name) "*")))))
491 (concat (w32-shell-name) " -c " (buffer-file-name)))))
493 (eval-when-compile (require 'comint))
494 (defun bat-generic-mode-run-as-comint ()
495 "Run the current BAT file in a comint buffer."
498 (let* ((file (buffer-file-name))
499 (buf-name (concat "*" file "*")))
502 (get-buffer-create buf-name))
511 (display-buffer buf-name))))
513 (define-key bat-generic-mode-keymap "\C-c\C-c" 'bat-generic-mode-compile)
515 ;; Make underscores count as words
516 (unless bat-generic-mode-syntax-table
517 (setq bat-generic-mode-syntax-table (make-syntax-table))
518 (modify-syntax-entry ?_ "w" bat-generic-mode-syntax-table))
520 ;; bat-generic-mode doesn't use the comment functionality of
521 ;; define-generic-mode because it has a three-letter comment-string,
522 ;; so we do it here manually instead
523 (defun generic-bat-mode-setup-function ()
524 (make-local-variable 'parse-sexp-ignore-comments)
525 (make-local-variable 'comment-start)
526 (make-local-variable 'comment-start-skip)
527 (make-local-variable 'comment-end)
528 (setq imenu-generic-expression '((nil "^:\\(\\sw+\\)" 1))
529 parse-sexp-ignore-comments t
532 comment-start-skip "[Rr][Ee][Mm] *")
533 (set-syntax-table bat-generic-mode-syntax-table)
534 ;; Make keywords case-insensitive
535 (setq font-lock-defaults '(generic-font-lock-keywords nil t))
536 (use-local-map bat-generic-mode-keymap)))
539 ;; Mailagent is a Unix mail filtering program. Anyone wanna do a
540 ;; generic mode for procmail?
541 (when (memq 'mailagent-rules-generic-mode generic-extras-enable-list)
543 (define-generic-mode mailagent-rules-generic-mode
545 '("SAVE" "DELETE" "PIPE" "ANNOTATE" "REJECT")
546 '(("^\\(\\sw+\\)\\s-*=" 1 font-lock-variable-name-face)
547 ("\\s-/\\([^/]+\\)/[i, \t\n]" 1 font-lock-constant-face))
552 (setq imenu-generic-expression
553 '((nil "\\s-/\\([^/]+\\)/[i, \t\n]" 1))))))
554 "Mode for Mailagent rules files."
557 ;; Solaris/Sys V prototype files
558 (when (memq 'prototype-generic-mode generic-extras-enable-list)
560 (define-generic-mode prototype-generic-mode
563 '(("^\\([0-9]\\)?\\s-*\\([a-z]\\)\\s-+\\([A-Za-z_]+\\)\\s-+\\([^\n\r]*\\)$"
564 (2 font-lock-constant-face)
565 (3 font-lock-keyword-face))
566 ("^\\([a-z]\\) \\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
567 (1 font-lock-constant-face)
568 (2 font-lock-keyword-face)
569 (3 font-lock-variable-name-face))
570 ("^\\(!\\s-*\\(search\\|include\\|default\\)\\)\\s-*\\([^\n\r]*\\)$"
571 (1 font-lock-keyword-face)
572 (3 font-lock-variable-name-face))
573 ("^\\(!\\s-*\\sw+\\)=\\([^\n\r]*\\)$"
574 (1 font-lock-keyword-face)
575 (2 font-lock-variable-name-face)))
578 "Mode for Sys V prototype files."
581 ;; Solaris/Sys V pkginfo files
582 (when (memq 'pkginfo-generic-mode generic-extras-enable-list)
584 (define-generic-mode pkginfo-generic-mode
587 '(("^\\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
588 (1 font-lock-keyword-face)
589 (2 font-lock-variable-name-face)))
592 "Mode for Sys V pkginfo files."
596 ;; Includes extra keywords from Armando Singer [asinger@MAIL.COLGATE.EDU]
597 (define-generic-mode javascript-generic-mode
598 '("//" ("/*" . "*/"))
621 ;; words reserved for ECMA extensions below
632 ;; Java Keywords reserved by JavaScript
659 '(("^\\s-*function\\s-+\\([A-Za-z0-9_]+\\)"
660 (1 font-lock-function-name-face))
661 ("^\\s-*var\\s-+\\([A-Za-z0-9_]+\\)"
662 (1 font-lock-variable-name-face)))
667 (setq imenu-generic-expression
668 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1)
669 ("*Variables*" "^var\\s-+\\([A-Za-z0-9_]+\\)" 1))))))
670 "Mode for JavaScript files."
674 (define-generic-mode vrml-generic-mode
704 '(("USE\\s-+\\([-A-Za-z0-9_]+\\)"
705 (1 font-lock-constant-face))
706 ("DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
707 (1 font-lock-type-face)
708 (2 font-lock-constant-face))
709 ("^\\s-*\\([-A-Za-z0-9_]+\\)\\s-*{"
710 (1 font-lock-function-name-face))
711 ("^\\s-*\\(geometry\\|appearance\\|material\\)\\s-+\\([-A-Za-z0-9_]+\\)"
712 (2 font-lock-variable-name-face)))
717 (setq imenu-generic-expression
718 '((nil "^\\([A-Za-z0-9_]+\\)\\s-*{" 1)
720 "DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
722 "Generic Mode for VRML files."
726 (define-generic-mode java-manifest-generic-mode
736 '(("^Name:\\s-+\\([^\n\r]*\\)$"
737 (1 font-lock-variable-name-face))
738 ("^\\(Manifest\\|Required\\|Signature\\)-Version:\\s-+\\([^\n\r]*\\)$"
739 (2 font-lock-constant-face)))
740 '("[mM][aA][nN][iI][fF][eE][sS][tT]\\.[mM][fF]\\'")
742 "Mode for Java Manifest files"
745 ;; Java properties files
746 (define-generic-mode java-properties-generic-mode
750 (let ((java-properties-key
751 "\\(\\([-A-Za-z0-9_\\./]\\|\\(\\\\[ =:]\\)\\)+\\)")
752 (java-properties-value
754 ;; Property and value can be separated in a number of different ways:
762 (concat "^" java-properties-key elt java-properties-value "$")
763 '(1 font-lock-constant-face)
764 '(4 font-lock-variable-name-face))))
765 ;; These are the separators
766 '(":\\s-*" "\\s-+" "\\s-*=\\s-*"))))
771 (setq imenu-generic-expression
772 '((nil "^\\([^#! \t\n\r=:]+\\)" 1))))))
773 "Mode for Java properties files."
776 ;; C shell alias definitions
777 (when (memq 'alias-generic-mode generic-extras-enable-list)
779 (define-generic-mode alias-generic-mode
782 '(("^alias\\s-+\\([-A-Za-z0-9_]+\\)\\s-+"
783 (1 font-lock-variable-name-face))
784 ("^unalias\\s-+\\([-A-Za-z0-9_]+\\)\\s-*$"
785 (1 font-lock-variable-name-face)))
790 (setq imenu-generic-expression
791 '((nil "^\\(alias\\|unalias\\)\\s-+\\([-a-zA-Z0-9_]+\\)" 2))))))
792 "Mode for C Shell alias files."
796 ;; Contributed by ACorreir@pervasive-sw.com (Alfred Correira)
797 (when (memq 'rc-generic-mode generic-extras-enable-list)
799 (define-generic-mode rc-generic-mode
854 ;; the choice of what tokens go where is somewhat arbitrary,
855 ;; as is the choice of which value tokens are included, as
856 ;; the choice of face for each token group
859 (generic-make-keywords-list
868 (generic-make-keywords-list
873 font-lock-function-name-face)
874 '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face)
875 '("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face)
876 '("^#[ \t]*\\(elif\\|if\\)\\>"
877 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil
878 (1 font-lock-constant-face)
879 (2 font-lock-variable-name-face nil t)))
880 '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
881 (1 font-lock-constant-face)
882 (2 font-lock-variable-name-face nil t))))
885 "Generic mode for MS-Windows Resource files."
888 ;; InstallShield RUL files
889 ;; Contributed by Alfred.Correira@Pervasive.Com
890 ;; Bugfixes by "Rolf Sandau" <Rolf.Sandau@marconi.com>
891 (when (memq 'rul-generic-mode generic-extras-enable-list)
895 ;;; build the regexp strings using regexp-opt
896 (defconst installshield-statement-keyword-list
915 ;; "goto" -- handled elsewhere
929 "Statement keywords used in InstallShield 3 and 5.")
931 (defconst installshield-system-functions-list
951 "ComponentAddItem" ; differs between IS3 and IS5
952 "ComponentCompareSizeRequired" ; IS5 only
954 "ComponentError" ; IS5 only
955 "ComponentFileEnum" ; IS5 only
956 "ComponentFileInfo" ; IS5 only
957 "ComponentFilterLanguage" ; IS5 only
958 "ComponentFilterOS" ; IS5 only
959 "ComponentGetData" ; IS5 only
960 "ComponentGetItemInfo" ; IS3 only
961 "ComponentGetItemSize" ; differs between IS3 and IS5
962 "ComponentIsItemSelected" ; differs between IS3 and IS5
964 "ComponentMoveData" ; IS5 only
965 "ComponentSelectItem" ; differs between IS3 and IS5
966 "ComponentSetData" ; IS5 only
967 "ComponentSetItemInfo" ; IS3 only
968 "ComponentSetTarget" ; IS5 only
969 "ComponentSetupTypeEnum" ; IS5 only
970 "ComponentSetupTypeGetData" ; IS5 only
971 "ComponentSetupTypeSet" ; IS5 only
973 "ComponentValidate" ; IS5 only
974 "CompressAdd" ; IS3 only
975 "CompressDel" ; IS3 only
976 "CompressEnum" ; IS3 only
977 "CompressGet" ; IS3 only
978 "CompressInfo" ; IS3 only
982 "CreateProgramFolder"
983 "DeinstallSetReference" ; IS5 only
1009 "FileSetBeginDefine" ; IS3 only
1010 "FileSetEndDefine" ; IS3 only
1011 "FileSetPerformEz" ; IS3 only
1012 "FileSetPerform" ; IS3 only
1013 "FileSetReset" ; IS3 only
1014 "FileSetRoot" ; IS3 only
1028 "GetValidDrivesList"
1043 "ListGetFirstString"
1047 "ListSetCurrentItem"
1053 "LongPathToShortPath"
1068 "PlayMMedia" ; IS5 only
1075 "RegDBGetKeyValueEx"
1076 "RegDBSetKeyValueEx"
1077 "RegDBSetDefaultRoot"
1086 "SdComponentAdvCheckSpace"
1087 "SdComponentAdvInit"
1088 "SdComponentAdvUpdateSpace"
1090 "SdComponentDialog2"
1091 "SdComponentDialogAdv"
1092 "SdComponentDialogEx"
1093 "SdComponentDlgCheckSpace"
1096 "SdConfirmRegistration"
1108 "SdGetUserCompanyInfo"
1117 "SdOptionsButtonsInit"
1118 "SdPlugInProductName"
1121 "SdRegExEnableButton"
1126 "SdSetSequentialItems"
1128 "SdSetupTypeEx" ; IS5 only
1139 "SdUpdateComponentSelection"
1145 "SetDisplayEffect" ; IS5 only
1147 "SetForegroundWindow"
1160 "StrRemoveLastSlash"
1174 "System functions defined in InstallShield 3 and 5.")
1176 (defconst installshield-system-variables-list
1180 "CORECOMPONENTHANDLING"
1206 "System variables used in InstallShield 3 and 5.")
1208 (defconst installshield-types-list
1227 "Type keywords used in InstallShield 3 and 5.")
1229 ;;; some might want to skip highlighting these to improve performance
1230 (defconst installshield-funarg-constants-list
1260 "COMP_UPDATE_VERSION"
1279 "DLG_INFO_CHECKSELECTION"
1281 "DLG_INFO_USEDECIMAL"
1282 "DLG_MSG_INFORMATION"
1303 "FILE_ATTR_ARCHIVED"
1304 "FILE_ATTR_DIRECTORY"
1307 "FILE_ATTR_READONLY"
1313 "FILE_MODE_BINARYREADONLY"
1335 "HKEY_LOCAL_MACHINE"
1380 "REGDB_APPPATH_DEFAULT"
1383 "REGDB_ERR_CONNECTIONEXISTS"
1384 "REGDB_ERR_CORRUPTEDREGSITRY"
1385 "REGDB_ERR_INITIALIZATION"
1386 "REGDB_ERR_INVALIDHANDLE"
1387 "REGDB_ERR_INVALIDNAME"
1389 "REGDB_STRING_EXPAND"
1390 "REGDB_STRING_MULTI"
1392 "REGDB_UNINSTALL_NAME"
1436 "Function argument constants used in InstallShield 3 and 5."))
1438 (defvar rul-generic-mode-syntax-table nil
1439 "Syntax table to use in rul-generic-mode buffers.")
1441 (setq rul-generic-mode-syntax-table
1442 (make-syntax-table c++-mode-syntax-table))
1444 (modify-syntax-entry ?\r "> b" rul-generic-mode-syntax-table)
1445 (modify-syntax-entry ?\n "> b" rul-generic-mode-syntax-table)
1447 (modify-syntax-entry ?/ ". 124b" rul-generic-mode-syntax-table)
1448 (modify-syntax-entry ?* ". 23" rul-generic-mode-syntax-table)
1450 ;; here manually instead
1451 (defun generic-rul-mode-setup-function ()
1452 (make-local-variable 'parse-sexp-ignore-comments)
1453 (make-local-variable 'comment-start)
1454 (make-local-variable 'comment-start-skip)
1455 (make-local-variable 'comment-end)
1456 (setq imenu-generic-expression
1457 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1))
1458 parse-sexp-ignore-comments t
1462 ;;; comment-start "//"
1463 ;;; comment-start-skip ""
1465 ;; (set-syntax-table rul-generic-mode-syntax-table)
1466 (setq font-lock-syntax-table rul-generic-mode-syntax-table))
1468 ;; moved mode-definition behind defun-definition to be warning-free - 15.11.02/RSan
1469 (define-generic-mode rul-generic-mode
1470 ;; Using "/*" and "*/" doesn't seem to be working right
1471 '("//" ("/*" . "*/" ))
1472 (eval-when-compile installshield-statement-keyword-list)
1475 ;; preprocessor constructs
1476 '("#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)"
1477 1 font-lock-string-face)
1478 '("#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
1479 (1 font-lock-reference-face)
1480 (2 font-lock-variable-name-face nil t))
1481 ;; indirect string constants
1482 '("\\(@[A-Za-z][A-Za-z0-9_]+\\)" 1 font-lock-builtin-face)
1484 '("[ \t]*\\(\\sw+:\\)" 1 font-lock-reference-face)
1485 '("\\<\\(goto\\)\\>[ \t]*\\(\\sw+\\)?"
1486 (1 font-lock-keyword-face)
1487 (2 font-lock-reference-face nil t))
1489 (generic-make-keywords-list
1490 installshield-system-variables-list
1491 font-lock-variable-name-face "[^_]" "[^_]")
1493 (generic-make-keywords-list
1494 installshield-system-functions-list
1495 font-lock-function-name-face "[^_]" "[^_]")
1497 (generic-make-keywords-list
1498 installshield-types-list
1499 font-lock-type-face "[^_]" "[^_]")
1500 ;; function argument constants
1501 (generic-make-keywords-list
1502 installshield-funarg-constants-list
1503 font-lock-variable-name-face "[^_]" "[^_]"))) ; is this face the best choice?
1504 '("\\.[rR][uU][lL]\\'")
1505 '(generic-rul-mode-setup-function)
1506 "Generic mode for InstallShield RUL files."
1509 (define-skeleton rul-if
1510 "Insert an if statement."
1512 "if(" str ") then" \n
1514 ( "other condition, %s: "
1515 > "elseif(" str ") then" \n
1522 (define-skeleton rul-function
1523 "Insert a function statement."
1525 "function " str " ()" \n
1526 ( "local variables, %s: "
1533 ;; Additions by ACorreir@pervasive-sw.com (Alfred Correira)
1534 (define-generic-mode mailrc-generic-mode
1545 '(("^\\s-*\\(alias\\|group\\)\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1546 (2 font-lock-constant-face)
1547 (3 font-lock-variable-name-face))
1548 ("^\\s-*\\(unset\\|set\\|ignore\\)\\s-+\\([-A-Za-z0-9_]+\\)=?\\([^\n\r#]*\\)\\(#.*\\)?$"
1549 (2 font-lock-constant-face)
1550 (3 font-lock-variable-name-face))
1551 ("^\\s-*\\(source\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1552 (2 font-lock-variable-name-face)))
1555 "Mode for mailrc files."
1559 (when (memq 'inetd-conf-generic-mode generic-extras-enable-list)
1561 (define-generic-mode inetd-conf-generic-mode
1570 '(("^\\([-A-Za-z0-9_]+\\)" 1 font-lock-type-face))
1571 '("/etc/inetd.conf\\'")
1575 (setq imenu-generic-expression
1576 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))
1580 (when (memq 'etc-services-generic-mode generic-extras-enable-list)
1582 (define-generic-mode etc-services-generic-mode
1587 '(("^\\([-A-Za-z0-9_]+\\)\\s-+\\([0-9]+\\)/"
1588 (1 font-lock-type-face)
1589 (2 font-lock-variable-name-face)))
1590 '("/etc/services\\'")
1594 (setq imenu-generic-expression
1595 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))
1598 ;; Password and Group files
1599 (when (memq 'etc-passwd-generic-mode generic-extras-enable-list)
1601 (define-generic-mode etc-passwd-generic-mode
1602 nil ;; No comment characters
1603 '("root") ;; Only one keyword
1609 ;; User name -- Never blank!
1612 ;; Password, UID and GID
1615 (make-list 3 "\\([^:]+\\)")
1618 ;; GECOS/Name -- might be blank
1621 ;; Home directory and shell
1626 '(1 font-lock-type-face)
1627 '(5 font-lock-variable-name-face)
1628 '(6 font-lock-constant-face)
1629 '(7 font-lock-warning-face))
1630 '("^\\([^:]+\\):\\([^:]*\\):\\([0-9]+\\):\\(.*\\)$"
1631 (1 font-lock-type-face)
1632 (4 font-lock-variable-name-face))))
1633 '("/etc/passwd\\'" "/etc/group\\'")
1637 (setq imenu-generic-expression
1638 '((nil "^\\([-A-Za-z0-9_]+\\):" 1))))))
1642 (when (memq 'etc-fstab-generic-mode generic-extras-enable-list)
1644 (define-generic-mode etc-fstab-generic-mode
1681 '(("^\\([/-A-Za-z0-9_]+\\)\\s-+\\([/-A-Za-z0-9_]+\\)"
1682 (1 font-lock-type-face t)
1683 (2 font-lock-variable-name-face t)))
1684 '("/etc/[v]*fstab\\'")
1688 (setq imenu-generic-expression
1689 '((nil "^\\([/-A-Za-z0-9_]+\\)\\s-+" 1))))))
1692 ;; From Jacques Duthen <jacques.duthen@sncf.fr>
1695 (defconst show-tabs-generic-mode-font-lock-defaults-1
1696 '(;; trailing spaces must come before...
1697 ("[ \t]+$" . 'show-tabs-space-face)
1699 ("[^\n\t]\\(\t+\\)" (1 'show-tabs-tab-face))))
1701 (defconst show-tabs-generic-mode-font-lock-defaults-2
1702 '(;; trailing spaces must come before...
1703 ("[ \t]+$" . 'show-tabs-space-face)
1705 ("\t+" . 'show-tabs-tab-face))))
1707 (defface show-tabs-tab-face
1708 '((((class grayscale) (background light)) (:background "DimGray" :weight bold))
1709 (((class grayscale) (background dark)) (:background "LightGray" :weight bold))
1710 (((class color) (min-colors 88)) (:background "red1"))
1711 (((class color)) (:background "red"))
1713 "Font Lock mode face used to highlight TABs."
1716 (defface show-tabs-space-face
1717 '((((class grayscale) (background light)) (:background "DimGray" :weight bold))
1718 (((class grayscale) (background dark)) (:background "LightGray" :weight bold))
1719 (((class color) (min-colors 88)) (:background "yellow1"))
1720 (((class color)) (:background "yellow"))
1722 "Font Lock mode face used to highlight spaces."
1725 (define-generic-mode show-tabs-generic-mode
1726 nil ;; no comment char
1728 (eval-when-compile show-tabs-generic-mode-font-lock-defaults-1)
1729 nil ;; no auto-mode-alist
1730 ;; '(show-tabs-generic-mode-hook-fun)
1732 "Generic mode to show tabs and trailing spaces"
1735 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1737 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1739 (define-generic-mode named-boot-generic-mode
1740 ;; List of comment characters
1743 '("cache" "primary" "secondary" "forwarders" "limit" "options"
1744 "directory" "check-names")
1745 ;; List of additional font-lock-expressions
1746 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face)
1747 ("^directory\\s-+\\(.*\\)" 1 font-lock-variable-name-face)
1748 ("^\\(primary\\|cache\\)\\s-+\\([.A-Za-z]+\\)\\s-+\\(.*\\)"
1749 (2 font-lock-variable-name-face)
1750 (3 font-lock-constant-face)))
1751 ;; List of additional automode-alist expressions
1752 '("/etc/named.boot\\'")
1753 ;; List of set up functions to call
1757 (define-generic-mode named-database-generic-mode
1758 ;; List of comment characters
1761 '("IN" "NS" "CNAME" "SOA" "PTR" "MX" "A")
1762 ;; List of additional font-lock-expressions
1763 '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 font-lock-constant-face)
1764 ("^\\([.A-Za-z0-9]+\\)" 1 font-lock-variable-name-face))
1765 ;; List of additional auto-mode-alist expressions
1767 ;; List of set up functions to call
1771 (defvar named-database-time-string "%Y%m%d%H"
1772 "Timestring for named serial numbers.")
1774 (defun named-database-print-serial ()
1775 "Print a serial number based on the current date."
1777 (insert (format-time-string named-database-time-string (current-time))))
1779 (define-generic-mode resolve-conf-generic-mode
1780 ;; List of comment characters
1783 '("nameserver" "domain" "search" "sortlist" "options")
1784 ;; List of additional font-lock-expressions
1786 ;; List of additional auto-mode-alist expressions
1787 '("/etc/resolv[e]?.conf\\'")
1788 ;; List of set up functions to call
1792 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1793 ;; Modes for spice and common electrical engineering circuit netlist formats
1794 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1796 (define-generic-mode spice-generic-mode
1813 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face)
1814 (" \\(\\$ .*\\)$" 1 font-lock-comment-face)
1815 ("^\\(\\$ .*\\)$" 1 font-lock-comment-face)
1816 ("\\([*].*\\)" 1 font-lock-comment-face)
1817 ("^\\([+]\\)" 1 font-lock-string-face)
1818 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face)
1819 ("\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face)
1820 ("\\('[^']+'\\)" 1 font-lock-string-face)
1821 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face))
1823 "\\.[sS][pP][iI]\\'"
1824 "\\.[sS][pP][iI][cC][eE]\\'"
1825 "\\.[iI][nN][cC]\\'")
1827 'generic-bracket-support
1828 ;; Make keywords case-insensitive
1831 (setq font-lock-defaults '(generic-font-lock-keywords nil t)))))
1832 "Generic mode for SPICE circuit netlist files."
1835 (define-generic-mode ibis-generic-mode
1838 '(("[[]\\([^]]*\\)[]]" 1 font-lock-keyword-face)
1839 ("\\(\\(_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face))
1840 '("\\.[iI][bB][sS]\\'")
1841 '(generic-bracket-support)
1842 "Generic mode for IBIS circuit netlist files."
1845 (define-generic-mode astap-generic-mode
1860 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face)
1861 (";\\s-*\\([*].*\\)" 1 font-lock-comment-face)
1862 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face)
1863 ("\\('[^']+'\\)" 1 font-lock-string-face)
1864 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face)
1865 ("[(,]\\s-*\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face))
1867 "\\.[aA][sS][xX]\\'"
1868 "\\.[aA][sS][tT][aA][pP]\\'"
1869 "\\.[pP][sS][pP]\\'"
1870 "\\.[dD][eE][cC][kK]\\'"
1871 "\\.[gG][oO][dD][aA][tT][aA]")
1873 'generic-bracket-support
1874 ;; Make keywords case-insensitive
1877 (setq font-lock-defaults '(generic-font-lock-keywords nil t)))))
1878 "Generic mode for ASTAP circuit netlist files."
1881 (define-generic-mode etc-modules-conf-generic-mode
1882 ;; List of comment characters
1900 "generic_stringfile"
1916 ;; List of additional font-lock-expressions
1918 ;; List of additional automode-alist expressions
1919 '("/etc/modules.conf" "/etc/conf.modules")
1920 ;; List of set up functions to call
1924 (provide 'generic-x)
1926 ;;; arch-tag: cde692a5-9ff6-4506-9999-c67999c2bdb5
1927 ;;; generic-x.el ends here