Make tramp-archive fit for older Emacsen
[emacs.git] / lisp / generic-x.el
blob3e3ddc5ceb9c2c84192d09023c62e342b7e2756f
1 ;;; generic-x.el --- A collection of generic modes
3 ;; Copyright (C) 1997-1998, 2001-2018 Free Software Foundation, Inc.
5 ;; Author: Peter Breton <pbreton@cs.umb.edu>
6 ;; Created: Tue Oct 08 1996
7 ;; Keywords: generic, comment, font-lock
8 ;; Package: emacs
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
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. If not, see <https://www.gnu.org/licenses/>.
25 ;;; Commentary:
27 ;; This file contains a collection of generic modes.
29 ;; INSTALLATION:
31 ;; Add this line to your init file:
33 ;; (require 'generic-x)
35 ;; You can decide which modes to load by setting the variable
36 ;; `generic-extras-enable-list'. Its default value is platform-
37 ;; specific. The recommended way to set this variable is through
38 ;; customize:
40 ;; M-x customize-option RET generic-extras-enable-list RET
42 ;; This lets you select generic modes from the list of available
43 ;; modes. If you manually set `generic-extras-enable-list' in your
44 ;; .emacs, do it BEFORE loading generic-x with (require 'generic-x).
46 ;; You can also send in new modes; if the file types are reasonably
47 ;; common, we would like to install them.
49 ;; DEFAULT GENERIC MODE:
51 ;; This file provides a hook which automatically puts a file into
52 ;; `default-generic-mode' if the first few lines of a file in
53 ;; fundamental mode start with a hash comment character. To disable
54 ;; this functionality, set the variable `generic-use-find-file-hook'
55 ;; to nil BEFORE loading generic-x. See the variables
56 ;; `generic-lines-to-scan' and `generic-find-file-regexp' for
57 ;; customization options.
59 ;; PROBLEMS WHEN USED WITH FOLDING MODE:
61 ;; [The following relates to the obsolete selective-display technique.
62 ;; Folding mode should use invisible text properties instead. -- Dave
63 ;; Love]
65 ;; From Anders Lindgren
67 ;; Problem summary: Wayne Adams has found a problem when using folding
68 ;; mode in conjunction with font-lock for a mode defined in
69 ;; `generic-x.el'.
71 ;; The problem, as Wayne described it, was that error messages of the
72 ;; following form appeared when both font-lock and folding are used:
74 ;; > - various msgs including "Fontifying region...(error Stack
75 ;; > overflow in regexp matcher)" appear
77 ;; I have just tracked down the cause of the problem. The regexp's in
78 ;; `generic-x.el' do not take into account the way that folding hides
79 ;; sections of the buffer. The technique is known as
80 ;; `selective-display' and has been available for a very long time (I
81 ;; started using it back in the good old Emacs 18 days). Basically, a
82 ;; section is hidden by creating one very long line were the newline
83 ;; character (C-j) is replaced by a linefeed (C-m) character.
85 ;; Many other hiding packages, besides folding, use the same technique,
86 ;; the problem should occur when using them as well.
88 ;; The erroneous lines in `generic-x.el' look like the following (this
89 ;; example is from the `ini' section):
91 ;; '(("^\\(\\[.*\\]\\)" 1 'font-lock-constant-face)
92 ;; ("^\\(.*\\)=" 1 'font-lock-variable-name-face)
94 ;; The intention of these lines is to highlight lines of the following
95 ;; form:
97 ;; [foo]
98 ;; bar = xxx
100 ;; However, since the `.' regexp symbol matches the linefeed character
101 ;; the entire folded section is searched, resulting in a regexp stack
102 ;; overflow.
104 ;; Solution suggestion: Instead of using ".", use the sequence
105 ;; "[^\n\r]". This will make the rules behave just as before, but
106 ;; they will work together with selective-display.
108 ;;; Code:
110 (eval-when-compile (require 'font-lock))
112 (defgroup generic-x nil
113 "A collection of generic modes."
114 :prefix "generic-"
115 :group 'data
116 :version "20.3")
118 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
119 ;; Default-Generic mode
120 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
122 (defcustom generic-use-find-file-hook t
123 "If non-nil, add a hook to enter `default-generic-mode' automatically.
124 This is done if the first few lines of a file in fundamental mode
125 start with a hash comment character."
126 :group 'generic-x
127 :type 'boolean)
129 (defcustom generic-lines-to-scan 3
130 "Number of lines that `generic-mode-find-file-hook' looks at.
131 Relevant when deciding whether to enter Default-Generic mode automatically.
132 This variable should be set to a small positive number."
133 :group 'generic-x
134 :type 'integer)
136 (defcustom generic-find-file-regexp "^#"
137 "Regular expression used by `generic-mode-find-file-hook'.
138 Files in fundamental mode whose first few lines contain a match
139 for this regexp, should be put into Default-Generic mode instead.
140 The number of lines tested for the matches is specified by the
141 value of the variable `generic-lines-to-scan', which see."
142 :group 'generic-x
143 :type 'regexp)
145 (defcustom generic-ignore-files-regexp "[Tt][Aa][Gg][Ss]\\'"
146 "Regular expression used by `generic-mode-find-file-hook'.
147 Files whose names match this regular expression should not be put
148 into Default-Generic mode, even if they have lines which match
149 the regexp in `generic-find-file-regexp'. If the value is nil,
150 `generic-mode-find-file-hook' does not check the file names."
151 :group 'generic-x
152 :type '(choice (const :tag "Don't check file names" nil) regexp))
154 ;; This generic mode is always defined
155 (define-generic-mode default-generic-mode (list ?#) nil nil nil nil)
157 ;; A more general solution would allow us to enter generic-mode for
158 ;; *any* comment character, but would require us to synthesize a new
159 ;; generic-mode on the fly. I think this gives us most of what we
160 ;; want.
161 (defun generic-mode-find-file-hook ()
162 "Hook function to enter Default-Generic mode automatically.
164 Done if the first few lines of a file in Fundamental mode start
165 with a match for the regexp in `generic-find-file-regexp', unless
166 the file's name matches the regexp which is the value of the
167 variable `generic-ignore-files-regexp'.
169 This hook will be installed if the variable
170 `generic-use-find-file-hook' is non-nil. The variable
171 `generic-lines-to-scan' determines the number of lines to look at."
172 (when (and (eq major-mode 'fundamental-mode)
173 (or (null generic-ignore-files-regexp)
174 (not (string-match-p
175 generic-ignore-files-regexp
176 (file-name-sans-versions buffer-file-name)))))
177 (save-excursion
178 (goto-char (point-min))
179 (when (re-search-forward generic-find-file-regexp
180 (save-excursion
181 (forward-line generic-lines-to-scan)
182 (point)) t)
183 (goto-char (point-min))
184 (default-generic-mode)))))
186 (and generic-use-find-file-hook
187 (add-hook 'find-file-hook 'generic-mode-find-file-hook))
189 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
190 ;; Other Generic modes
191 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
193 ;; If you add a generic mode to this file, put it in one of these four
194 ;; lists as well.
196 (defconst generic-default-modes
197 '(apache-conf-generic-mode
198 apache-log-generic-mode
199 hosts-generic-mode
200 java-manifest-generic-mode
201 java-properties-generic-mode
202 javascript-generic-mode
203 show-tabs-generic-mode
204 vrml-generic-mode)
205 "List of generic modes that are defined by default.")
207 (defconst generic-mswindows-modes
208 '(bat-generic-mode
209 inf-generic-mode
210 ini-generic-mode
211 rc-generic-mode
212 reg-generic-mode
213 rul-generic-mode)
214 "List of generic modes that are defined by default on MS-Windows.")
216 (defconst generic-unix-modes
217 '(alias-generic-mode
218 ansible-inventory-generic-mode
219 etc-fstab-generic-mode
220 etc-modules-conf-generic-mode
221 etc-passwd-generic-mode
222 etc-services-generic-mode
223 etc-sudoers-generic-mode
224 fvwm-generic-mode
225 inetd-conf-generic-mode
226 mailagent-rules-generic-mode
227 mailrc-generic-mode
228 named-boot-generic-mode
229 named-database-generic-mode
230 prototype-generic-mode
231 resolve-conf-generic-mode
232 samba-generic-mode
233 x-resource-generic-mode
234 xmodmap-generic-mode)
235 "List of generic modes that are defined by default on Unix.")
237 (defconst generic-other-modes
238 '(astap-generic-mode
239 ibis-generic-mode
240 pkginfo-generic-mode
241 spice-generic-mode)
242 "List of generic modes that are not defined by default.")
244 (defcustom generic-define-mswindows-modes
245 (memq system-type '(windows-nt ms-dos))
246 "Non-nil means the modes in `generic-mswindows-modes' will be defined.
247 This is a list of MS-Windows specific generic modes. This variable
248 only affects the default value of `generic-extras-enable-list'."
249 :group 'generic-x
250 :type 'boolean
251 :version "22.1")
252 (make-obsolete-variable 'generic-define-mswindows-modes 'generic-extras-enable-list "22.1")
254 (defcustom generic-define-unix-modes
255 (not (memq system-type '(windows-nt ms-dos)))
256 "Non-nil means the modes in `generic-unix-modes' will be defined.
257 This is a list of Unix specific generic modes. This variable only
258 affects the default value of `generic-extras-enable-list'."
259 :group 'generic-x
260 :type 'boolean
261 :version "22.1")
262 (make-obsolete-variable 'generic-define-unix-modes 'generic-extras-enable-list "22.1")
264 (defcustom generic-extras-enable-list
265 (append generic-default-modes
266 (if generic-define-mswindows-modes generic-mswindows-modes)
267 (if generic-define-unix-modes generic-unix-modes)
268 nil)
269 "List of generic modes to define.
270 Each entry in the list should be a symbol. If you set this variable
271 directly, without using customize, you must reload generic-x to put
272 your changes into effect."
273 :group 'generic-x
274 :type (let (list)
275 (dolist (mode
276 (sort (append generic-default-modes
277 generic-mswindows-modes
278 generic-unix-modes
279 generic-other-modes
280 nil)
281 (lambda (a b)
282 (string< (symbol-name b)
283 (symbol-name a))))
284 (cons 'set list))
285 (push `(const ,mode) list)))
286 :set (lambda (s v)
287 (set-default s v)
288 (unless load-in-progress
289 (load "generic-x")))
290 :version "22.1")
292 ;;; Apache
293 (when (memq 'apache-conf-generic-mode generic-extras-enable-list)
295 (define-generic-mode apache-conf-generic-mode
296 '(?#)
298 '(("^\\s-*\\(<.*>\\)" 1 font-lock-constant-face)
299 ("^\\s-*\\(\\sw+\\)\\s-" 1 font-lock-variable-name-face))
300 '("srm\\.conf\\'" "httpd\\.conf\\'" "access\\.conf\\'")
301 (list
302 (function
303 (lambda ()
304 (setq imenu-generic-expression
305 '((nil "^\\([-A-Za-z0-9_]+\\)" 1)
306 ("*Directories*" "^\\s-*<Directory\\s-*\\([^>]+\\)>" 1)
307 ("*Locations*" "^\\s-*<Location\\s-*\\([^>]+\\)>" 1))))))
308 "Generic mode for Apache or HTTPD configuration files."))
310 (when (memq 'apache-log-generic-mode generic-extras-enable-list)
312 (define-generic-mode apache-log-generic-mode
315 ;; Hostname ? user date request return-code number-of-bytes
316 '(("^\\([-a-zA-z0-9.]+\\) - [-A-Za-z]+ \\(\\[.*\\]\\)"
317 (1 font-lock-constant-face)
318 (2 font-lock-variable-name-face)))
319 '("access_log\\'")
321 "Generic mode for Apache log files."))
323 ;;; Samba
324 (when (memq 'samba-generic-mode generic-extras-enable-list)
326 (define-generic-mode samba-generic-mode
327 '(?\; ?#)
329 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face)
330 ("^\\s-*\\(.+\\)=\\([^\r\n]*\\)"
331 (1 font-lock-variable-name-face)
332 (2 font-lock-type-face)))
333 '("smb\\.conf\\'")
334 '(generic-bracket-support)
335 "Generic mode for Samba configuration files."))
337 ;;; Fvwm
338 ;; This is pretty basic. Also, modes for other window managers could
339 ;; be defined as well.
340 (when (memq 'fvwm-generic-mode generic-extras-enable-list)
342 (define-generic-mode fvwm-generic-mode
343 '(?#)
344 '("AddToMenu"
345 "AddToFunc"
346 "ButtonStyle"
347 "EndFunction"
348 "EndPopup"
349 "Function"
350 "IconPath"
351 "Key"
352 "ModulePath"
353 "Mouse"
354 "PixmapPath"
355 "Popup"
356 "Style")
358 '("\\.fvwmrc\\'" "\\.fvwm2rc\\'")
360 "Generic mode for FVWM configuration files."))
362 ;;; X Resource
363 ;; I'm pretty sure I've seen an actual mode to do this, but I don't
364 ;; think it's standard with Emacs
365 (when (memq 'x-resource-generic-mode generic-extras-enable-list)
367 (define-generic-mode x-resource-generic-mode
368 '(?!)
370 '(("^\\([^:\n]+:\\)" 1 font-lock-variable-name-face))
371 '("\\.Xdefaults\\'" "\\.Xresources\\'" "\\.Xenvironment\\'" "\\.ad\\'")
373 "Generic mode for X Resource configuration files."))
375 (if (memq 'xmodmap-generic-mode generic-extras-enable-list)
376 (define-generic-mode xmodmap-generic-mode
377 '(?!)
378 '("add" "clear" "keycode" "keysym" "remove" "pointer")
380 '("[xX]modmap\\(rc\\)?\\'")
382 "Simple mode for xmodmap files."))
384 ;;; Hosts
385 (when (memq 'hosts-generic-mode generic-extras-enable-list)
387 (define-generic-mode hosts-generic-mode
388 '(?#)
389 '("localhost")
390 '(("\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)" 1 font-lock-constant-face))
391 '("[hH][oO][sS][tT][sS]\\'")
393 "Generic mode for HOSTS files."))
395 ;;; Windows INF files
397 ;; If i-g-m-f-f-h is defined, then so is i-g-m.
398 (declare-function ini-generic-mode "generic-x")
400 (when (memq 'inf-generic-mode generic-extras-enable-list)
402 (define-generic-mode inf-generic-mode
403 '(?\;)
405 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face))
406 '("\\.[iI][nN][fF]\\'")
407 '(generic-bracket-support)
408 "Generic mode for MS-Windows INF files."))
410 ;;; Windows INI files
411 ;; Should define escape character as well!
412 (when (memq 'ini-generic-mode generic-extras-enable-list)
414 (define-generic-mode ini-generic-mode
415 '(?\;)
417 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face)
418 ("^\\([^=\n\r]*\\)=\\([^\n\r]*\\)$"
419 (1 font-lock-function-name-face)
420 (2 font-lock-variable-name-face)))
421 '("\\.[iI][nN][iI]\\'")
422 (list
423 (function
424 (lambda ()
425 (setq imenu-generic-expression
426 '((nil "^\\[\\(.*\\)\\]" 1)
427 ("*Variables*" "^\\s-*\\([^=]+\\)\\s-*=" 1))))))
428 "Generic mode for MS-Windows INI files.
429 You can use `ini-generic-mode-find-file-hook' to enter this mode
430 automatically for INI files whose names do not end in \".ini\".")
432 (defun ini-generic-mode-find-file-hook ()
433 "Hook function to enter Ini-Generic mode automatically for INI files.
434 Done if the first few lines of a file in Fundamental mode look
435 like an INI file. You can add this hook to `find-file-hook'."
436 (and (eq major-mode 'fundamental-mode)
437 (save-excursion
438 (goto-char (point-min))
439 (and (looking-at "^\\s-*\\[.*\\]")
440 (ini-generic-mode)))))
441 (defalias 'generic-mode-ini-file-find-file-hook 'ini-generic-mode-find-file-hook))
443 ;;; Windows REG files
444 ;;; Unfortunately, Windows 95 and Windows NT have different REG file syntax!
445 (when (memq 'reg-generic-mode generic-extras-enable-list)
447 (define-generic-mode reg-generic-mode
448 '(?\;)
449 '("key" "classes_root" "REGEDIT" "REGEDIT4")
450 '(("\\(\\[.*\\]\\)" 1 font-lock-constant-face)
451 ("^\\([^\n\r]*\\)\\s-*=" 1 font-lock-variable-name-face))
452 '("\\.[rR][eE][gG]\\'")
453 (list
454 (function
455 (lambda ()
456 (setq imenu-generic-expression
457 '((nil "^\\s-*\\(.*\\)\\s-*=" 1))))))
458 "Generic mode for MS-Windows Registry files."))
460 (declare-function w32-shell-name "w32-fns" ())
462 ;;; DOS/Windows BAT files
463 (when (memq 'bat-generic-mode generic-extras-enable-list)
464 (define-obsolete-function-alias 'bat-generic-mode 'bat-mode "24.4"))
466 ;;; Mailagent
467 ;; Mailagent is a Unix mail filtering program. Anyone wanna do a
468 ;; generic mode for procmail?
469 (when (memq 'mailagent-rules-generic-mode generic-extras-enable-list)
471 (define-generic-mode mailagent-rules-generic-mode
472 '(?#)
473 '("SAVE" "DELETE" "PIPE" "ANNOTATE" "REJECT")
474 '(("^\\(\\sw+\\)\\s-*=" 1 font-lock-variable-name-face)
475 ("\\s-/\\([^/]+\\)/[i, \t\n]" 1 font-lock-constant-face))
476 '("\\.rules\\'")
477 (list
478 (function
479 (lambda ()
480 (setq imenu-generic-expression
481 '((nil "\\s-/\\([^/]+\\)/[i, \t\n]" 1))))))
482 "Generic mode for Mailagent rules files."))
484 ;; Solaris/Sys V prototype files
485 (when (memq 'prototype-generic-mode generic-extras-enable-list)
487 (define-generic-mode prototype-generic-mode
488 '(?#)
490 '(("^\\([0-9]\\)?\\s-*\\([a-z]\\)\\s-+\\([A-Za-z_]+\\)\\s-+\\([^\n\r]*\\)$"
491 (2 font-lock-constant-face)
492 (3 font-lock-keyword-face))
493 ("^\\([a-z]\\) \\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
494 (1 font-lock-constant-face)
495 (2 font-lock-keyword-face)
496 (3 font-lock-variable-name-face))
497 ("^\\(!\\s-*\\(search\\|include\\|default\\)\\)\\s-*\\([^\n\r]*\\)$"
498 (1 font-lock-keyword-face)
499 (3 font-lock-variable-name-face))
500 ("^\\(!\\s-*\\sw+\\)=\\([^\n\r]*\\)$"
501 (1 font-lock-keyword-face)
502 (2 font-lock-variable-name-face)))
503 '("prototype\\'")
505 "Generic mode for Sys V prototype files."))
507 ;; Solaris/Sys V pkginfo files
508 (when (memq 'pkginfo-generic-mode generic-extras-enable-list)
510 (define-generic-mode pkginfo-generic-mode
511 '(?#)
513 '(("^\\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
514 (1 font-lock-keyword-face)
515 (2 font-lock-variable-name-face)))
516 '("pkginfo\\'")
518 "Generic mode for Sys V pkginfo files."))
520 ;; Javascript mode
521 ;; Obsolete; defer to js-mode from js.el.
522 (when (memq 'javascript-generic-mode generic-extras-enable-list)
523 (define-obsolete-function-alias 'javascript-generic-mode 'js-mode "24.3")
524 (define-obsolete-variable-alias 'javascript-generic-mode-hook 'js-mode-hook "24.3"))
526 ;; VRML files
527 (when (memq 'vrml-generic-mode generic-extras-enable-list)
529 (define-generic-mode vrml-generic-mode
530 '(?#)
531 '("DEF"
532 "NULL"
533 "USE"
534 "Viewpoint"
535 "ambientIntensity"
536 "appearance"
537 "children"
538 "color"
539 "coord"
540 "coordIndex"
541 "creaseAngle"
542 "diffuseColor"
543 "emissiveColor"
544 "fieldOfView"
545 "geometry"
546 "info"
547 "material"
548 "normal"
549 "orientation"
550 "position"
551 "shininess"
552 "specularColor"
553 "texCoord"
554 "texture"
555 "textureTransform"
556 "title"
557 "transparency"
558 "type")
559 '(("USE\\s-+\\([-A-Za-z0-9_]+\\)"
560 (1 font-lock-constant-face))
561 ("DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
562 (1 font-lock-type-face)
563 (2 font-lock-constant-face))
564 ("^\\s-*\\([-A-Za-z0-9_]+\\)\\s-*{"
565 (1 font-lock-function-name-face))
566 ("^\\s-*\\(geometry\\|appearance\\|material\\)\\s-+\\([-A-Za-z0-9_]+\\)"
567 (2 font-lock-variable-name-face)))
568 '("\\.wrl\\'")
569 (list
570 (function
571 (lambda ()
572 (setq imenu-generic-expression
573 '((nil "^\\([A-Za-z0-9_]+\\)\\s-*{" 1)
574 ("*Definitions*"
575 "DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
576 1))))))
577 "Generic Mode for VRML files."))
579 ;; Java Manifests
580 (when (memq 'java-manifest-generic-mode generic-extras-enable-list)
582 (define-generic-mode java-manifest-generic-mode
583 '(?#)
584 '("Name"
585 "Digest-Algorithms"
586 "Manifest-Version"
587 "Required-Version"
588 "Signature-Version"
589 "Magic"
590 "Java-Bean"
591 "Depends-On")
592 '(("^Name:\\s-+\\([^\n\r]*\\)$"
593 (1 font-lock-variable-name-face))
594 ("^\\(Manifest\\|Required\\|Signature\\)-Version:\\s-+\\([^\n\r]*\\)$"
595 (2 font-lock-constant-face)))
596 '("[mM][aA][nN][iI][fF][eE][sS][tT]\\.[mM][fF]\\'")
598 "Generic mode for Java Manifest files."))
600 ;; Java properties files
601 (when (memq 'java-properties-generic-mode generic-extras-enable-list)
603 (define-generic-mode java-properties-generic-mode
604 '(?! ?#)
606 (eval-when-compile
607 (let ((java-properties-key
608 "\\(\\([-A-Za-z0-9_\\./]\\|\\(\\\\[ =:]\\)\\)+\\)")
609 (java-properties-value
610 "\\([^\r\n]*\\)"))
611 ;; Property and value can be separated in a number of different ways:
612 ;; * whitespace
613 ;; * an equal sign
614 ;; * a colon
615 (mapcar
616 (function
617 (lambda (elt)
618 (list
619 (concat "^" java-properties-key elt java-properties-value "$")
620 '(1 font-lock-constant-face)
621 '(4 font-lock-variable-name-face))))
622 ;; These are the separators
623 '(":\\s-*" "\\s-+" "\\s-*=\\s-*"))))
625 (list
626 (function
627 (lambda ()
628 (setq imenu-generic-expression
629 '((nil "^\\([^#! \t\n\r=:]+\\)" 1))))))
630 "Generic mode for Java properties files."))
632 ;; C shell alias definitions
633 (when (memq 'alias-generic-mode generic-extras-enable-list)
635 (define-generic-mode alias-generic-mode
636 '(?#)
637 '("alias" "unalias")
638 '(("^alias\\s-+\\([-A-Za-z0-9_]+\\)\\s-+"
639 (1 font-lock-variable-name-face))
640 ("^unalias\\s-+\\([-A-Za-z0-9_]+\\)\\s-*$"
641 (1 font-lock-variable-name-face)))
642 '("alias\\'")
643 (list
644 (function
645 (lambda ()
646 (setq imenu-generic-expression
647 '((nil "^\\(alias\\|unalias\\)\\s-+\\([-a-zA-Z0-9_]+\\)" 2))))))
648 "Generic mode for C Shell alias files."))
650 ;; Ansible inventory files
651 (when (memq 'ansible-inventory-generic-mode generic-extras-enable-list)
653 (define-generic-mode ansible-inventory-generic-mode
654 '(?#)
656 '(("^\\s-*\\(\\[.*\\]\\)" 1 font-lock-constant-face)
657 ("^\\s-*\\([^ \n\r]*\\)" 1 font-lock-function-name-face)
658 ;; Variable assignments must be x=y, so highlight as warning if
659 ;; the value is missing.
660 ("\\s-\\([^ =\n\r]+\\)[\n\r ]" 1 font-lock-warning-face)
661 ;; Variable assignments: x=y
662 ("\\([^ =\n\r]+\\)=\\([^ \n\r]*\\)"
663 (1 font-lock-variable-name-face)
664 (2 font-lock-keyword-face)))
665 '("inventory")
666 (list
667 (function
668 (lambda ()
669 (setq imenu-generic-expression
670 '((nil "^\\s-*\\[\\(.*\\)\\]" 1)
671 ("*Variables*" "\\s-+\\([^ =\n\r]+\\)=" 1))))))
672 "Generic mode for Ansible inventory files."))
674 ;;; Windows RC files
675 ;; Contributed by ACorreir@pervasive-sw.com (Alfred Correira)
676 (when (memq 'rc-generic-mode generic-extras-enable-list)
678 (define-generic-mode rc-generic-mode
679 ;; '(?\/)
680 '("//")
681 '("ACCELERATORS"
682 "AUTO3STATE"
683 "AUTOCHECKBOX"
684 "AUTORADIOBUTTON"
685 "BITMAP"
686 "BOTTOMMARGIN"
687 "BUTTON"
688 "CAPTION"
689 "CHARACTERISTICS"
690 "CHECKBOX"
691 "CLASS"
692 "COMBOBOX"
693 "CONTROL"
694 "CTEXT"
695 "CURSOR"
696 "DEFPUSHBUTTON"
697 "DESIGNINFO"
698 "DIALOG"
699 "DISCARDABLE"
700 "EDITTEXT"
701 "EXSTYLE"
702 "FONT"
703 "GROUPBOX"
704 "GUIDELINES"
705 "ICON"
706 "LANGUAGE"
707 "LEFTMARGIN"
708 "LISTBOX"
709 "LTEXT"
710 "MENUITEM SEPARATOR"
711 "MENUITEM"
712 "MENU"
713 "MOVEABLE"
714 "POPUP"
715 "PRELOAD"
716 "PURE"
717 "PUSHBOX"
718 "PUSHBUTTON"
719 "RADIOBUTTON"
720 "RCDATA"
721 "RIGHTMARGIN"
722 "RTEXT"
723 "SCROLLBAR"
724 "SEPARATOR"
725 "STATE3"
726 "STRINGTABLE"
727 "STYLE"
728 "TEXTINCLUDE"
729 "TOOLBAR"
730 "TOPMARGIN"
731 "VERSIONINFO"
732 "VERSION")
733 ;; the choice of what tokens go where is somewhat arbitrary,
734 ;; as is the choice of which value tokens are included, as
735 ;; the choice of face for each token group
736 (eval-when-compile
737 (list
738 (list (regexp-opt '("FILEFLAGSMASK"
739 "FILEFLAGS"
740 "FILEOS"
741 "FILESUBTYPE"
742 "FILETYPE"
743 "FILEVERSION"
744 "PRODUCTVERSION") 'symbols)
745 1 font-lock-type-face)
746 (list (regexp-opt '("BEGIN" "BLOCK" "END" "VALUE") 'symbols)
747 1 font-lock-function-name-face)
748 '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face)
749 '("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face)
750 '("^#[ \t]*\\(elif\\|if\\)\\>"
751 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil
752 (1 font-lock-constant-face)
753 (2 font-lock-variable-name-face nil t)))
754 '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
755 (1 font-lock-constant-face)
756 (2 font-lock-variable-name-face nil t))))
757 '("\\.[rR][cC]\\'")
759 "Generic mode for MS-Windows Resource files."))
761 ;; InstallShield RUL files
762 ;; Contributed by Alfred.Correira@Pervasive.Com
763 ;; Bugfixes by "Rolf Sandau" <Rolf.Sandau@marconi.com>
764 (when (memq 'rul-generic-mode generic-extras-enable-list)
766 (eval-when-compile
768 ;;; build the regexp strings using regexp-opt
769 (defconst installshield-statement-keyword-list
770 '("abort"
771 "begin"
772 "call"
773 "case"
774 "declare"
775 "default"
776 "downto"
777 "elseif"
778 "else"
779 "endfor"
780 "endif"
781 "endswitch"
782 "endwhile"
783 "end"
784 "exit"
785 "external"
786 "for"
787 "function"
788 ;; "goto" -- handled elsewhere
789 "if"
790 "program"
791 "prototype"
792 "repeat"
793 "return"
794 "step"
795 "switch"
796 "then"
797 "to"
798 "typedef"
799 "until"
800 "void"
801 "while")
802 "Statement keywords used in InstallShield 3 and 5.")
804 (defconst installshield-system-functions-list
805 '("AddFolderIcon"
806 "AddProfString"
807 "AddressString"
808 "AppCommand"
809 "AskDestPath"
810 "AskOptions"
811 "AskPath"
812 "AskText"
813 "AskYesNo"
814 "BatchDeleteEx"
815 "BatchFileLoad"
816 "BatchFileSave"
817 "BatchFind"
818 "BatchGetFileName"
819 "BatchMoveEx"
820 "BatchSetFileName"
821 "ChangeDirectory"
822 "CloseFile"
823 "CmdGetHwndDlg"
824 "ComponentAddItem" ; differs between IS3 and IS5
825 "ComponentCompareSizeRequired" ; IS5 only
826 "ComponentDialog"
827 "ComponentError" ; IS5 only
828 "ComponentFileEnum" ; IS5 only
829 "ComponentFileInfo" ; IS5 only
830 "ComponentFilterLanguage" ; IS5 only
831 "ComponentFilterOS" ; IS5 only
832 "ComponentGetData" ; IS5 only
833 "ComponentGetItemInfo" ; IS3 only
834 "ComponentGetItemSize" ; differs between IS3 and IS5
835 "ComponentIsItemSelected" ; differs between IS3 and IS5
836 "ComponentListItems"
837 "ComponentMoveData" ; IS5 only
838 "ComponentSelectItem" ; differs between IS3 and IS5
839 "ComponentSetData" ; IS5 only
840 "ComponentSetItemInfo" ; IS3 only
841 "ComponentSetTarget" ; IS5 only
842 "ComponentSetupTypeEnum" ; IS5 only
843 "ComponentSetupTypeGetData" ; IS5 only
844 "ComponentSetupTypeSet" ; IS5 only
845 "ComponentTotalSize"
846 "ComponentValidate" ; IS5 only
847 "CompressAdd" ; IS3 only
848 "CompressDel" ; IS3 only
849 "CompressEnum" ; IS3 only
850 "CompressGet" ; IS3 only
851 "CompressInfo" ; IS3 only
852 "CopyFile"
853 "CreateDir"
854 "CreateFile"
855 "CreateProgramFolder"
856 "DeinstallSetReference" ; IS5 only
857 "DeinstallStart"
858 "Delay"
859 "DeleteDir"
860 "DeleteFile"
861 "DialogSetInfo"
862 "Disable"
863 "DoInstall"
864 "Do"
865 "Enable"
866 "EnterDisk"
867 "ExistsDir"
868 "ExistsDisk"
869 "ExitProgMan"
870 "EzBatchAddPath"
871 "EzBatchAddString"
872 "EzBatchReplace"
873 "EzConfigAddDriver"
874 "EzConfigAddString"
875 "EzConfigGetValue"
876 "EzConfigSetValue"
877 "EzDefineDialog"
878 "FileCompare"
879 "FileDeleteLine"
880 "FileGrep"
881 "FileInsertLine"
882 "FileSetBeginDefine" ; IS3 only
883 "FileSetEndDefine" ; IS3 only
884 "FileSetPerformEz" ; IS3 only
885 "FileSetPerform" ; IS3 only
886 "FileSetReset" ; IS3 only
887 "FileSetRoot" ; IS3 only
888 "FindAllDirs"
889 "FindAllFiles"
890 "FindFile"
891 "FindWindow"
892 "GetDiskSpace"
893 "GetDisk"
894 "GetEnvVar"
895 "GetExtents"
896 "GetFileInfo"
897 "GetLine"
898 "GetProfInt"
899 "GetProfString"
900 "GetSystemInfo"
901 "GetValidDrivesList"
902 "GetVersion"
903 "GetWindowHandle"
904 "InstallationInfo"
905 "Is"
906 "LaunchApp"
907 "LaunchAppAndWait"
908 "ListAddItem"
909 "ListAddString"
910 "ListCount"
911 "ListCreate"
912 "ListDestroy"
913 "ListFindItem"
914 "ListFindString"
915 "ListGetFirstItem"
916 "ListGetFirstString"
917 "ListGetNextItem"
918 "ListGetNextString"
919 "ListReadFromFile"
920 "ListSetCurrentItem"
921 "ListSetNextItem"
922 "ListSetNextString"
923 "ListSetIndex"
924 "ListWriteToFile"
925 "LongPathToQuote"
926 "LongPathToShortPath"
927 "MessageBox"
928 "NumToStr"
929 "OpenFileMode"
930 "OpenFile"
931 "ParsePath"
932 "PathAdd"
933 "PathDelete"
934 "PathFind"
935 "PathGet"
936 "PathMove"
937 "PathSet"
938 "Path"
939 "PlaceBitmap"
940 "PlaceWindow"
941 "PlayMMedia" ; IS5 only
942 "ProgDefGroupType"
943 "RegDBCreateKeyEx"
944 "RegDBDeleteValue"
945 "RegDBGetItem"
946 "RegDBKeyExist"
947 "RegDBSetItem"
948 "RegDBGetKeyValueEx"
949 "RegDBSetKeyValueEx"
950 "RegDBSetDefaultRoot"
951 "RenameFile"
952 "ReplaceFolderIcon"
953 "ReplaceProfString"
954 "SdAskDestPath"
955 "SdAskOptions"
956 "SdAskOptionsList"
957 "SdBitmap"
958 "SdCloseDlg"
959 "SdComponentAdvCheckSpace"
960 "SdComponentAdvInit"
961 "SdComponentAdvUpdateSpace"
962 "SdComponentDialog"
963 "SdComponentDialog2"
964 "SdComponentDialogAdv"
965 "SdComponentDialogEx"
966 "SdComponentDlgCheckSpace"
967 "SdComponentMult"
968 "SdConfirmNewDir"
969 "SdConfirmRegistration"
970 "SdDiskSpace"
971 "SdDisplayTopics"
972 "SdDoStdButton"
973 "SdEnablement"
974 "SdError"
975 "SdFinish"
976 "SdFinishInit32"
977 "SdFinishReboot"
978 "SdGeneralInit"
979 "SdGetItemName"
980 "SdGetTextExtent"
981 "SdGetUserCompanyInfo"
982 "SdInit"
983 "SdIsShellExplorer"
984 "SdIsStdButton"
985 "SdLicense"
986 "SdMakeName"
987 "SdOptionInit"
988 "SdOptionSetState"
989 "SdOptionsButtons"
990 "SdOptionsButtonsInit"
991 "SdPlugInProductName"
992 "SdProductName"
993 "SdRegEnableButton"
994 "SdRegExEnableButton"
995 "SdRegisterUser"
996 "SdRegisterUserEx"
997 "SdRemoveEndSpace"
998 "SdSelectFolder"
999 "SdSetSequentialItems"
1000 "SdSetStatic"
1001 "SdSetupTypeEx" ; IS5 only
1002 "SdSetupType"
1003 "SdShowAnyDialog"
1004 "SdShowDlgEdit1"
1005 "SdShowDlgEdit2"
1006 "SdShowDlgEdit3"
1007 "SdShowFileMods"
1008 "SdShowInfoList"
1009 "SdShowMsg"
1010 "SdStartCopy"
1011 "SdUnInit"
1012 "SdUpdateComponentSelection"
1013 "SdWelcome"
1014 "SendMessage"
1015 "SetColor"
1016 "SetFont"
1017 "SetDialogTitle"
1018 "SetDisplayEffect" ; IS5 only
1019 "SetFileInfo"
1020 "SetForegroundWindow"
1021 "SetStatusWindow"
1022 "SetTitle"
1023 "SetupType"
1024 "ShowProgramFolder"
1025 "Split" ; IS3 only
1026 "SprintfBox"
1027 "Sprintf"
1028 "StatusUpdate"
1029 "StrCompare"
1030 "StrFind"
1031 "StrGetTokens"
1032 "StrLength"
1033 "StrRemoveLastSlash"
1034 "StrToLower"
1035 "StrToNum"
1036 "StrToUpper"
1037 "StrSub"
1038 "VarRestore"
1039 "VarSave"
1040 "VerCompare"
1041 "VerGetFileVersion"
1042 "WaitOnDialog"
1043 "Welcome"
1044 "WriteLine"
1045 "WriteProfString"
1046 "XCopyFile")
1047 "System functions defined in InstallShield 3 and 5.")
1049 (defconst installshield-system-variables-list
1050 '("BATCH_INSTALL"
1051 "CMDLINE"
1052 "COMMONFILES"
1053 "CORECOMPONENTHANDLING"
1054 "DIALOGCACHE"
1055 "ERRORFILENAME"
1056 "FOLDER_DESKTOP"
1057 "FOLDER_PROGRAMS"
1058 "FOLDER_STARTMENU"
1059 "FOLDER_STARTUP"
1060 "INFOFILENAME"
1061 "ISRES"
1062 "ISUSER"
1063 "ISVERSION"
1064 "MEDIA"
1065 "MODE"
1066 "PROGRAMFILES"
1067 "SELECTED_LANGUAGE"
1068 "SRCDIR"
1069 "SRCDISK"
1070 "SUPPORTDIR"
1071 "TARGETDIR"
1072 "TARGETDISK"
1073 "UNINST"
1074 "WINDIR"
1075 "WINDISK"
1076 "WINMAJOR"
1077 "WINSYSDIR"
1078 "WINSYSDISK")
1079 "System variables used in InstallShield 3 and 5.")
1081 (defconst installshield-types-list
1082 '("BOOL"
1083 "BYREF"
1084 "CHAR"
1085 "HIWORD"
1086 "HWND"
1087 "INT"
1088 "LIST"
1089 "LONG"
1090 "LOWORD"
1091 "LPSTR"
1092 "NUMBER"
1093 "NUMBERLIST"
1094 "POINTER"
1095 "QUAD"
1096 "RGB"
1097 "SHORT"
1098 "STRINGLIST"
1099 "STRING")
1100 "Type keywords used in InstallShield 3 and 5.")
1102 ;;; some might want to skip highlighting these to improve performance
1103 (defconst installshield-funarg-constants-list
1104 '("AFTER"
1105 "APPEND"
1106 "ALLCONTENTS"
1107 "BACKBUTTON"
1108 "BACKGROUNDCAPTION"
1109 "BACKGROUND"
1110 "BACK"
1111 "BASEMEMORY"
1112 "BEFORE"
1113 "BIOS"
1114 "BITMAPICON"
1115 "BK_BLUE"
1116 "BK_GREEN"
1117 "BK_RED"
1118 "BLUE"
1119 "BOOTUPDRIVE"
1120 "CANCEL"
1121 "CDROM_DRIVE"
1122 "CDROM"
1123 "CHECKBOX95"
1124 "CHECKBOX"
1125 "CHECKLINE"
1126 "CHECKMARK"
1127 "COLORS"
1128 "COMMANDEX"
1129 "COMMAND"
1130 "COMP_NORMAL"
1131 "COMP_UPDATE_DATE"
1132 "COMP_UPDATE_SAME"
1133 "COMP_UPDATE_VERSION"
1134 "COMPACT"
1135 "CONTINUE"
1136 "CPU"
1137 "CUSTOM"
1138 "DATE"
1139 "DEFWINDOWMODE"
1140 "DIR_WRITEABLE"
1141 "DIRECTORY"
1142 "DISABLE"
1143 "DISK_TOTALSPACE"
1144 "DISK"
1145 "DLG_OPTIONS"
1146 "DLG_PATH"
1147 "DLG_TEXT"
1148 "DLG_ASK_YESNO"
1149 "DLG_ENTER_DISK"
1150 "DLG_ERR"
1151 "DLG_INFO_ALTIMAGE"
1152 "DLG_INFO_CHECKSELECTION"
1153 "DLG_INFO_KUNITS"
1154 "DLG_INFO_USEDECIMAL"
1155 "DLG_MSG_INFORMATION"
1156 "DLG_MSG_SEVERE"
1157 "DLG_MSG_WARNING"
1158 "DLG_STATUS"
1159 "DLG_WARNING"
1160 "DLG_USER_CAPTION"
1161 "DRIVE"
1162 "ENABLE"
1163 "END_OF_FILE"
1164 "END_OF_LIST"
1165 "ENVSPACE"
1166 "EQUALS"
1167 "EXCLUDE_SUBDIR"
1168 "EXCLUSIVE"
1169 "EXISTS"
1170 "EXIT"
1171 "EXTENDED_MEMORY"
1172 "EXTENSION_ONLY"
1173 "FAILIFEXISTS"
1174 "FALSE"
1175 "FEEDBACK_FULL"
1176 "FILE_ATTR_ARCHIVED"
1177 "FILE_ATTR_DIRECTORY"
1178 "FILE_ATTR_HIDDEN"
1179 "FILE_ATTR_NORMAL"
1180 "FILE_ATTR_READONLY"
1181 "FILE_ATTR_SYSTEM"
1182 "FILE_ATTRIBUTE"
1183 "FILE_DATE"
1184 "FILE_LINE_LENGTH"
1185 "FILE_MODE_APPEND"
1186 "FILE_MODE_BINARYREADONLY"
1187 "FILE_MODE_BINARY"
1188 "FILE_MODE_NORMAL"
1189 "FILE_NO_VERSION"
1190 "FILE_NOT_FOUND"
1191 "FILE_SIZE"
1192 "FILE_TIME"
1193 "FILENAME_ONLY"
1194 "FILENAME"
1195 "FIXED_DRIVE"
1196 "FOLDER_DESKTOP"
1197 "FOLDER_PROGRAMS"
1198 "FOLDER_STARTMENU"
1199 "FOLDER_STARTUP"
1200 "FREEENVSPACE"
1201 "FULLWINDOWMODE"
1202 "FULL"
1203 "FONT_TITLE"
1204 "GREATER_THAN"
1205 "GREEN"
1206 "HKEY_CLASSES_ROOT"
1207 "HKEY_CURRENT_USER"
1208 "HKEY_LOCAL_MACHINE"
1209 "HKEY_USERS"
1210 "HOURGLASS"
1211 "INCLUDE_SUBDIR"
1212 "INDVFILESTATUS"
1213 "INFORMATION"
1214 "IS_WINDOWSNT"
1215 "IS_WINDOWS95"
1216 "IS_WINDOWS"
1217 "IS_WIN32S"
1218 "ISTYPE"
1219 "LANGUAGE_DRV"
1220 "LANGUAGE"
1221 "LESS_THAN"
1222 "LIST_NULL"
1223 "LISTFIRST"
1224 "LISTNEXT"
1225 "LOCKEDFILE"
1226 "LOGGING"
1227 "LOWER_LEFT"
1228 "LOWER_RIGHT"
1229 "MAGENTA"
1230 "MOUSE_DRV"
1231 "MOUSE"
1232 "NETWORK_DRV"
1233 "NETWORK"
1234 "NEXT"
1235 "NONEXCLUSIVE"
1236 "NORMALMODE"
1237 "NOSET"
1238 "NOTEXISTS"
1239 "NOWAIT"
1240 "NO"
1241 "OFF"
1242 "ONLYDIR"
1243 "ON"
1244 "OSMAJOR"
1245 "OSMINOR"
1246 "OS"
1247 "OTHER_FAILURE"
1248 "PARALLEL"
1249 "PARTIAL"
1250 "PATH_EXISTS"
1251 "PATH"
1252 "RED"
1253 "REGDB_APPPATH_DEFAULT"
1254 "REGDB_APPPATH"
1255 "REGDB_BINARY"
1256 "REGDB_ERR_CONNECTIONEXISTS"
1257 "REGDB_ERR_CORRUPTEDREGISTRY"
1258 "REGDB_ERR_INITIALIZATION"
1259 "REGDB_ERR_INVALIDHANDLE"
1260 "REGDB_ERR_INVALIDNAME"
1261 "REGDB_NUMBER"
1262 "REGDB_STRING_EXPAND"
1263 "REGDB_STRING_MULTI"
1264 "REGDB_STRING"
1265 "REGDB_UNINSTALL_NAME"
1266 "REMOTE_DRIVE"
1267 "REMOVEABLE_DRIVE"
1268 "REPLACE_ITEM"
1269 "REPLACE"
1270 "RESET"
1271 "RESTART"
1272 "ROOT"
1273 "SELFREGISTER"
1274 "SERIAL"
1275 "SET"
1276 "SEVERE"
1277 "SHAREDFILE"
1278 "SHARE"
1279 "SILENTMODE"
1280 "SRCTARGETDIR"
1281 "STATUSBAR"
1282 "STATUSDLG"
1283 "STATUSOLD"
1284 "STATUS"
1285 "STYLE_NORMAL"
1286 "SW_MAXIMIZE"
1287 "SW_MINIMIZE"
1288 "SW_RESTORE"
1289 "SW_SHOW"
1290 "SYS_BOOTMACHINE"
1291 "TIME"
1292 "TRUE"
1293 "TYPICAL"
1294 "UPPER_LEFT"
1295 "UPPER_RIGHT"
1296 "VALID_PATH"
1297 "VERSION"
1298 "VIDEO"
1299 "VOLUMELABEL"
1300 "YELLOW"
1301 "YES"
1302 "WAIT"
1303 "WARNING"
1304 "WINMAJOR"
1305 "WINMINOR"
1306 "WIN32SINSTALLED"
1307 "WIN32SMAJOR"
1308 "WIN32SMINOR")
1309 "Function argument constants used in InstallShield 3 and 5."))
1311 ;; c++-mode-syntax-table used to be autoloaded, with an initial nil value.
1312 ;; This file did not load cc-mode, and therefore rul-generic-mode-syntax-table
1313 ;; would have different values according to whether or not cc-mode
1314 ;; happened to be loaded before this file was.
1315 (require 'cc-mode)
1316 (defvar c++-mode-syntax-table)
1318 (defvar rul-generic-mode-syntax-table
1319 (let ((table (make-syntax-table c++-mode-syntax-table)))
1320 (modify-syntax-entry ?\r "> b" table)
1321 (modify-syntax-entry ?\n "> b" table)
1322 (modify-syntax-entry ?/ ". 124b" table)
1323 (modify-syntax-entry ?* ". 23" table)
1324 table)
1325 "Syntax table to use in `rul-generic-mode' buffers.")
1327 ;; here manually instead
1328 (defun generic-rul-mode-setup-function ()
1329 (make-local-variable 'parse-sexp-ignore-comments)
1330 (make-local-variable 'comment-start)
1331 (make-local-variable 'comment-start-skip)
1332 (make-local-variable 'comment-end)
1333 (setq imenu-generic-expression
1334 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1))
1335 parse-sexp-ignore-comments t
1336 comment-end "*/"
1337 comment-start "/*"
1338 ;;; comment-end ""
1339 ;;; comment-start "//"
1340 ;;; comment-start-skip ""
1342 ;; (set-syntax-table rul-generic-mode-syntax-table)
1343 (setq-local font-lock-syntax-table rul-generic-mode-syntax-table))
1345 ;; moved mode-definition behind defun-definition to be warning-free - 15.11.02/RSan
1346 (define-generic-mode rul-generic-mode
1347 ;; Using "/*" and "*/" doesn't seem to be working right
1348 '("//" ("/*" . "*/" ))
1349 (eval-when-compile installshield-statement-keyword-list)
1350 (eval-when-compile
1351 (list
1352 ;; preprocessor constructs
1353 '("#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)"
1354 1 font-lock-string-face)
1355 '("#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
1356 (1 font-lock-constant-face)
1357 (2 font-lock-variable-name-face nil t))
1358 ;; indirect string constants
1359 '("\\(@[A-Za-z][A-Za-z0-9_]+\\)" 1 font-lock-builtin-face)
1360 ;; gotos
1361 '("[ \t]*\\(\\sw+:\\)" 1 font-lock-constant-face)
1362 '("\\<\\(goto\\)\\>[ \t]*\\(\\sw+\\)?"
1363 (1 font-lock-keyword-face)
1364 (2 font-lock-constant-face nil t))
1365 ;; system variables
1366 (list (concat "[^_]"
1367 (regexp-opt installshield-system-variables-list 'symbols)
1368 "[^_]")
1369 1 font-lock-variable-name-face)
1370 ;; system functions
1371 (list (concat "[^_]"
1372 (regexp-opt installshield-system-functions-list 'symbols)
1373 "[^_]")
1374 1 font-lock-function-name-face)
1375 ;; type keywords
1376 (list (concat "[^_]"
1377 (regexp-opt installshield-types-list 'symbols)
1378 "[^_]")
1379 1 font-lock-type-face)
1380 ;; function argument constants
1381 (list (concat "[^_]"
1382 (regexp-opt installshield-funarg-constants-list 'symbols)
1383 "[^_]")
1384 1 font-lock-variable-name-face))) ; is this face the best choice?
1385 '("\\.[rR][uU][lL]\\'")
1386 '(generic-rul-mode-setup-function)
1387 "Generic mode for InstallShield RUL files.")
1389 (define-skeleton rul-if
1390 "Insert an if statement."
1391 "condition: "
1392 "if(" str ") then" \n
1393 > _ \n
1394 ( "other condition, %s: "
1395 > "elseif(" str ") then" \n
1396 > \n)
1397 > "else" \n
1398 > \n
1399 resume:
1400 > "endif;")
1402 (define-skeleton rul-function
1403 "Insert a function statement."
1404 "function: "
1405 "function " str " ()" \n
1406 ( "local variables, %s: "
1407 > " " str ";" \n)
1408 > "begin" \n
1409 > _ \n
1410 resume:
1411 > "end;"))
1413 ;; Additions by ACorreir@pervasive-sw.com (Alfred Correira)
1414 (when (memq 'mailrc-generic-mode generic-extras-enable-list)
1416 (define-generic-mode mailrc-generic-mode
1417 '(?#)
1418 '("alias"
1419 "else"
1420 "endif"
1421 "group"
1422 "if"
1423 "ignore"
1424 "set"
1425 "source"
1426 "unset")
1427 '(("^\\s-*\\(alias\\|group\\)\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1428 (2 font-lock-constant-face)
1429 (3 font-lock-variable-name-face))
1430 ("^\\s-*\\(unset\\|set\\|ignore\\)\\s-+\\([-A-Za-z0-9_]+\\)=?\\([^\n\r#]*\\)\\(#.*\\)?$"
1431 (2 font-lock-constant-face)
1432 (3 font-lock-variable-name-face))
1433 ("^\\s-*\\(source\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1434 (2 font-lock-variable-name-face)))
1435 '("\\.mailrc\\'")
1437 "Mode for mailrc files."))
1439 ;; Inetd.conf
1440 (when (memq 'inetd-conf-generic-mode generic-extras-enable-list)
1442 (define-generic-mode inetd-conf-generic-mode
1443 '(?#)
1444 '("stream"
1445 "dgram"
1446 "tcp"
1447 "udp"
1448 "wait"
1449 "nowait"
1450 "internal")
1451 '(("^\\([-A-Za-z0-9_]+\\)" 1 font-lock-type-face))
1452 '("/etc/inetd.conf\\'")
1453 (list
1454 (function
1455 (lambda ()
1456 (setq imenu-generic-expression
1457 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1459 ;; Services
1460 (when (memq 'etc-services-generic-mode generic-extras-enable-list)
1462 (define-generic-mode etc-services-generic-mode
1463 '(?#)
1464 '("tcp"
1465 "udp"
1466 "ddp")
1467 '(("^\\([-A-Za-z0-9_]+\\)\\s-+\\([0-9]+\\)/"
1468 (1 font-lock-type-face)
1469 (2 font-lock-variable-name-face)))
1470 '("/etc/services\\'")
1471 (list
1472 (function
1473 (lambda ()
1474 (setq imenu-generic-expression
1475 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1477 ;; Password and Group files
1478 (when (memq 'etc-passwd-generic-mode generic-extras-enable-list)
1480 (define-generic-mode etc-passwd-generic-mode
1481 nil ;; No comment characters
1482 '("root") ;; Only one keyword
1483 (eval-when-compile
1484 (list
1485 (list
1486 (concat
1488 ;; User name -- Never blank!
1489 "\\([^:]+\\)"
1491 ;; Password, UID and GID
1492 (mapconcat
1493 'identity
1494 (make-list 3 "\\([^:]+\\)")
1495 ":")
1497 ;; GECOS/Name -- might be blank
1498 "\\([^:]*\\)"
1500 ;; Home directory and shell
1501 "\\([^:]+\\)"
1502 ":?"
1503 "\\([^:]*\\)"
1504 "$")
1505 '(1 font-lock-type-face)
1506 '(5 font-lock-variable-name-face)
1507 '(6 font-lock-constant-face)
1508 '(7 font-lock-warning-face))
1509 '("^\\([^:]+\\):\\([^:]*\\):\\([0-9]+\\):\\(.*\\)$"
1510 (1 font-lock-type-face)
1511 (4 font-lock-variable-name-face))))
1512 '("/etc/passwd\\'" "/etc/group\\'")
1513 (list
1514 (function
1515 (lambda ()
1516 (setq imenu-generic-expression
1517 '((nil "^\\([-A-Za-z0-9_]+\\):" 1))))))))
1519 ;; Fstab
1520 (when (memq 'etc-fstab-generic-mode generic-extras-enable-list)
1522 (define-generic-mode etc-fstab-generic-mode
1523 '(?#)
1524 '("adfs"
1525 "affs"
1526 "autofs"
1527 "coda"
1528 "coherent"
1529 "cramfs"
1530 "devpts"
1531 "efs"
1532 "ext2"
1533 "ext3"
1534 "ext4"
1535 "hfs"
1536 "hpfs"
1537 "iso9660"
1538 "jfs"
1539 "minix"
1540 "msdos"
1541 "ncpfs"
1542 "nfs"
1543 "ntfs"
1544 "proc"
1545 "qnx4"
1546 "reiserfs"
1547 "romfs"
1548 "smbfs"
1549 "cifs"
1550 "usbdevfs"
1551 "sysv"
1552 "sysfs"
1553 "tmpfs"
1554 "udf"
1555 "ufs"
1556 "umsdos"
1557 "vfat"
1558 "xenix"
1559 "xfs"
1560 "swap"
1561 "auto"
1562 "ignore")
1563 '(("^\\([^# \t]+\\)\\s-+\\([^# \t]+\\)"
1564 (1 font-lock-type-face t)
1565 (2 font-lock-variable-name-face t)))
1566 '("/etc/[v]*fstab\\'")
1567 (list
1568 (function
1569 (lambda ()
1570 (setq imenu-generic-expression
1571 '((nil "^\\([^# \t]+\\)\\s-+" 1))))))))
1573 ;; /etc/sudoers
1574 (when (memq 'etc-sudoers-generic-mode generic-extras-enable-list)
1576 (define-generic-mode etc-sudoers-generic-mode
1577 '(?#)
1578 '("User_Alias" "Runas_Alias" "Host_Alias" "Cmnd_Alias"
1579 "NOPASSWD" "PASSWD" "NOEXEC" "EXEC"
1580 "ALL")
1581 '(("\\<\\(root\\|su\\)\\>" 1 font-lock-warning-face)
1582 ("\\(\\*\\)" 1 font-lock-warning-face)
1583 ("\\<\\(%[A-Za-z0-9_]+\\)\\>" 1 font-lock-variable-name-face))
1584 '("/etc/sudoers\\'")
1586 "Generic mode for sudoers configuration files."))
1588 ;; From Jacques Duthen <jacques.duthen@sncf.fr>
1589 (when (memq 'show-tabs-generic-mode generic-extras-enable-list)
1591 (eval-when-compile
1593 (defconst show-tabs-generic-mode-font-lock-defaults-1
1594 '(;; trailing spaces must come before...
1595 ("[ \t]+$" . 'show-tabs-space)
1596 ;; ...embedded tabs
1597 ("[^\n\t]\\(\t+\\)" (1 'show-tabs-tab))))
1599 (defconst show-tabs-generic-mode-font-lock-defaults-2
1600 '(;; trailing spaces must come before...
1601 ("[ \t]+$" . 'show-tabs-space)
1602 ;; ...tabs
1603 ("\t+" . 'show-tabs-tab))))
1605 (defface show-tabs-tab
1606 '((((class grayscale) (background light)) (:background "DimGray" :weight bold))
1607 (((class grayscale) (background dark)) (:background "LightGray" :weight bold))
1608 (((class color) (min-colors 88)) (:background "red1"))
1609 (((class color)) (:background "red"))
1610 (t (:weight bold)))
1611 "Font Lock mode face used to highlight TABs."
1612 :group 'generic-x)
1614 (defface show-tabs-space
1615 '((((class grayscale) (background light)) (:background "DimGray" :weight bold))
1616 (((class grayscale) (background dark)) (:background "LightGray" :weight bold))
1617 (((class color) (min-colors 88)) (:background "yellow1"))
1618 (((class color)) (:background "yellow"))
1619 (t (:weight bold)))
1620 "Font Lock mode face used to highlight spaces."
1621 :group 'generic-x)
1623 (define-generic-mode show-tabs-generic-mode
1624 nil ;; no comment char
1625 nil ;; no keywords
1626 (eval-when-compile show-tabs-generic-mode-font-lock-defaults-1)
1627 nil ;; no auto-mode-alist
1628 ;; '(show-tabs-generic-mode-hook-fun)
1630 "Generic mode to show tabs and trailing spaces."))
1632 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1633 ;; DNS modes
1634 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1636 (when (memq 'named-boot-generic-mode generic-extras-enable-list)
1638 (define-generic-mode named-boot-generic-mode
1639 ;; List of comment characters
1640 '(?\;)
1641 ;; List of keywords
1642 '("cache" "primary" "secondary" "forwarders" "limit" "options"
1643 "directory" "check-names")
1644 ;; List of additional font-lock-expressions
1645 '(("\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)" 1 font-lock-constant-face)
1646 ("^directory\\s-+\\(.*\\)" 1 font-lock-variable-name-face)
1647 ("^\\(primary\\|cache\\)\\s-+\\([.A-Za-z]+\\)\\s-+\\(.*\\)"
1648 (2 font-lock-variable-name-face)
1649 (3 font-lock-constant-face)))
1650 ;; List of additional automode-alist expressions
1651 '("/etc/named.boot\\'")
1652 ;; List of set up functions to call
1653 nil))
1655 (when (memq 'named-database-generic-mode generic-extras-enable-list)
1657 (define-generic-mode named-database-generic-mode
1658 ;; List of comment characters
1659 '(?\;)
1660 ;; List of keywords
1661 '("IN" "NS" "CNAME" "SOA" "PTR" "MX" "A")
1662 ;; List of additional font-lock-expressions
1663 '(("\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)" 1 font-lock-constant-face)
1664 ("^\\([.A-Za-z0-9]+\\)" 1 font-lock-variable-name-face))
1665 ;; List of additional auto-mode-alist expressions
1667 ;; List of set up functions to call
1668 nil)
1670 (defvar named-database-time-string "%Y%m%d%H"
1671 "Timestring for named serial numbers.")
1673 (defun named-database-print-serial ()
1674 "Print a serial number based on the current date."
1675 (interactive)
1676 (insert (format-time-string named-database-time-string))))
1678 (when (memq 'resolve-conf-generic-mode generic-extras-enable-list)
1680 (define-generic-mode resolve-conf-generic-mode
1681 ;; List of comment characters
1682 '(?#)
1683 ;; List of keywords
1684 '("nameserver" "domain" "search" "sortlist" "options")
1685 ;; List of additional font-lock-expressions
1687 ;; List of additional auto-mode-alist expressions
1688 '("/etc/resolv[e]?.conf\\'")
1689 ;; List of set up functions to call
1690 nil))
1692 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1693 ;; Modes for spice and common electrical engineering circuit netlist formats
1694 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1696 (when (memq 'spice-generic-mode generic-extras-enable-list)
1698 (define-generic-mode spice-generic-mode
1700 '("and"
1701 "cccs"
1702 "ccvs"
1703 "delay"
1704 "nand"
1705 "nor"
1706 "npwl"
1707 "or"
1708 "par"
1709 "ppwl"
1710 "pwl"
1711 "vccap"
1712 "vccs"
1713 "vcr"
1714 "vcvs")
1715 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face)
1716 (" \\(\\$ .*\\)$" 1 font-lock-comment-face)
1717 ("^\\(\\$ .*\\)$" 1 font-lock-comment-face)
1718 ("\\([*].*\\)" 1 font-lock-comment-face)
1719 ("^\\([+]\\)" 1 font-lock-string-face)
1720 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face)
1721 ("\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face)
1722 ("\\('[^']+'\\)" 1 font-lock-string-face)
1723 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face))
1724 '("\\.[sS][pP]\\'"
1725 "\\.[sS][pP][iI]\\'"
1726 "\\.[sS][pP][iI][cC][eE]\\'"
1727 "\\.[iI][nN][cC]\\'")
1728 (list
1729 'generic-bracket-support
1730 ;; Make keywords case-insensitive
1731 (function
1732 (lambda()
1733 (setq font-lock-defaults '(generic-font-lock-keywords nil t)))))
1734 "Generic mode for SPICE circuit netlist files."))
1736 (when (memq 'ibis-generic-mode generic-extras-enable-list)
1738 (define-generic-mode ibis-generic-mode
1739 '(?|)
1741 '(("[[]\\([^]]*\\)[]]" 1 font-lock-keyword-face)
1742 ("\\(\\(_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face))
1743 '("\\.[iI][bB][sS]\\'")
1744 '(generic-bracket-support)
1745 "Generic mode for IBIS circuit netlist files."))
1747 (when (memq 'astap-generic-mode generic-extras-enable-list)
1749 (define-generic-mode astap-generic-mode
1751 '("analyze"
1752 "description"
1753 "elements"
1754 "execution"
1755 "features"
1756 "functions"
1757 "ground"
1758 "model"
1759 "outputs"
1760 "print"
1761 "run"
1762 "controls"
1763 "table")
1764 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face)
1765 (";\\s-*\\([*].*\\)" 1 font-lock-comment-face)
1766 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face)
1767 ("\\('[^']+'\\)" 1 font-lock-string-face)
1768 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face)
1769 ("[(,]\\s-*\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face))
1770 '("\\.[aA][pP]\\'"
1771 "\\.[aA][sS][xX]\\'"
1772 "\\.[aA][sS][tT][aA][pP]\\'"
1773 "\\.[pP][sS][pP]\\'"
1774 "\\.[dD][eE][cC][kK]\\'"
1775 "\\.[gG][oO][dD][aA][tT][aA]")
1776 (list
1777 'generic-bracket-support
1778 ;; Make keywords case-insensitive
1779 (function
1780 (lambda()
1781 (setq font-lock-defaults '(generic-font-lock-keywords nil t)))))
1782 "Generic mode for ASTAP circuit netlist files."))
1784 (when (memq 'etc-modules-conf-generic-mode generic-extras-enable-list)
1786 (define-generic-mode etc-modules-conf-generic-mode
1787 ;; List of comment characters
1788 '(?#)
1789 ;; List of keywords
1790 '("above"
1791 "alias"
1792 "below"
1793 "define"
1794 "depfile"
1795 "else"
1796 "elseif"
1797 "endif"
1798 "if"
1799 "include"
1800 "insmod_opt"
1801 "install"
1802 "keep"
1803 "options"
1804 "path"
1805 "generic_stringfile"
1806 "pcimapfile"
1807 "isapnpmapfile"
1808 "usbmapfile"
1809 "parportmapfile"
1810 "ieee1394mapfile"
1811 "pnpbiosmapfile"
1812 "probe"
1813 "probeall"
1814 "prune"
1815 "post-install"
1816 "post-remove"
1817 "pre-install"
1818 "pre-remove"
1819 "remove"
1820 "persistdir")
1821 ;; List of additional font-lock-expressions
1823 ;; List of additional automode-alist expressions
1824 '("/etc/modules.conf" "/etc/conf.modules")
1825 ;; List of set up functions to call
1826 nil))
1828 (provide 'generic-x)
1830 ;;; generic-x.el ends here