Allow 'browse-url-emacs' to fetch URL in the selected window
[emacs.git] / lisp / generic-x.el
blobd8a7fe3a73595cef396fdbaa8a6ecc56fd564bd2
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-extras-enable-list
245 (append generic-default-modes
246 (if (memq system-type '(windows-nt ms-dos))
247 generic-mswindows-modes
248 generic-unix-modes)
249 nil)
250 "List of generic modes to define.
251 Each entry in the list should be a symbol. If you set this variable
252 directly, without using customize, you must reload generic-x to put
253 your changes into effect."
254 :group 'generic-x
255 :type (let (list)
256 (dolist (mode
257 (sort (append generic-default-modes
258 generic-mswindows-modes
259 generic-unix-modes
260 generic-other-modes
261 nil)
262 (lambda (a b)
263 (string< (symbol-name b)
264 (symbol-name a))))
265 (cons 'set list))
266 (push `(const ,mode) list)))
267 :set (lambda (s v)
268 (set-default s v)
269 (unless load-in-progress
270 (load "generic-x")))
271 :version "22.1")
273 ;;; Apache
274 (when (memq 'apache-conf-generic-mode generic-extras-enable-list)
276 (define-generic-mode apache-conf-generic-mode
277 '(?#)
279 '(("^\\s-*\\(<.*>\\)" 1 font-lock-constant-face)
280 ("^\\s-*\\(\\sw+\\)\\s-" 1 font-lock-variable-name-face))
281 '("srm\\.conf\\'" "httpd\\.conf\\'" "access\\.conf\\'")
282 (list
283 (function
284 (lambda ()
285 (setq imenu-generic-expression
286 '((nil "^\\([-A-Za-z0-9_]+\\)" 1)
287 ("*Directories*" "^\\s-*<Directory\\s-*\\([^>]+\\)>" 1)
288 ("*Locations*" "^\\s-*<Location\\s-*\\([^>]+\\)>" 1))))))
289 "Generic mode for Apache or HTTPD configuration files."))
291 (when (memq 'apache-log-generic-mode generic-extras-enable-list)
293 (define-generic-mode apache-log-generic-mode
296 ;; Hostname ? user date request return-code number-of-bytes
297 '(("^\\([-a-zA-z0-9.]+\\) - [-A-Za-z]+ \\(\\[.*\\]\\)"
298 (1 font-lock-constant-face)
299 (2 font-lock-variable-name-face)))
300 '("access_log\\'")
302 "Generic mode for Apache log files."))
304 ;;; Samba
305 (when (memq 'samba-generic-mode generic-extras-enable-list)
307 (define-generic-mode samba-generic-mode
308 '(?\; ?#)
310 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face)
311 ("^\\s-*\\(.+\\)=\\([^\r\n]*\\)"
312 (1 font-lock-variable-name-face)
313 (2 font-lock-type-face)))
314 '("smb\\.conf\\'")
315 '(generic-bracket-support)
316 "Generic mode for Samba configuration files."))
318 ;;; Fvwm
319 ;; This is pretty basic. Also, modes for other window managers could
320 ;; be defined as well.
321 (when (memq 'fvwm-generic-mode generic-extras-enable-list)
323 (define-generic-mode fvwm-generic-mode
324 '(?#)
325 '("AddToMenu"
326 "AddToFunc"
327 "ButtonStyle"
328 "EndFunction"
329 "EndPopup"
330 "Function"
331 "IconPath"
332 "Key"
333 "ModulePath"
334 "Mouse"
335 "PixmapPath"
336 "Popup"
337 "Style")
339 '("\\.fvwmrc\\'" "\\.fvwm2rc\\'")
341 "Generic mode for FVWM configuration files."))
343 ;;; X Resource
344 ;; I'm pretty sure I've seen an actual mode to do this, but I don't
345 ;; think it's standard with Emacs
346 (when (memq 'x-resource-generic-mode generic-extras-enable-list)
348 (define-generic-mode x-resource-generic-mode
349 '(?!)
351 '(("^\\([^:\n]+:\\)" 1 font-lock-variable-name-face))
352 '("\\.Xdefaults\\'" "\\.Xresources\\'" "\\.Xenvironment\\'" "\\.ad\\'")
354 "Generic mode for X Resource configuration files."))
356 (if (memq 'xmodmap-generic-mode generic-extras-enable-list)
357 (define-generic-mode xmodmap-generic-mode
358 '(?!)
359 '("add" "clear" "keycode" "keysym" "remove" "pointer")
361 '("[xX]modmap\\(rc\\)?\\'")
363 "Simple mode for xmodmap files."))
365 ;;; Hosts
366 (when (memq 'hosts-generic-mode generic-extras-enable-list)
368 (define-generic-mode hosts-generic-mode
369 '(?#)
370 '("localhost")
371 '(("\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)" 1 font-lock-constant-face))
372 '("[hH][oO][sS][tT][sS]\\'")
374 "Generic mode for HOSTS files."))
376 ;;; Windows INF files
378 ;; If i-g-m-f-f-h is defined, then so is i-g-m.
379 (declare-function ini-generic-mode "generic-x")
381 (when (memq 'inf-generic-mode generic-extras-enable-list)
383 (define-generic-mode inf-generic-mode
384 '(?\;)
386 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face))
387 '("\\.[iI][nN][fF]\\'")
388 '(generic-bracket-support)
389 "Generic mode for MS-Windows INF files."))
391 ;;; Windows INI files
392 ;; Should define escape character as well!
393 (when (memq 'ini-generic-mode generic-extras-enable-list)
395 (define-generic-mode ini-generic-mode
396 '(?\;)
398 '(("^\\(\\[.*\\]\\)" 1 font-lock-constant-face)
399 ("^\\([^=\n\r]*\\)=\\([^\n\r]*\\)$"
400 (1 font-lock-function-name-face)
401 (2 font-lock-variable-name-face)))
402 '("\\.[iI][nN][iI]\\'")
403 (list
404 (function
405 (lambda ()
406 (setq imenu-generic-expression
407 '((nil "^\\[\\(.*\\)\\]" 1)
408 ("*Variables*" "^\\s-*\\([^=]+\\)\\s-*=" 1))))))
409 "Generic mode for MS-Windows INI files.
410 You can use `ini-generic-mode-find-file-hook' to enter this mode
411 automatically for INI files whose names do not end in \".ini\".")
413 (defun ini-generic-mode-find-file-hook ()
414 "Hook function to enter Ini-Generic mode automatically for INI files.
415 Done if the first few lines of a file in Fundamental mode look
416 like an INI file. You can add this hook to `find-file-hook'."
417 (and (eq major-mode 'fundamental-mode)
418 (save-excursion
419 (goto-char (point-min))
420 (and (looking-at "^\\s-*\\[.*\\]")
421 (ini-generic-mode)))))
422 (defalias 'generic-mode-ini-file-find-file-hook 'ini-generic-mode-find-file-hook))
424 ;;; Windows REG files
425 ;;; Unfortunately, Windows 95 and Windows NT have different REG file syntax!
426 (when (memq 'reg-generic-mode generic-extras-enable-list)
428 (define-generic-mode reg-generic-mode
429 '(?\;)
430 '("key" "classes_root" "REGEDIT" "REGEDIT4")
431 '(("\\(\\[.*\\]\\)" 1 font-lock-constant-face)
432 ("^\\([^\n\r]*\\)\\s-*=" 1 font-lock-variable-name-face))
433 '("\\.[rR][eE][gG]\\'")
434 (list
435 (function
436 (lambda ()
437 (setq imenu-generic-expression
438 '((nil "^\\s-*\\(.*\\)\\s-*=" 1))))))
439 "Generic mode for MS-Windows Registry files."))
441 (declare-function w32-shell-name "w32-fns" ())
443 ;;; DOS/Windows BAT files
444 (when (memq 'bat-generic-mode generic-extras-enable-list)
445 (define-obsolete-function-alias 'bat-generic-mode 'bat-mode "24.4"))
447 ;;; Mailagent
448 ;; Mailagent is a Unix mail filtering program. Anyone wanna do a
449 ;; generic mode for procmail?
450 (when (memq 'mailagent-rules-generic-mode generic-extras-enable-list)
452 (define-generic-mode mailagent-rules-generic-mode
453 '(?#)
454 '("SAVE" "DELETE" "PIPE" "ANNOTATE" "REJECT")
455 '(("^\\(\\sw+\\)\\s-*=" 1 font-lock-variable-name-face)
456 ("\\s-/\\([^/]+\\)/[i, \t\n]" 1 font-lock-constant-face))
457 '("\\.rules\\'")
458 (list
459 (function
460 (lambda ()
461 (setq imenu-generic-expression
462 '((nil "\\s-/\\([^/]+\\)/[i, \t\n]" 1))))))
463 "Generic mode for Mailagent rules files."))
465 ;; Solaris/Sys V prototype files
466 (when (memq 'prototype-generic-mode generic-extras-enable-list)
468 (define-generic-mode prototype-generic-mode
469 '(?#)
471 '(("^\\([0-9]\\)?\\s-*\\([a-z]\\)\\s-+\\([A-Za-z_]+\\)\\s-+\\([^\n\r]*\\)$"
472 (2 font-lock-constant-face)
473 (3 font-lock-keyword-face))
474 ("^\\([a-z]\\) \\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
475 (1 font-lock-constant-face)
476 (2 font-lock-keyword-face)
477 (3 font-lock-variable-name-face))
478 ("^\\(!\\s-*\\(search\\|include\\|default\\)\\)\\s-*\\([^\n\r]*\\)$"
479 (1 font-lock-keyword-face)
480 (3 font-lock-variable-name-face))
481 ("^\\(!\\s-*\\sw+\\)=\\([^\n\r]*\\)$"
482 (1 font-lock-keyword-face)
483 (2 font-lock-variable-name-face)))
484 '("prototype\\'")
486 "Generic mode for Sys V prototype files."))
488 ;; Solaris/Sys V pkginfo files
489 (when (memq 'pkginfo-generic-mode generic-extras-enable-list)
491 (define-generic-mode pkginfo-generic-mode
492 '(?#)
494 '(("^\\([A-Za-z_]+\\)=\\([^\n\r]*\\)$"
495 (1 font-lock-keyword-face)
496 (2 font-lock-variable-name-face)))
497 '("pkginfo\\'")
499 "Generic mode for Sys V pkginfo files."))
501 ;; Javascript mode
502 ;; Obsolete; defer to js-mode from js.el.
503 (when (memq 'javascript-generic-mode generic-extras-enable-list)
504 (define-obsolete-function-alias 'javascript-generic-mode 'js-mode "24.3")
505 (define-obsolete-variable-alias 'javascript-generic-mode-hook 'js-mode-hook "24.3"))
507 ;; VRML files
508 (when (memq 'vrml-generic-mode generic-extras-enable-list)
510 (define-generic-mode vrml-generic-mode
511 '(?#)
512 '("DEF"
513 "NULL"
514 "USE"
515 "Viewpoint"
516 "ambientIntensity"
517 "appearance"
518 "children"
519 "color"
520 "coord"
521 "coordIndex"
522 "creaseAngle"
523 "diffuseColor"
524 "emissiveColor"
525 "fieldOfView"
526 "geometry"
527 "info"
528 "material"
529 "normal"
530 "orientation"
531 "position"
532 "shininess"
533 "specularColor"
534 "texCoord"
535 "texture"
536 "textureTransform"
537 "title"
538 "transparency"
539 "type")
540 '(("USE\\s-+\\([-A-Za-z0-9_]+\\)"
541 (1 font-lock-constant-face))
542 ("DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
543 (1 font-lock-type-face)
544 (2 font-lock-constant-face))
545 ("^\\s-*\\([-A-Za-z0-9_]+\\)\\s-*{"
546 (1 font-lock-function-name-face))
547 ("^\\s-*\\(geometry\\|appearance\\|material\\)\\s-+\\([-A-Za-z0-9_]+\\)"
548 (2 font-lock-variable-name-face)))
549 '("\\.wrl\\'")
550 (list
551 (function
552 (lambda ()
553 (setq imenu-generic-expression
554 '((nil "^\\([A-Za-z0-9_]+\\)\\s-*{" 1)
555 ("*Definitions*"
556 "DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{"
557 1))))))
558 "Generic Mode for VRML files."))
560 ;; Java Manifests
561 (when (memq 'java-manifest-generic-mode generic-extras-enable-list)
563 (define-generic-mode java-manifest-generic-mode
564 '(?#)
565 '("Name"
566 "Digest-Algorithms"
567 "Manifest-Version"
568 "Required-Version"
569 "Signature-Version"
570 "Magic"
571 "Java-Bean"
572 "Depends-On")
573 '(("^Name:\\s-+\\([^\n\r]*\\)$"
574 (1 font-lock-variable-name-face))
575 ("^\\(Manifest\\|Required\\|Signature\\)-Version:\\s-+\\([^\n\r]*\\)$"
576 (2 font-lock-constant-face)))
577 '("[mM][aA][nN][iI][fF][eE][sS][tT]\\.[mM][fF]\\'")
579 "Generic mode for Java Manifest files."))
581 ;; Java properties files
582 (when (memq 'java-properties-generic-mode generic-extras-enable-list)
584 (define-generic-mode java-properties-generic-mode
585 '(?! ?#)
587 (eval-when-compile
588 (let ((java-properties-key
589 "\\(\\([-A-Za-z0-9_\\./]\\|\\(\\\\[ =:]\\)\\)+\\)")
590 (java-properties-value
591 "\\([^\r\n]*\\)"))
592 ;; Property and value can be separated in a number of different ways:
593 ;; * whitespace
594 ;; * an equal sign
595 ;; * a colon
596 (mapcar
597 (function
598 (lambda (elt)
599 (list
600 (concat "^" java-properties-key elt java-properties-value "$")
601 '(1 font-lock-constant-face)
602 '(4 font-lock-variable-name-face))))
603 ;; These are the separators
604 '(":\\s-*" "\\s-+" "\\s-*=\\s-*"))))
606 (list
607 (function
608 (lambda ()
609 (setq imenu-generic-expression
610 '((nil "^\\([^#! \t\n\r=:]+\\)" 1))))))
611 "Generic mode for Java properties files."))
613 ;; C shell alias definitions
614 (when (memq 'alias-generic-mode generic-extras-enable-list)
616 (define-generic-mode alias-generic-mode
617 '(?#)
618 '("alias" "unalias")
619 '(("^alias\\s-+\\([-A-Za-z0-9_]+\\)\\s-+"
620 (1 font-lock-variable-name-face))
621 ("^unalias\\s-+\\([-A-Za-z0-9_]+\\)\\s-*$"
622 (1 font-lock-variable-name-face)))
623 '("alias\\'")
624 (list
625 (function
626 (lambda ()
627 (setq imenu-generic-expression
628 '((nil "^\\(alias\\|unalias\\)\\s-+\\([-a-zA-Z0-9_]+\\)" 2))))))
629 "Generic mode for C Shell alias files."))
631 ;; Ansible inventory files
632 (when (memq 'ansible-inventory-generic-mode generic-extras-enable-list)
634 (define-generic-mode ansible-inventory-generic-mode
635 '(?#)
637 '(("^\\s-*\\(\\[.*\\]\\)" 1 font-lock-constant-face)
638 ("^\\s-*\\([^ \n\r]*\\)" 1 font-lock-function-name-face)
639 ;; Variable assignments must be x=y, so highlight as warning if
640 ;; the value is missing.
641 ("\\s-\\([^ =\n\r]+\\)[\n\r ]" 1 font-lock-warning-face)
642 ;; Variable assignments: x=y
643 ("\\([^ =\n\r]+\\)=\\([^ \n\r]*\\)"
644 (1 font-lock-variable-name-face)
645 (2 font-lock-keyword-face)))
646 '("inventory")
647 (list
648 (function
649 (lambda ()
650 (setq imenu-generic-expression
651 '((nil "^\\s-*\\[\\(.*\\)\\]" 1)
652 ("*Variables*" "\\s-+\\([^ =\n\r]+\\)=" 1))))))
653 "Generic mode for Ansible inventory files."))
655 ;;; Windows RC files
656 ;; Contributed by ACorreir@pervasive-sw.com (Alfred Correira)
657 (when (memq 'rc-generic-mode generic-extras-enable-list)
659 (define-generic-mode rc-generic-mode
660 ;; '(?\/)
661 '("//")
662 '("ACCELERATORS"
663 "AUTO3STATE"
664 "AUTOCHECKBOX"
665 "AUTORADIOBUTTON"
666 "BITMAP"
667 "BOTTOMMARGIN"
668 "BUTTON"
669 "CAPTION"
670 "CHARACTERISTICS"
671 "CHECKBOX"
672 "CLASS"
673 "COMBOBOX"
674 "CONTROL"
675 "CTEXT"
676 "CURSOR"
677 "DEFPUSHBUTTON"
678 "DESIGNINFO"
679 "DIALOG"
680 "DISCARDABLE"
681 "EDITTEXT"
682 "EXSTYLE"
683 "FONT"
684 "GROUPBOX"
685 "GUIDELINES"
686 "ICON"
687 "LANGUAGE"
688 "LEFTMARGIN"
689 "LISTBOX"
690 "LTEXT"
691 "MENUITEM SEPARATOR"
692 "MENUITEM"
693 "MENU"
694 "MOVEABLE"
695 "POPUP"
696 "PRELOAD"
697 "PURE"
698 "PUSHBOX"
699 "PUSHBUTTON"
700 "RADIOBUTTON"
701 "RCDATA"
702 "RIGHTMARGIN"
703 "RTEXT"
704 "SCROLLBAR"
705 "SEPARATOR"
706 "STATE3"
707 "STRINGTABLE"
708 "STYLE"
709 "TEXTINCLUDE"
710 "TOOLBAR"
711 "TOPMARGIN"
712 "VERSIONINFO"
713 "VERSION")
714 ;; the choice of what tokens go where is somewhat arbitrary,
715 ;; as is the choice of which value tokens are included, as
716 ;; the choice of face for each token group
717 (eval-when-compile
718 (list
719 (list (regexp-opt '("FILEFLAGSMASK"
720 "FILEFLAGS"
721 "FILEOS"
722 "FILESUBTYPE"
723 "FILETYPE"
724 "FILEVERSION"
725 "PRODUCTVERSION") 'symbols)
726 1 font-lock-type-face)
727 (list (regexp-opt '("BEGIN" "BLOCK" "END" "VALUE") 'symbols)
728 1 font-lock-function-name-face)
729 '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face)
730 '("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face)
731 '("^#[ \t]*\\(elif\\|if\\)\\>"
732 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil
733 (1 font-lock-constant-face)
734 (2 font-lock-variable-name-face nil t)))
735 '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
736 (1 font-lock-constant-face)
737 (2 font-lock-variable-name-face nil t))))
738 '("\\.[rR][cC]\\'")
740 "Generic mode for MS-Windows Resource files."))
742 ;; InstallShield RUL files
743 ;; Contributed by Alfred.Correira@Pervasive.Com
744 ;; Bugfixes by "Rolf Sandau" <Rolf.Sandau@marconi.com>
745 (when (memq 'rul-generic-mode generic-extras-enable-list)
747 (eval-when-compile
749 ;;; build the regexp strings using regexp-opt
750 (defconst installshield-statement-keyword-list
751 '("abort"
752 "begin"
753 "call"
754 "case"
755 "declare"
756 "default"
757 "downto"
758 "elseif"
759 "else"
760 "endfor"
761 "endif"
762 "endswitch"
763 "endwhile"
764 "end"
765 "exit"
766 "external"
767 "for"
768 "function"
769 ;; "goto" -- handled elsewhere
770 "if"
771 "program"
772 "prototype"
773 "repeat"
774 "return"
775 "step"
776 "switch"
777 "then"
778 "to"
779 "typedef"
780 "until"
781 "void"
782 "while")
783 "Statement keywords used in InstallShield 3 and 5.")
785 (defconst installshield-system-functions-list
786 '("AddFolderIcon"
787 "AddProfString"
788 "AddressString"
789 "AppCommand"
790 "AskDestPath"
791 "AskOptions"
792 "AskPath"
793 "AskText"
794 "AskYesNo"
795 "BatchDeleteEx"
796 "BatchFileLoad"
797 "BatchFileSave"
798 "BatchFind"
799 "BatchGetFileName"
800 "BatchMoveEx"
801 "BatchSetFileName"
802 "ChangeDirectory"
803 "CloseFile"
804 "CmdGetHwndDlg"
805 "ComponentAddItem" ; differs between IS3 and IS5
806 "ComponentCompareSizeRequired" ; IS5 only
807 "ComponentDialog"
808 "ComponentError" ; IS5 only
809 "ComponentFileEnum" ; IS5 only
810 "ComponentFileInfo" ; IS5 only
811 "ComponentFilterLanguage" ; IS5 only
812 "ComponentFilterOS" ; IS5 only
813 "ComponentGetData" ; IS5 only
814 "ComponentGetItemInfo" ; IS3 only
815 "ComponentGetItemSize" ; differs between IS3 and IS5
816 "ComponentIsItemSelected" ; differs between IS3 and IS5
817 "ComponentListItems"
818 "ComponentMoveData" ; IS5 only
819 "ComponentSelectItem" ; differs between IS3 and IS5
820 "ComponentSetData" ; IS5 only
821 "ComponentSetItemInfo" ; IS3 only
822 "ComponentSetTarget" ; IS5 only
823 "ComponentSetupTypeEnum" ; IS5 only
824 "ComponentSetupTypeGetData" ; IS5 only
825 "ComponentSetupTypeSet" ; IS5 only
826 "ComponentTotalSize"
827 "ComponentValidate" ; IS5 only
828 "CompressAdd" ; IS3 only
829 "CompressDel" ; IS3 only
830 "CompressEnum" ; IS3 only
831 "CompressGet" ; IS3 only
832 "CompressInfo" ; IS3 only
833 "CopyFile"
834 "CreateDir"
835 "CreateFile"
836 "CreateProgramFolder"
837 "DeinstallSetReference" ; IS5 only
838 "DeinstallStart"
839 "Delay"
840 "DeleteDir"
841 "DeleteFile"
842 "DialogSetInfo"
843 "Disable"
844 "DoInstall"
845 "Do"
846 "Enable"
847 "EnterDisk"
848 "ExistsDir"
849 "ExistsDisk"
850 "ExitProgMan"
851 "EzBatchAddPath"
852 "EzBatchAddString"
853 "EzBatchReplace"
854 "EzConfigAddDriver"
855 "EzConfigAddString"
856 "EzConfigGetValue"
857 "EzConfigSetValue"
858 "EzDefineDialog"
859 "FileCompare"
860 "FileDeleteLine"
861 "FileGrep"
862 "FileInsertLine"
863 "FileSetBeginDefine" ; IS3 only
864 "FileSetEndDefine" ; IS3 only
865 "FileSetPerformEz" ; IS3 only
866 "FileSetPerform" ; IS3 only
867 "FileSetReset" ; IS3 only
868 "FileSetRoot" ; IS3 only
869 "FindAllDirs"
870 "FindAllFiles"
871 "FindFile"
872 "FindWindow"
873 "GetDiskSpace"
874 "GetDisk"
875 "GetEnvVar"
876 "GetExtents"
877 "GetFileInfo"
878 "GetLine"
879 "GetProfInt"
880 "GetProfString"
881 "GetSystemInfo"
882 "GetValidDrivesList"
883 "GetVersion"
884 "GetWindowHandle"
885 "InstallationInfo"
886 "Is"
887 "LaunchApp"
888 "LaunchAppAndWait"
889 "ListAddItem"
890 "ListAddString"
891 "ListCount"
892 "ListCreate"
893 "ListDestroy"
894 "ListFindItem"
895 "ListFindString"
896 "ListGetFirstItem"
897 "ListGetFirstString"
898 "ListGetNextItem"
899 "ListGetNextString"
900 "ListReadFromFile"
901 "ListSetCurrentItem"
902 "ListSetNextItem"
903 "ListSetNextString"
904 "ListSetIndex"
905 "ListWriteToFile"
906 "LongPathToQuote"
907 "LongPathToShortPath"
908 "MessageBox"
909 "NumToStr"
910 "OpenFileMode"
911 "OpenFile"
912 "ParsePath"
913 "PathAdd"
914 "PathDelete"
915 "PathFind"
916 "PathGet"
917 "PathMove"
918 "PathSet"
919 "Path"
920 "PlaceBitmap"
921 "PlaceWindow"
922 "PlayMMedia" ; IS5 only
923 "ProgDefGroupType"
924 "RegDBCreateKeyEx"
925 "RegDBDeleteValue"
926 "RegDBGetItem"
927 "RegDBKeyExist"
928 "RegDBSetItem"
929 "RegDBGetKeyValueEx"
930 "RegDBSetKeyValueEx"
931 "RegDBSetDefaultRoot"
932 "RenameFile"
933 "ReplaceFolderIcon"
934 "ReplaceProfString"
935 "SdAskDestPath"
936 "SdAskOptions"
937 "SdAskOptionsList"
938 "SdBitmap"
939 "SdCloseDlg"
940 "SdComponentAdvCheckSpace"
941 "SdComponentAdvInit"
942 "SdComponentAdvUpdateSpace"
943 "SdComponentDialog"
944 "SdComponentDialog2"
945 "SdComponentDialogAdv"
946 "SdComponentDialogEx"
947 "SdComponentDlgCheckSpace"
948 "SdComponentMult"
949 "SdConfirmNewDir"
950 "SdConfirmRegistration"
951 "SdDiskSpace"
952 "SdDisplayTopics"
953 "SdDoStdButton"
954 "SdEnablement"
955 "SdError"
956 "SdFinish"
957 "SdFinishInit32"
958 "SdFinishReboot"
959 "SdGeneralInit"
960 "SdGetItemName"
961 "SdGetTextExtent"
962 "SdGetUserCompanyInfo"
963 "SdInit"
964 "SdIsShellExplorer"
965 "SdIsStdButton"
966 "SdLicense"
967 "SdMakeName"
968 "SdOptionInit"
969 "SdOptionSetState"
970 "SdOptionsButtons"
971 "SdOptionsButtonsInit"
972 "SdPlugInProductName"
973 "SdProductName"
974 "SdRegEnableButton"
975 "SdRegExEnableButton"
976 "SdRegisterUser"
977 "SdRegisterUserEx"
978 "SdRemoveEndSpace"
979 "SdSelectFolder"
980 "SdSetSequentialItems"
981 "SdSetStatic"
982 "SdSetupTypeEx" ; IS5 only
983 "SdSetupType"
984 "SdShowAnyDialog"
985 "SdShowDlgEdit1"
986 "SdShowDlgEdit2"
987 "SdShowDlgEdit3"
988 "SdShowFileMods"
989 "SdShowInfoList"
990 "SdShowMsg"
991 "SdStartCopy"
992 "SdUnInit"
993 "SdUpdateComponentSelection"
994 "SdWelcome"
995 "SendMessage"
996 "SetColor"
997 "SetFont"
998 "SetDialogTitle"
999 "SetDisplayEffect" ; IS5 only
1000 "SetFileInfo"
1001 "SetForegroundWindow"
1002 "SetStatusWindow"
1003 "SetTitle"
1004 "SetupType"
1005 "ShowProgramFolder"
1006 "Split" ; IS3 only
1007 "SprintfBox"
1008 "Sprintf"
1009 "StatusUpdate"
1010 "StrCompare"
1011 "StrFind"
1012 "StrGetTokens"
1013 "StrLength"
1014 "StrRemoveLastSlash"
1015 "StrToLower"
1016 "StrToNum"
1017 "StrToUpper"
1018 "StrSub"
1019 "VarRestore"
1020 "VarSave"
1021 "VerCompare"
1022 "VerGetFileVersion"
1023 "WaitOnDialog"
1024 "Welcome"
1025 "WriteLine"
1026 "WriteProfString"
1027 "XCopyFile")
1028 "System functions defined in InstallShield 3 and 5.")
1030 (defconst installshield-system-variables-list
1031 '("BATCH_INSTALL"
1032 "CMDLINE"
1033 "COMMONFILES"
1034 "CORECOMPONENTHANDLING"
1035 "DIALOGCACHE"
1036 "ERRORFILENAME"
1037 "FOLDER_DESKTOP"
1038 "FOLDER_PROGRAMS"
1039 "FOLDER_STARTMENU"
1040 "FOLDER_STARTUP"
1041 "INFOFILENAME"
1042 "ISRES"
1043 "ISUSER"
1044 "ISVERSION"
1045 "MEDIA"
1046 "MODE"
1047 "PROGRAMFILES"
1048 "SELECTED_LANGUAGE"
1049 "SRCDIR"
1050 "SRCDISK"
1051 "SUPPORTDIR"
1052 "TARGETDIR"
1053 "TARGETDISK"
1054 "UNINST"
1055 "WINDIR"
1056 "WINDISK"
1057 "WINMAJOR"
1058 "WINSYSDIR"
1059 "WINSYSDISK")
1060 "System variables used in InstallShield 3 and 5.")
1062 (defconst installshield-types-list
1063 '("BOOL"
1064 "BYREF"
1065 "CHAR"
1066 "HIWORD"
1067 "HWND"
1068 "INT"
1069 "LIST"
1070 "LONG"
1071 "LOWORD"
1072 "LPSTR"
1073 "NUMBER"
1074 "NUMBERLIST"
1075 "POINTER"
1076 "QUAD"
1077 "RGB"
1078 "SHORT"
1079 "STRINGLIST"
1080 "STRING")
1081 "Type keywords used in InstallShield 3 and 5.")
1083 ;;; some might want to skip highlighting these to improve performance
1084 (defconst installshield-funarg-constants-list
1085 '("AFTER"
1086 "APPEND"
1087 "ALLCONTENTS"
1088 "BACKBUTTON"
1089 "BACKGROUNDCAPTION"
1090 "BACKGROUND"
1091 "BACK"
1092 "BASEMEMORY"
1093 "BEFORE"
1094 "BIOS"
1095 "BITMAPICON"
1096 "BK_BLUE"
1097 "BK_GREEN"
1098 "BK_RED"
1099 "BLUE"
1100 "BOOTUPDRIVE"
1101 "CANCEL"
1102 "CDROM_DRIVE"
1103 "CDROM"
1104 "CHECKBOX95"
1105 "CHECKBOX"
1106 "CHECKLINE"
1107 "CHECKMARK"
1108 "COLORS"
1109 "COMMANDEX"
1110 "COMMAND"
1111 "COMP_NORMAL"
1112 "COMP_UPDATE_DATE"
1113 "COMP_UPDATE_SAME"
1114 "COMP_UPDATE_VERSION"
1115 "COMPACT"
1116 "CONTINUE"
1117 "CPU"
1118 "CUSTOM"
1119 "DATE"
1120 "DEFWINDOWMODE"
1121 "DIR_WRITEABLE"
1122 "DIRECTORY"
1123 "DISABLE"
1124 "DISK_TOTALSPACE"
1125 "DISK"
1126 "DLG_OPTIONS"
1127 "DLG_PATH"
1128 "DLG_TEXT"
1129 "DLG_ASK_YESNO"
1130 "DLG_ENTER_DISK"
1131 "DLG_ERR"
1132 "DLG_INFO_ALTIMAGE"
1133 "DLG_INFO_CHECKSELECTION"
1134 "DLG_INFO_KUNITS"
1135 "DLG_INFO_USEDECIMAL"
1136 "DLG_MSG_INFORMATION"
1137 "DLG_MSG_SEVERE"
1138 "DLG_MSG_WARNING"
1139 "DLG_STATUS"
1140 "DLG_WARNING"
1141 "DLG_USER_CAPTION"
1142 "DRIVE"
1143 "ENABLE"
1144 "END_OF_FILE"
1145 "END_OF_LIST"
1146 "ENVSPACE"
1147 "EQUALS"
1148 "EXCLUDE_SUBDIR"
1149 "EXCLUSIVE"
1150 "EXISTS"
1151 "EXIT"
1152 "EXTENDED_MEMORY"
1153 "EXTENSION_ONLY"
1154 "FAILIFEXISTS"
1155 "FALSE"
1156 "FEEDBACK_FULL"
1157 "FILE_ATTR_ARCHIVED"
1158 "FILE_ATTR_DIRECTORY"
1159 "FILE_ATTR_HIDDEN"
1160 "FILE_ATTR_NORMAL"
1161 "FILE_ATTR_READONLY"
1162 "FILE_ATTR_SYSTEM"
1163 "FILE_ATTRIBUTE"
1164 "FILE_DATE"
1165 "FILE_LINE_LENGTH"
1166 "FILE_MODE_APPEND"
1167 "FILE_MODE_BINARYREADONLY"
1168 "FILE_MODE_BINARY"
1169 "FILE_MODE_NORMAL"
1170 "FILE_NO_VERSION"
1171 "FILE_NOT_FOUND"
1172 "FILE_SIZE"
1173 "FILE_TIME"
1174 "FILENAME_ONLY"
1175 "FILENAME"
1176 "FIXED_DRIVE"
1177 "FOLDER_DESKTOP"
1178 "FOLDER_PROGRAMS"
1179 "FOLDER_STARTMENU"
1180 "FOLDER_STARTUP"
1181 "FREEENVSPACE"
1182 "FULLWINDOWMODE"
1183 "FULL"
1184 "FONT_TITLE"
1185 "GREATER_THAN"
1186 "GREEN"
1187 "HKEY_CLASSES_ROOT"
1188 "HKEY_CURRENT_USER"
1189 "HKEY_LOCAL_MACHINE"
1190 "HKEY_USERS"
1191 "HOURGLASS"
1192 "INCLUDE_SUBDIR"
1193 "INDVFILESTATUS"
1194 "INFORMATION"
1195 "IS_WINDOWSNT"
1196 "IS_WINDOWS95"
1197 "IS_WINDOWS"
1198 "IS_WIN32S"
1199 "ISTYPE"
1200 "LANGUAGE_DRV"
1201 "LANGUAGE"
1202 "LESS_THAN"
1203 "LIST_NULL"
1204 "LISTFIRST"
1205 "LISTNEXT"
1206 "LOCKEDFILE"
1207 "LOGGING"
1208 "LOWER_LEFT"
1209 "LOWER_RIGHT"
1210 "MAGENTA"
1211 "MOUSE_DRV"
1212 "MOUSE"
1213 "NETWORK_DRV"
1214 "NETWORK"
1215 "NEXT"
1216 "NONEXCLUSIVE"
1217 "NORMALMODE"
1218 "NOSET"
1219 "NOTEXISTS"
1220 "NOWAIT"
1221 "NO"
1222 "OFF"
1223 "ONLYDIR"
1224 "ON"
1225 "OSMAJOR"
1226 "OSMINOR"
1227 "OS"
1228 "OTHER_FAILURE"
1229 "PARALLEL"
1230 "PARTIAL"
1231 "PATH_EXISTS"
1232 "PATH"
1233 "RED"
1234 "REGDB_APPPATH_DEFAULT"
1235 "REGDB_APPPATH"
1236 "REGDB_BINARY"
1237 "REGDB_ERR_CONNECTIONEXISTS"
1238 "REGDB_ERR_CORRUPTEDREGISTRY"
1239 "REGDB_ERR_INITIALIZATION"
1240 "REGDB_ERR_INVALIDHANDLE"
1241 "REGDB_ERR_INVALIDNAME"
1242 "REGDB_NUMBER"
1243 "REGDB_STRING_EXPAND"
1244 "REGDB_STRING_MULTI"
1245 "REGDB_STRING"
1246 "REGDB_UNINSTALL_NAME"
1247 "REMOTE_DRIVE"
1248 "REMOVEABLE_DRIVE"
1249 "REPLACE_ITEM"
1250 "REPLACE"
1251 "RESET"
1252 "RESTART"
1253 "ROOT"
1254 "SELFREGISTER"
1255 "SERIAL"
1256 "SET"
1257 "SEVERE"
1258 "SHAREDFILE"
1259 "SHARE"
1260 "SILENTMODE"
1261 "SRCTARGETDIR"
1262 "STATUSBAR"
1263 "STATUSDLG"
1264 "STATUSOLD"
1265 "STATUS"
1266 "STYLE_NORMAL"
1267 "SW_MAXIMIZE"
1268 "SW_MINIMIZE"
1269 "SW_RESTORE"
1270 "SW_SHOW"
1271 "SYS_BOOTMACHINE"
1272 "TIME"
1273 "TRUE"
1274 "TYPICAL"
1275 "UPPER_LEFT"
1276 "UPPER_RIGHT"
1277 "VALID_PATH"
1278 "VERSION"
1279 "VIDEO"
1280 "VOLUMELABEL"
1281 "YELLOW"
1282 "YES"
1283 "WAIT"
1284 "WARNING"
1285 "WINMAJOR"
1286 "WINMINOR"
1287 "WIN32SINSTALLED"
1288 "WIN32SMAJOR"
1289 "WIN32SMINOR")
1290 "Function argument constants used in InstallShield 3 and 5."))
1292 ;; c++-mode-syntax-table used to be autoloaded, with an initial nil value.
1293 ;; This file did not load cc-mode, and therefore rul-generic-mode-syntax-table
1294 ;; would have different values according to whether or not cc-mode
1295 ;; happened to be loaded before this file was.
1296 (require 'cc-mode)
1297 (defvar c++-mode-syntax-table)
1299 (defvar rul-generic-mode-syntax-table
1300 (let ((table (make-syntax-table c++-mode-syntax-table)))
1301 (modify-syntax-entry ?\r "> b" table)
1302 (modify-syntax-entry ?\n "> b" table)
1303 (modify-syntax-entry ?/ ". 124b" table)
1304 (modify-syntax-entry ?* ". 23" table)
1305 table)
1306 "Syntax table to use in `rul-generic-mode' buffers.")
1308 ;; here manually instead
1309 (defun generic-rul-mode-setup-function ()
1310 (make-local-variable 'parse-sexp-ignore-comments)
1311 (make-local-variable 'comment-start)
1312 (make-local-variable 'comment-start-skip)
1313 (make-local-variable 'comment-end)
1314 (setq imenu-generic-expression
1315 '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1))
1316 parse-sexp-ignore-comments t
1317 comment-end "*/"
1318 comment-start "/*"
1319 ;;; comment-end ""
1320 ;;; comment-start "//"
1321 ;;; comment-start-skip ""
1323 ;; (set-syntax-table rul-generic-mode-syntax-table)
1324 (setq-local font-lock-syntax-table rul-generic-mode-syntax-table))
1326 ;; moved mode-definition behind defun-definition to be warning-free - 15.11.02/RSan
1327 (define-generic-mode rul-generic-mode
1328 ;; Using "/*" and "*/" doesn't seem to be working right
1329 '("//" ("/*" . "*/" ))
1330 (eval-when-compile installshield-statement-keyword-list)
1331 (eval-when-compile
1332 (list
1333 ;; preprocessor constructs
1334 '("#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)"
1335 1 font-lock-string-face)
1336 '("#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
1337 (1 font-lock-constant-face)
1338 (2 font-lock-variable-name-face nil t))
1339 ;; indirect string constants
1340 '("\\(@[A-Za-z][A-Za-z0-9_]+\\)" 1 font-lock-builtin-face)
1341 ;; gotos
1342 '("[ \t]*\\(\\sw+:\\)" 1 font-lock-constant-face)
1343 '("\\<\\(goto\\)\\>[ \t]*\\(\\sw+\\)?"
1344 (1 font-lock-keyword-face)
1345 (2 font-lock-constant-face nil t))
1346 ;; system variables
1347 (list (concat "[^_]"
1348 (regexp-opt installshield-system-variables-list 'symbols)
1349 "[^_]")
1350 1 font-lock-variable-name-face)
1351 ;; system functions
1352 (list (concat "[^_]"
1353 (regexp-opt installshield-system-functions-list 'symbols)
1354 "[^_]")
1355 1 font-lock-function-name-face)
1356 ;; type keywords
1357 (list (concat "[^_]"
1358 (regexp-opt installshield-types-list 'symbols)
1359 "[^_]")
1360 1 font-lock-type-face)
1361 ;; function argument constants
1362 (list (concat "[^_]"
1363 (regexp-opt installshield-funarg-constants-list 'symbols)
1364 "[^_]")
1365 1 font-lock-variable-name-face))) ; is this face the best choice?
1366 '("\\.[rR][uU][lL]\\'")
1367 '(generic-rul-mode-setup-function)
1368 "Generic mode for InstallShield RUL files.")
1370 (define-skeleton rul-if
1371 "Insert an if statement."
1372 "condition: "
1373 "if(" str ") then" \n
1374 > _ \n
1375 ( "other condition, %s: "
1376 > "elseif(" str ") then" \n
1377 > \n)
1378 > "else" \n
1379 > \n
1380 resume:
1381 > "endif;")
1383 (define-skeleton rul-function
1384 "Insert a function statement."
1385 "function: "
1386 "function " str " ()" \n
1387 ( "local variables, %s: "
1388 > " " str ";" \n)
1389 > "begin" \n
1390 > _ \n
1391 resume:
1392 > "end;"))
1394 ;; Additions by ACorreir@pervasive-sw.com (Alfred Correira)
1395 (when (memq 'mailrc-generic-mode generic-extras-enable-list)
1397 (define-generic-mode mailrc-generic-mode
1398 '(?#)
1399 '("alias"
1400 "else"
1401 "endif"
1402 "group"
1403 "if"
1404 "ignore"
1405 "set"
1406 "source"
1407 "unset")
1408 '(("^\\s-*\\(alias\\|group\\)\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1409 (2 font-lock-constant-face)
1410 (3 font-lock-variable-name-face))
1411 ("^\\s-*\\(unset\\|set\\|ignore\\)\\s-+\\([-A-Za-z0-9_]+\\)=?\\([^\n\r#]*\\)\\(#.*\\)?$"
1412 (2 font-lock-constant-face)
1413 (3 font-lock-variable-name-face))
1414 ("^\\s-*\\(source\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$"
1415 (2 font-lock-variable-name-face)))
1416 '("\\.mailrc\\'")
1418 "Mode for mailrc files."))
1420 ;; Inetd.conf
1421 (when (memq 'inetd-conf-generic-mode generic-extras-enable-list)
1423 (define-generic-mode inetd-conf-generic-mode
1424 '(?#)
1425 '("stream"
1426 "dgram"
1427 "tcp"
1428 "udp"
1429 "wait"
1430 "nowait"
1431 "internal")
1432 '(("^\\([-A-Za-z0-9_]+\\)" 1 font-lock-type-face))
1433 '("/etc/inetd.conf\\'")
1434 (list
1435 (function
1436 (lambda ()
1437 (setq imenu-generic-expression
1438 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1440 ;; Services
1441 (when (memq 'etc-services-generic-mode generic-extras-enable-list)
1443 (define-generic-mode etc-services-generic-mode
1444 '(?#)
1445 '("tcp"
1446 "udp"
1447 "ddp")
1448 '(("^\\([-A-Za-z0-9_]+\\)\\s-+\\([0-9]+\\)/"
1449 (1 font-lock-type-face)
1450 (2 font-lock-variable-name-face)))
1451 '("/etc/services\\'")
1452 (list
1453 (function
1454 (lambda ()
1455 (setq imenu-generic-expression
1456 '((nil "^\\([-A-Za-z0-9_]+\\)" 1))))))))
1458 ;; Password and Group files
1459 (when (memq 'etc-passwd-generic-mode generic-extras-enable-list)
1461 (define-generic-mode etc-passwd-generic-mode
1462 nil ;; No comment characters
1463 '("root") ;; Only one keyword
1464 (eval-when-compile
1465 (list
1466 (list
1467 (concat
1469 ;; User name -- Never blank!
1470 "\\([^:]+\\)"
1472 ;; Password, UID and GID
1473 (mapconcat
1474 'identity
1475 (make-list 3 "\\([^:]+\\)")
1476 ":")
1478 ;; GECOS/Name -- might be blank
1479 "\\([^:]*\\)"
1481 ;; Home directory and shell
1482 "\\([^:]+\\)"
1483 ":?"
1484 "\\([^:]*\\)"
1485 "$")
1486 '(1 font-lock-type-face)
1487 '(5 font-lock-variable-name-face)
1488 '(6 font-lock-constant-face)
1489 '(7 font-lock-warning-face))
1490 '("^\\([^:]+\\):\\([^:]*\\):\\([0-9]+\\):\\(.*\\)$"
1491 (1 font-lock-type-face)
1492 (4 font-lock-variable-name-face))))
1493 '("/etc/passwd\\'" "/etc/group\\'")
1494 (list
1495 (function
1496 (lambda ()
1497 (setq imenu-generic-expression
1498 '((nil "^\\([-A-Za-z0-9_]+\\):" 1))))))))
1500 ;; Fstab
1501 (when (memq 'etc-fstab-generic-mode generic-extras-enable-list)
1503 (define-generic-mode etc-fstab-generic-mode
1504 '(?#)
1505 '("adfs"
1506 "affs"
1507 "autofs"
1508 "coda"
1509 "coherent"
1510 "cramfs"
1511 "devpts"
1512 "efs"
1513 "ext2"
1514 "ext3"
1515 "ext4"
1516 "hfs"
1517 "hpfs"
1518 "iso9660"
1519 "jfs"
1520 "minix"
1521 "msdos"
1522 "ncpfs"
1523 "nfs"
1524 "ntfs"
1525 "proc"
1526 "qnx4"
1527 "reiserfs"
1528 "romfs"
1529 "smbfs"
1530 "cifs"
1531 "usbdevfs"
1532 "sysv"
1533 "sysfs"
1534 "tmpfs"
1535 "udf"
1536 "ufs"
1537 "umsdos"
1538 "vfat"
1539 "xenix"
1540 "xfs"
1541 "swap"
1542 "auto"
1543 "ignore")
1544 '(("^\\([^# \t]+\\)\\s-+\\([^# \t]+\\)"
1545 (1 font-lock-type-face t)
1546 (2 font-lock-variable-name-face t)))
1547 '("/etc/[v]*fstab\\'")
1548 (list
1549 (function
1550 (lambda ()
1551 (setq imenu-generic-expression
1552 '((nil "^\\([^# \t]+\\)\\s-+" 1))))))))
1554 ;; /etc/sudoers
1555 (when (memq 'etc-sudoers-generic-mode generic-extras-enable-list)
1557 (define-generic-mode etc-sudoers-generic-mode
1558 '(?#)
1559 '("User_Alias" "Runas_Alias" "Host_Alias" "Cmnd_Alias"
1560 "NOPASSWD" "PASSWD" "NOEXEC" "EXEC"
1561 "ALL")
1562 '(("\\<\\(root\\|su\\)\\>" 1 font-lock-warning-face)
1563 ("\\(\\*\\)" 1 font-lock-warning-face)
1564 ("\\<\\(%[A-Za-z0-9_]+\\)\\>" 1 font-lock-variable-name-face))
1565 '("/etc/sudoers\\'")
1567 "Generic mode for sudoers configuration files."))
1569 ;; From Jacques Duthen <jacques.duthen@sncf.fr>
1570 (when (memq 'show-tabs-generic-mode generic-extras-enable-list)
1572 (eval-when-compile
1574 (defconst show-tabs-generic-mode-font-lock-defaults-1
1575 '(;; trailing spaces must come before...
1576 ("[ \t]+$" . 'show-tabs-space)
1577 ;; ...embedded tabs
1578 ("[^\n\t]\\(\t+\\)" (1 'show-tabs-tab))))
1580 (defconst show-tabs-generic-mode-font-lock-defaults-2
1581 '(;; trailing spaces must come before...
1582 ("[ \t]+$" . 'show-tabs-space)
1583 ;; ...tabs
1584 ("\t+" . 'show-tabs-tab))))
1586 (defface show-tabs-tab
1587 '((((class grayscale) (background light)) (:background "DimGray" :weight bold))
1588 (((class grayscale) (background dark)) (:background "LightGray" :weight bold))
1589 (((class color) (min-colors 88)) (:background "red1"))
1590 (((class color)) (:background "red"))
1591 (t (:weight bold)))
1592 "Font Lock mode face used to highlight TABs."
1593 :group 'generic-x)
1595 (defface show-tabs-space
1596 '((((class grayscale) (background light)) (:background "DimGray" :weight bold))
1597 (((class grayscale) (background dark)) (:background "LightGray" :weight bold))
1598 (((class color) (min-colors 88)) (:background "yellow1"))
1599 (((class color)) (:background "yellow"))
1600 (t (:weight bold)))
1601 "Font Lock mode face used to highlight spaces."
1602 :group 'generic-x)
1604 (define-generic-mode show-tabs-generic-mode
1605 nil ;; no comment char
1606 nil ;; no keywords
1607 (eval-when-compile show-tabs-generic-mode-font-lock-defaults-1)
1608 nil ;; no auto-mode-alist
1609 ;; '(show-tabs-generic-mode-hook-fun)
1611 "Generic mode to show tabs and trailing spaces."))
1613 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1614 ;; DNS modes
1615 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1617 (when (memq 'named-boot-generic-mode generic-extras-enable-list)
1619 (define-generic-mode named-boot-generic-mode
1620 ;; List of comment characters
1621 '(?\;)
1622 ;; List of keywords
1623 '("cache" "primary" "secondary" "forwarders" "limit" "options"
1624 "directory" "check-names")
1625 ;; List of additional font-lock-expressions
1626 '(("\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)" 1 font-lock-constant-face)
1627 ("^directory\\s-+\\(.*\\)" 1 font-lock-variable-name-face)
1628 ("^\\(primary\\|cache\\)\\s-+\\([.A-Za-z]+\\)\\s-+\\(.*\\)"
1629 (2 font-lock-variable-name-face)
1630 (3 font-lock-constant-face)))
1631 ;; List of additional automode-alist expressions
1632 '("/etc/named.boot\\'")
1633 ;; List of set up functions to call
1634 nil))
1636 (when (memq 'named-database-generic-mode generic-extras-enable-list)
1638 (define-generic-mode named-database-generic-mode
1639 ;; List of comment characters
1640 '(?\;)
1641 ;; List of keywords
1642 '("IN" "NS" "CNAME" "SOA" "PTR" "MX" "A")
1643 ;; List of additional font-lock-expressions
1644 '(("\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)" 1 font-lock-constant-face)
1645 ("^\\([.A-Za-z0-9]+\\)" 1 font-lock-variable-name-face))
1646 ;; List of additional auto-mode-alist expressions
1648 ;; List of set up functions to call
1649 nil)
1651 (defvar named-database-time-string "%Y%m%d%H"
1652 "Timestring for named serial numbers.")
1654 (defun named-database-print-serial ()
1655 "Print a serial number based on the current date."
1656 (interactive)
1657 (insert (format-time-string named-database-time-string))))
1659 (when (memq 'resolve-conf-generic-mode generic-extras-enable-list)
1661 (define-generic-mode resolve-conf-generic-mode
1662 ;; List of comment characters
1663 '(?#)
1664 ;; List of keywords
1665 '("nameserver" "domain" "search" "sortlist" "options")
1666 ;; List of additional font-lock-expressions
1668 ;; List of additional auto-mode-alist expressions
1669 '("/etc/resolv[e]?.conf\\'")
1670 ;; List of set up functions to call
1671 nil))
1673 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1674 ;; Modes for spice and common electrical engineering circuit netlist formats
1675 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1677 (when (memq 'spice-generic-mode generic-extras-enable-list)
1679 (define-generic-mode spice-generic-mode
1681 '("and"
1682 "cccs"
1683 "ccvs"
1684 "delay"
1685 "nand"
1686 "nor"
1687 "npwl"
1688 "or"
1689 "par"
1690 "ppwl"
1691 "pwl"
1692 "vccap"
1693 "vccs"
1694 "vcr"
1695 "vcvs")
1696 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face)
1697 (" \\(\\$ .*\\)$" 1 font-lock-comment-face)
1698 ("^\\(\\$ .*\\)$" 1 font-lock-comment-face)
1699 ("\\([*].*\\)" 1 font-lock-comment-face)
1700 ("^\\([+]\\)" 1 font-lock-string-face)
1701 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face)
1702 ("\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face)
1703 ("\\('[^']+'\\)" 1 font-lock-string-face)
1704 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face))
1705 '("\\.[sS][pP]\\'"
1706 "\\.[sS][pP][iI]\\'"
1707 "\\.[sS][pP][iI][cC][eE]\\'"
1708 "\\.[iI][nN][cC]\\'")
1709 (list
1710 'generic-bracket-support
1711 ;; Make keywords case-insensitive
1712 (function
1713 (lambda()
1714 (setq font-lock-defaults '(generic-font-lock-keywords nil t)))))
1715 "Generic mode for SPICE circuit netlist files."))
1717 (when (memq 'ibis-generic-mode generic-extras-enable-list)
1719 (define-generic-mode ibis-generic-mode
1720 '(?|)
1722 '(("[[]\\([^]]*\\)[]]" 1 font-lock-keyword-face)
1723 ("\\(\\(_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face))
1724 '("\\.[iI][bB][sS]\\'")
1725 '(generic-bracket-support)
1726 "Generic mode for IBIS circuit netlist files."))
1728 (when (memq 'astap-generic-mode generic-extras-enable-list)
1730 (define-generic-mode astap-generic-mode
1732 '("analyze"
1733 "description"
1734 "elements"
1735 "execution"
1736 "features"
1737 "functions"
1738 "ground"
1739 "model"
1740 "outputs"
1741 "print"
1742 "run"
1743 "controls"
1744 "table")
1745 '(("^\\s-*\\([*].*\\)" 1 font-lock-comment-face)
1746 (";\\s-*\\([*].*\\)" 1 font-lock-comment-face)
1747 ("^\\s-*\\([.]\\w+\\>\\)" 1 font-lock-keyword-face)
1748 ("\\('[^']+'\\)" 1 font-lock-string-face)
1749 ("\\(\"[^\"]+\"\\)" 1 font-lock-string-face)
1750 ("[(,]\\s-*\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 font-lock-variable-name-face))
1751 '("\\.[aA][pP]\\'"
1752 "\\.[aA][sS][xX]\\'"
1753 "\\.[aA][sS][tT][aA][pP]\\'"
1754 "\\.[pP][sS][pP]\\'"
1755 "\\.[dD][eE][cC][kK]\\'"
1756 "\\.[gG][oO][dD][aA][tT][aA]")
1757 (list
1758 'generic-bracket-support
1759 ;; Make keywords case-insensitive
1760 (function
1761 (lambda()
1762 (setq font-lock-defaults '(generic-font-lock-keywords nil t)))))
1763 "Generic mode for ASTAP circuit netlist files."))
1765 (when (memq 'etc-modules-conf-generic-mode generic-extras-enable-list)
1767 (define-generic-mode etc-modules-conf-generic-mode
1768 ;; List of comment characters
1769 '(?#)
1770 ;; List of keywords
1771 '("above"
1772 "alias"
1773 "below"
1774 "define"
1775 "depfile"
1776 "else"
1777 "elseif"
1778 "endif"
1779 "if"
1780 "include"
1781 "insmod_opt"
1782 "install"
1783 "keep"
1784 "options"
1785 "path"
1786 "generic_stringfile"
1787 "pcimapfile"
1788 "isapnpmapfile"
1789 "usbmapfile"
1790 "parportmapfile"
1791 "ieee1394mapfile"
1792 "pnpbiosmapfile"
1793 "probe"
1794 "probeall"
1795 "prune"
1796 "post-install"
1797 "post-remove"
1798 "pre-install"
1799 "pre-remove"
1800 "remove"
1801 "persistdir")
1802 ;; List of additional font-lock-expressions
1804 ;; List of additional automode-alist expressions
1805 '("/etc/modules.conf" "/etc/conf.modules")
1806 ;; List of set up functions to call
1807 nil))
1809 (provide 'generic-x)
1811 ;;; generic-x.el ends here