1 ;;; conf-mode.el --- Simple major mode for editing conf/ini/properties files
3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 ;; Free Software Foundation, Inc.
6 ;; Author: Daniel Pfeiffer <occitan@esperanto.org>
7 ;; Keywords: conf ini windows java
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; This mode is designed to edit many similar varieties of Conf/Ini files and
27 ;; Java properties. It started out from Aurélien Tisné's ini-mode.
28 ;; `conf-space-keywords' were inspired by Robert Fitzgerald's any-ini-mode.
35 (defvar outline-heading-end-regexp
)
40 "Configuration files."
44 (defcustom conf-assignment-column
24
45 "Align assignments to this column by default with \\[conf-align-assignments].
46 If this number is negative, the `=' comes before the whitespace. Use 0 to
47 not align (only setting space according to `conf-assignment-space')."
51 (defcustom conf-javaprop-assignment-column
32
52 "Value for `conf-assignment-column' in Java properties buffers."
56 (defcustom conf-colon-assignment-column
(- (abs conf-assignment-column
))
57 "Value for `conf-assignment-column' in Java properties buffers."
61 (defcustom conf-assignment-space t
62 "Put at least one space around assignments when aligning."
66 (defcustom conf-colon-assignment-space nil
67 "Value for `conf-assignment-space' in colon style Conf mode buffers."
72 (let ((map (make-sparse-keymap))
73 (menu-map (make-sparse-keymap)))
74 (define-key map
"\C-c\C-u" 'conf-unix-mode
)
75 (define-key map
"\C-c\C-w" 'conf-windows-mode
)
76 (define-key map
"\C-c\C-j" 'conf-javaprop-mode
)
77 (define-key map
"\C-c\C-s" 'conf-space-keywords
)
78 (define-key map
"\C-c " 'conf-space-keywords
)
79 (define-key map
"\C-c\C-c" 'conf-colon-mode
)
80 (define-key map
"\C-c:" 'conf-colon-mode
)
81 (define-key map
"\C-c\C-x" 'conf-xdefaults-mode
)
82 (define-key map
"\C-c\C-p" 'conf-ppd-mode
)
83 (define-key map
"\C-c\C-q" 'conf-quote-normal
)
84 (define-key map
"\C-c\"" 'conf-quote-normal
)
85 (define-key map
"\C-c'" 'conf-quote-normal
)
86 (define-key map
"\C-c\C-a" 'conf-align-assignments
)
87 (define-key map
[menu-bar sh-script
] (cons "Conf" menu-map
))
88 (define-key menu-map
[conf-windows-mode
]
89 '(menu-item "Windows mode"
91 :help
"Conf Mode starter for Windows style Conf files"
92 :button
(:radio .
(eq major-mode
'conf-windows-mode
))))
93 (define-key menu-map
[conf-javaprop-mode
]
94 '(menu-item "Java properties mode"
96 :help
"Conf Mode starter for Java properties files"
97 :button
(:radio .
(eq major-mode
'conf-javaprop-mode
))))
98 (define-key menu-map
[conf-space-keywords
]
99 '(menu-item "Space keywords mode..."
101 :help
"Enter Conf Space mode using regexp KEYWORDS to match the keywords"
102 :button
(:radio .
(eq major-mode
'conf-space-keywords
))))
103 (define-key menu-map
[conf-ppd-mode
]
104 '(menu-item "PPD mode"
106 :help
"Conf Mode starter for Adobe/CUPS PPD files"
107 :button
(:radio .
(eq major-mode
'conf-ppd-mode
))))
108 (define-key menu-map
[conf-colon-mode
]
109 '(menu-item "Colon mode"
111 :help
"Conf Mode starter for Colon files"
112 :button
(:radio .
(eq major-mode
'conf-colon-mode
))))
113 (define-key menu-map
[conf-unix-mode
]
114 '(menu-item "Unix mode"
116 :help
"Conf Mode starter for Unix style Conf files"
117 :button
(:radio .
(eq major-mode
'conf-unix-mode
))))
118 (define-key menu-map
[conf-xdefaults-mode
]
119 '(menu-item "Xdefaults mode"
121 :help
"Conf Mode starter for Xdefaults files"
122 :button
(:radio .
(eq major-mode
'conf-xdefaults-mode
))))
123 (define-key menu-map
[c-s0
] '("--"))
124 (define-key menu-map
[conf-quote-normal
]
125 '(menu-item "Set quote syntax normal" conf-quote-normal
126 :help
"Set the syntax of \' and \" to punctuation"))
127 (define-key menu-map
[conf-align-assignments
]
128 '(menu-item "Align assignments" conf-align-assignments
129 :help
"Align assignments"))
131 "Local keymap for `conf-mode' buffers.")
133 (defvar conf-mode-syntax-table
134 (let ((table (make-syntax-table)))
135 (modify-syntax-entry ?
= "." table
)
136 (modify-syntax-entry ?_
"_" table
)
137 (modify-syntax-entry ?-
"_" table
)
138 (modify-syntax-entry ?.
"_" table
)
139 (modify-syntax-entry ?
\' "\"" table
)
140 (modify-syntax-entry ?\
; "<" table)
141 (modify-syntax-entry ?
\n ">" table
)
142 (modify-syntax-entry ?
\r ">" table
)
144 "Syntax table in use in Windows style `conf-mode' buffers.")
146 (defvar conf-unix-mode-syntax-table
147 (let ((table (make-syntax-table conf-mode-syntax-table
)))
148 (modify-syntax-entry ?\
# "<" table
)
150 (modify-syntax-entry ?\
; "." table)
152 "Syntax table in use in Unix style `conf-mode' buffers.")
154 (defvar conf-javaprop-mode-syntax-table
155 (let ((table (make-syntax-table conf-unix-mode-syntax-table
)))
156 (modify-syntax-entry ?
/ ". 124" table
)
157 (modify-syntax-entry ?
* ". 23b" table
)
159 "Syntax table in use in Java prperties buffers.")
161 (defvar conf-ppd-mode-syntax-table
162 (let ((table (make-syntax-table conf-mode-syntax-table
)))
163 (modify-syntax-entry ?
* ". 1" table
)
164 (modify-syntax-entry ?%
". 2" table
)
166 (modify-syntax-entry ?
\' "." table
)
167 (modify-syntax-entry ?\
; "." table)
169 "Syntax table in use in PPD `conf-mode' buffers.")
171 (defvar conf-xdefaults-mode-syntax-table
172 (let ((table (make-syntax-table conf-mode-syntax-table
)))
173 (modify-syntax-entry ?
! "<" table
)
175 (modify-syntax-entry ?\
; "." table)
177 "Syntax table in use in Xdefaults style `conf-mode' buffers.")
180 (defvar conf-font-lock-keywords
181 `(;; [section] (do this first because it may look like a parameter)
182 ("^[ \t]*\\[\\(.+\\)\\]" 1 'font-lock-type-face
)
183 ;; var=val or var[index]=val
184 ("^[ \t]*\\(.+?\\)\\(?:\\[\\(.*?\\)\\]\\)?[ \t]*="
185 (1 'font-lock-variable-name-face
)
186 (2 'font-lock-constant-face nil t
))
187 ;; section { ... } (do this last because some assign ...{...)
188 ("^[ \t]*\\([^=:\n]+?\\)[ \t\n]*{[^{}]*?$" 1 'font-lock-type-face prepend
))
189 "Keywords to hilight in Conf mode.")
191 (defvar conf-javaprop-font-lock-keywords
193 ("^[ \t]*\\(.+?\\)\\(?:\\.\\([0-9]+\\)\\(?:\\.\\(.+?\\)\\(?:\\.\\([0-9]+\\)\\(?:\\.\\(.+?\\)\\(?:\\.\\([0-9]+\\)\\(\\..+?\\)?\\)?\\)?\\)?\\)?\\)?\\([:= \t]\\|$\\)"
194 (1 'font-lock-variable-name-face
)
195 (2 'font-lock-constant-face nil t
)
196 (3 'font-lock-variable-name-face nil t
)
197 (4 'font-lock-constant-face nil t
)
198 (5 'font-lock-variable-name-face nil t
)
199 (6 'font-lock-constant-face nil t
)
200 (7 'font-lock-variable-name-face nil t
)))
201 "Keywords to hilight in Conf Java Properties mode.")
203 (defvar conf-space-keywords-alist
204 '(("\\`/etc/gpm/" .
"key\\|name\\|foreground\\|background\\|border\\|head")
205 ("\\`/etc/magic\\'" .
"[^ \t]+[ \t]+\\(?:[bl]?e?\\(?:short\\|long\\)\\|byte\\|string\\)[^ \t]*")
206 ("/mod\\(?:ules\\|probe\\)\\.conf" .
"alias\\|in\\(?:clude\\|stall\\)\\|options\\|remove")
207 ("/manpath\\.config" .
"MAN\\(?:DATORY_MANPATH\\|PATH_MAP\\|DB_MAP\\)")
208 ("/sensors\\.conf" .
"chip\\|bus\\|label\\|compute\\|set\\|ignore")
209 ("/sane\\(\\.d\\)?/" .
"option\\|device\\|port\\|usb\\|sc\\(?:si\\|anner\\)")
210 ("/resmgr\\.conf" .
"class\\|add\\|allow\\|deny")
211 ("/dictionary\\.lst\\'" .
"DICT\\|HYPH\\|THES")
212 ("/tuxracer/options" .
"set"))
213 "File-name-based settings for the variable `conf-space-keywords'.")
215 (defvar conf-space-keywords nil
216 "Regexps for functions that may come before a space assignment.
217 This allows constructs such as
219 This variable is best set in the file local variables, or through
220 `conf-space-keywords-alist'.")
221 (put 'conf-space-keywords
'safe-local-variable
'stringp
)
223 (defvar conf-space-font-lock-keywords
224 `(;; [section] (do this first because it may look like a parameter)
225 ("^[ \t]*\\[\\(.+\\)\\]" 1 'font-lock-type-face
)
226 ;; section { ... } (do this first because it looks like a parameter)
227 ("^[ \t]*\\(.+?\\)[ \t\n]*{[^{}]*?$" 1 'font-lock-type-face
)
229 (eval if conf-space-keywords
230 (list (concat "^[ \t]*\\(" conf-space-keywords
"\\)[ \t]+\\([^\000- ]+\\)")
231 '(1 'font-lock-keyword-face
)
232 '(2 'font-lock-variable-name-face
))
233 '("^[ \t]*\\([^\000- ]+\\)" 1 'font-lock-variable-name-face
)))
234 "Keywords to highlight in Conf Space mode.")
236 (defvar conf-colon-font-lock-keywords
237 `(;; [section] (do this first because it may look like a parameter)
238 ("^[ \t]*\\[\\(.+\\)\\]" 1 'font-lock-type-face
)
240 ("^[ \t]*\\(.+?\\)[ \t]*:"
241 (1 'font-lock-variable-name-face
))
242 ;; section { ... } (do this last because some assign ...{...)
243 ("^[ \t]*\\([^:\n]+\\)[ \t\n]*{[^{}]*?$" 1 'font-lock-type-face prepend
))
244 "Keywords to hilight in Conf Colon mode.")
246 (defvar conf-assignment-sign ?
=
247 "Sign used for assignments (char or string).")
249 (defvar conf-assignment-regexp
".+?\\([ \t]*=[ \t]*\\)"
250 "Regexp to recognize assignments.
251 It is anchored after the first sexp on a line. There must be a
252 grouping for the assignment sign, including leading and trailing
256 ;; If anybody can figure out how to get the same effect by configuring
257 ;; `align', I'd be glad to hear.
258 (defun conf-align-assignments (&optional arg
)
260 "Align the assignments in the buffer or active region.
261 In Transient Mark mode, if the mark is active, operate on the
262 contents of the region. Otherwise, operate on the whole buffer."
264 (prefix-numeric-value arg
)
265 conf-assignment-column
))
269 (narrow-to-region (region-beginning) (region-end)))
270 (goto-char (point-min))
272 (let ((cs (comment-beginning))) ; go before comment if within
273 (if cs
(goto-char cs
)))
274 (while (forward-comment 9)) ; max-int?
275 (when (and (not (eobp))
276 (looking-at conf-assignment-regexp
))
277 (goto-char (match-beginning 1))
278 (delete-region (point) (match-end 1))
279 (if conf-assignment-sign
282 (indent-to-column arg
)
283 (or (not conf-assignment-space
)
284 (memq (char-before (point)) '(?\s ?
\t)) (insert ?\s
))
285 (insert conf-assignment-sign
286 (if (and conf-assignment-space
(not (eolp))) ?\s
"")))
287 (insert (if conf-assignment-space ?\s
"") conf-assignment-sign
)
289 (indent-to-column (- arg
))
290 (or (not conf-assignment-space
)
291 (memq (char-before (point)) '(?\s ?
\t)) (insert ?\s
))))
293 (if (>= (current-column) (abs arg
))
295 (indent-to-column (abs arg
))))))
299 (defun conf-quote-normal (arg)
300 "Set the syntax of ' and \" to punctuation.
301 With prefix arg, only do it for ' if 1, or only for \" if 2.
302 This only affects the current buffer. Some conf files use quotes
303 to delimit strings, while others allow quotes as simple parts of
304 the assigned value. In those files font locking will be wrong,
305 and you can correct it with this command. (Some files even do
306 both, i.e. quotes delimit strings, except when they are
307 unbalanced, but hey...)"
309 (let ((table (copy-syntax-table (syntax-table))))
310 (when (or (not arg
) (= (prefix-numeric-value arg
) 1))
311 (modify-syntax-entry ?
\' "." table
))
312 (when (or (not arg
) (= (prefix-numeric-value arg
) 2))
313 (modify-syntax-entry ?
\" "." table
))
314 (set-syntax-table table
)
316 (font-lock-fontify-buffer))))
319 (defun conf-outline-level ()
323 (while (setq pt
(scan-lists pt -
1 1)
325 (scan-error depth
))))
331 "Mode for Unix and Windows Conf files and Java properties.
332 Most conf files know only three kinds of constructs: parameter
333 assignments optionally grouped into sections and comments. Yet
334 there is a great range of variation in the exact syntax of conf
335 files. See below for various wrapper commands that set up the
336 details for some of the most widespread variants.
338 This mode sets up font locking, outline, imenu and it provides
339 alignment support through `conf-align-assignments'. If strings
340 come out wrong, try `conf-quote-normal'.
342 Some files allow continuation lines, either with a backslash at
343 the end of line, or by indenting the next line (further). These
344 constructs cannot currently be recognized.
346 Because of this great variety of nuances, which are often not
347 even clearly specified, please don't expect it to get every file
348 quite right. Patches that clearly identify some special case,
349 without breaking the general ones, are welcome.
351 If instead you start this mode with the generic `conf-mode'
352 command, it will parse the buffer. It will generally well
353 identify the first four cases listed below. If the buffer
354 doesn't have enough contents to decide, this is identical to
355 `conf-windows-mode' on Windows, elsewhere to `conf-unix-mode'.
356 See also `conf-space-mode', `conf-colon-mode', `conf-javaprop-mode',
357 `conf-ppd-mode' and `conf-xdefaults-mode'.
362 ;; `conf-mode' plays two roles: it's the parent of several sub-modes
363 ;; but it's also the function that chooses between those submodes.
364 ;; To tell the difference between those two cases where the function
365 ;; might be called, we check `delay-mode-hooks'.
366 ;; (adopted from tex-mode.el)
367 (if (not delay-mode-hooks
)
368 ;; try to guess sub-mode of conf-mode based on buffer content
369 (let ((unix 0) (win 0) (equal 0) (colon 0) (space 0) (jp 0))
371 (goto-char (point-min))
373 (skip-chars-forward " \t\f")
374 (cond ((eq (char-after) ?\
#) (setq unix
(1+ unix
)))
375 ((eq (char-after) ?\
;) (setq win (1+ win)))
376 ((eq (char-after) ?\
[)) ; nop
378 ((eq (char-after) ?
})) ; nop
379 ;; recognize at most double spaces within names
380 ((looking-at "[^ \t\n=:]+\\(?: ?[^ \t\n=:]+\\)*[ \t]*[=:]")
381 (if (eq (char-before (match-end 0)) ?
=)
382 (setq equal
(1+ equal
))
383 (setq colon
(1+ colon
))))
384 ((looking-at "/[/*]") (setq jp
(1+ jp
)))
385 ((looking-at ".*{")) ; nop
386 ((setq space
(1+ space
))))
389 ((> jp
(max unix win
3)) (conf-javaprop-mode))
390 ((> colon
(max equal space
)) (conf-colon-mode))
391 ((> space
(max equal colon
)) (conf-space-mode))
392 ((or (> win unix
) (and (= win unix
) (eq system-type
'windows-nt
)))
394 (t (conf-unix-mode))))
396 (kill-all-local-variables)
397 (use-local-map conf-mode-map
)
398 (setq major-mode
'conf-mode
400 (set (make-local-variable 'font-lock-defaults
)
401 '(conf-font-lock-keywords nil t nil nil
))
402 ;; Let newcomment.el decide this for itself.
403 ;; (set (make-local-variable 'comment-use-syntax) t)
404 (set (make-local-variable 'parse-sexp-ignore-comments
) t
)
405 (set (make-local-variable 'outline-regexp
)
406 "[ \t]*\\(?:\\[\\|.+[ \t\n]*{\\)")
407 (set (make-local-variable 'outline-heading-end-regexp
)
409 (set (make-local-variable 'outline-level
)
411 (set-syntax-table conf-mode-syntax-table
)
412 (setq imenu-generic-expression
413 '(("Parameters" "^[ \t]*\\(.+?\\)[ \t]*=" 1)
415 (nil "^[ \t]*\\[[ \t]*\\(.+\\)[ \t]*\\]" 1)
417 (nil "^[ \t]*\\([^=:{} \t\n][^=:{}\n]+\\)[ \t\n]*{" 1)))
418 (run-mode-hooks 'conf-mode-hook
)))
420 (defun conf-mode-initialize (comment &optional font-lock
)
421 "Intitializations for sub-modes of conf-mode.
422 COMMENT initializes `comment-start' and `comment-start-skip'.
423 The optional arg FONT-LOCK is the value for FONT-LOCK-KEYWORDS."
424 (set (make-local-variable 'comment-start
) comment
)
425 (set (make-local-variable 'comment-start-skip
)
426 (concat (regexp-quote comment-start
) "+\\s *"))
428 (set (make-local-variable 'font-lock-defaults
)
429 `(,font-lock nil t nil nil
))))
432 (define-derived-mode conf-unix-mode conf-mode
"Conf[Unix]"
433 "Conf Mode starter for Unix style Conf files.
434 Comments start with `#'.
435 For details see `conf-mode'. Example:
437 # Conf mode font-locks this right on Unix and with \\[conf-unix-mode]
444 (conf-mode-initialize "#"))
447 (define-derived-mode conf-windows-mode conf-mode
"Conf[WinIni]"
448 "Conf Mode starter for Windows style Conf files.
449 Comments start with `;'.
450 For details see `conf-mode'. Example:
452 ; Conf mode font-locks this right on Windows and with \\[conf-windows-mode]
454 \[ExtShellFolderViews]
455 Default={5984FFE0-28D4-11CF-AE66-08002B2E1262}
456 {5984FFE0-28D4-11CF-AE66-08002B2E1262}={5984FFE0-28D4-11CF-AE66-08002B2E1262}
458 \[{5984FFE0-28D4-11CF-AE66-08002B2E1262}]
459 PersistMoniker=file://Folder.htt"
460 (conf-mode-initialize ";"))
462 ;; Here are a few more or less widespread styles. There are others, so
463 ;; obscure, they are not covered. E.g. RFC 2614 allows both Unix and Windows
464 ;; comments. Or the donkey has (* Pascal comments *) -- roll your own starter
468 (define-derived-mode conf-javaprop-mode conf-mode
"Conf[JavaProp]"
469 "Conf Mode starter for Java properties files.
470 Comments start with `#' but are also recognized with `//' or
471 between `/*' and `*/'.
472 For details see `conf-mode'. Example:
474 # Conf mode font-locks this right with \\[conf-javaprop-mode] (Java properties)
475 // another kind of comment
484 (conf-mode-initialize "#" 'conf-javaprop-font-lock-keywords
)
485 (set (make-local-variable 'conf-assignment-column
)
486 conf-javaprop-assignment-column
)
487 (set (make-local-variable 'conf-assignment-regexp
)
488 ".+?\\([ \t]*[=: \t][ \t]*\\|$\\)")
489 (setq comment-start-skip
"\\(?:#+\\|/[/*]+\\)\\s *")
490 (setq imenu-generic-expression
491 '(("Parameters" "^[ \t]*\\(.+?\\)[=: \t]" 1))))
494 (define-derived-mode conf-space-mode conf-unix-mode
"Conf[Space]"
495 "Conf Mode starter for space separated conf files.
496 \"Assignments\" are with ` '. Keywords before the parameters are
497 recognized according to the variable `conf-space-keywords-alist'.
498 Alternatively, you can specify a value for the file local variable
499 `conf-space-keywords'.
500 Use the function `conf-space-keywords' if you want to specify keywords
501 in an interactive fashion instead.
503 For details see `conf-mode'. Example:
505 # Conf mode font-locks this right with \\[conf-space-mode] (space separated)
507 image/jpeg jpeg jpg jpe
511 # Or with keywords (from a recognized file name):
513 # Standard multimedia devices
514 add /dev/audio desktop
515 add /dev/mixer desktop"
516 (conf-mode-initialize "#" 'conf-space-font-lock-keywords
)
517 (make-local-variable 'conf-assignment-sign
)
518 (setq conf-assignment-sign nil
)
519 (make-local-variable 'conf-space-keywords
)
520 (cond (buffer-file-name
521 ;; We set conf-space-keywords directly, but a value which is
522 ;; in the local variables list or interactively specified
523 ;; (see the function conf-space-keywords) takes precedence.
524 (setq conf-space-keywords
525 (assoc-default buffer-file-name conf-space-keywords-alist
527 (conf-space-mode-internal)
528 ;; In case the local variables list specifies conf-space-keywords,
529 ;; recompute other things from that afterward.
530 (add-hook 'hack-local-variables-hook
'conf-space-mode-internal nil t
))
533 (defun conf-space-keywords (keywords)
534 "Enter Conf Space mode using regexp KEYWORDS to match the keywords.
535 See `conf-space-mode'."
536 (interactive "sConf Space keyword regexp: ")
539 (if (string-equal keywords
"")
541 (setq conf-space-keywords keywords
)
542 (conf-space-mode-internal)
545 (defun conf-space-mode-internal ()
546 (make-local-variable 'conf-assignment-regexp
)
547 (setq conf-assignment-regexp
548 (if conf-space-keywords
549 (concat "\\(?:" conf-space-keywords
"\\)[ \t]+.+?\\([ \t]+\\|$\\)")
550 ".+?\\([ \t]+\\|$\\)"))
551 ;; If Font Lock is already enabled, reenable it with new
552 ;; conf-assignment-regexp.
553 (when (and font-lock-mode
554 (boundp 'font-lock-keywords
)) ;see `normal-mode'
555 (font-lock-add-keywords nil nil
)
557 ;; Copy so that we don't destroy shared structure.
558 (setq imenu-generic-expression
(copy-sequence imenu-generic-expression
))
559 ;; Get rid of any existing Parameters element.
560 (setq imenu-generic-expression
561 (delq (assoc "Parameters" imenu-generic-expression
)
562 imenu-generic-expression
))
563 ;; Add a new one based on conf-space-keywords.
564 (setq imenu-generic-expression
566 ,(if conf-space-keywords
567 (concat "^[ \t]*\\(?:" conf-space-keywords
568 "\\)[ \t]+\\([^ \t\n]+\\)\\(?:[ \t]\\|$\\)")
569 "^[ \t]*\\([^ \t\n[]+\\)\\(?:[ \t]\\|$\\)")
571 imenu-generic-expression
)))
574 (define-derived-mode conf-colon-mode conf-unix-mode
"Conf[Colon]"
575 "Conf Mode starter for Colon files.
576 \"Assignments\" are with `:'.
577 For details see `conf-mode'. Example:
579 # Conf mode font-locks this right with \\[conf-colon-mode] (colon)
581 <Multi_key> <exclam> <exclam> : \"\\241\" exclamdown
582 <Multi_key> <c> <slash> : \"\\242\" cent"
583 (conf-mode-initialize "#" 'conf-colon-font-lock-keywords
)
584 (set (make-local-variable 'conf-assignment-space
)
585 conf-colon-assignment-space
)
586 (set (make-local-variable 'conf-assignment-column
)
587 conf-colon-assignment-column
)
588 (set (make-local-variable 'conf-assignment-sign
)
590 (set (make-local-variable 'conf-assignment-regexp
)
591 ".+?\\([ \t]*:[ \t]*\\)")
592 (setq imenu-generic-expression
593 `(("Parameters" "^[ \t]*\\(.+?\\)[ \t]*:" 1)
594 ,@(cdr imenu-generic-expression
))))
597 (define-derived-mode conf-ppd-mode conf-colon-mode
"Conf[PPD]"
598 "Conf Mode starter for Adobe/CUPS PPD files.
599 Comments start with `*%' and \"assignments\" are with `:'.
600 For details see `conf-mode'. Example:
602 *% Conf mode font-locks this right with \\[conf-ppd-mode] (PPD)
604 *DefaultTransfer: Null
605 *Transfer Null.Inverse: \"{ 1 exch sub }\""
606 (conf-mode-initialize "*%")
607 ;; no sections, they match within PostScript code
608 (setq imenu-generic-expression
(list (car imenu-generic-expression
))))
611 (define-derived-mode conf-xdefaults-mode conf-colon-mode
"Conf[Xdefaults]"
612 "Conf Mode starter for Xdefaults files.
613 Comments start with `!' and \"assignments\" are with `:'.
614 For details see `conf-mode'. Example:
616 ! Conf mode font-locks this right with \\[conf-xdefaults-mode] (.Xdefaults)
620 (conf-mode-initialize "!"))
624 ;; arch-tag: 0a3805b2-0371-4d3a-8498-8897116b2356
625 ;;; conf-mode.el ends here