Function: conf-mode

conf-mode is an autoloaded, interactive and byte-compiled function defined in conf-mode.el.gz.

Signature

(conf-mode)

Documentation

Mode for Unix and Windows Conf files and Java properties.

Most conf files know only three kinds of constructs: parameter assignments optionally grouped into sections and comments. Yet there is a great range of variation in the exact syntax of conf files. See below for various wrapper commands that set up the details for some of the most widespread variants.

This mode sets up font locking, outline, imenu and it provides alignment support through conf-align-assignments. If strings come out wrong, try conf-quote-normal.

Some files allow continuation lines, either with a backslash at the end of line, or by indenting the next line (further). These constructs cannot currently be recognized.

Because of this great variety of nuances, which are often not even clearly specified, please don't expect it to get every file quite right. Patches that clearly identify some special case, without breaking the general ones, are welcome.

If instead you start this mode with the generic conf-mode command, it will parse the buffer. It will generally well identify the first four cases listed below. If the buffer doesn't have enough contents to decide, this is identical to conf-windows-mode on Windows, elsewhere to conf-unix-mode. See also conf-space-mode, conf-colon-mode, conf-javaprop-mode, conf-ppd-mode and conf-xdefaults-mode.

C-c " conf-quote-normal
C-c ' conf-quote-normal
C-c : conf-colon-mode
C-c C-a conf-align-assignments
C-c C-c conf-colon-mode
C-c C-j conf-javaprop-mode
C-c C-p conf-ppd-mode
C-c C-q conf-quote-normal
C-c C-s conf-space-keywords(var)/conf-space-keywords(fun)
C-c C-u conf-unix-mode
C-c C-w conf-windows-mode
C-c C-x conf-xdefaults-mode
C-c SPC conf-space-keywords(var)/conf-space-keywords(fun)

This mode runs the hook conf-mode-hook, as the final or penultimate step during initialization.

This function has :around advice: Redirect to one of the submodes when called directly.

Probably introduced at or before Emacs version 22.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/conf-mode.el.gz
;;;###autoload
(define-derived-mode conf-mode nil "Conf[?]"
  "Mode for Unix and Windows Conf files and Java properties.
Most conf files know only three kinds of constructs: parameter
assignments optionally grouped into sections and comments.  Yet
there is a great range of variation in the exact syntax of conf
files.  See below for various wrapper commands that set up the
details for some of the most widespread variants.

This mode sets up font locking, outline, imenu and it provides
alignment support through `conf-align-assignments'.  If strings
come out wrong, try `conf-quote-normal'.

Some files allow continuation lines, either with a backslash at
the end of line, or by indenting the next line (further).  These
constructs cannot currently be recognized.

Because of this great variety of nuances, which are often not
even clearly specified, please don't expect it to get every file
quite right.  Patches that clearly identify some special case,
without breaking the general ones, are welcome.

If instead you start this mode with the generic `conf-mode'
command, it will parse the buffer.  It will generally well
identify the first four cases listed below.  If the buffer
doesn't have enough contents to decide, this is identical to
`conf-windows-mode' on Windows, elsewhere to `conf-unix-mode'.
See also `conf-space-mode', `conf-colon-mode', `conf-javaprop-mode',
`conf-ppd-mode' and `conf-xdefaults-mode'.

\\{conf-mode-map}"

  (setq-local font-lock-defaults '(conf-font-lock-keywords nil t nil nil))
  ;; Let newcomment.el decide this for itself.
  ;; (setq-local comment-use-syntax t)
  (setq-local parse-sexp-ignore-comments t)
  (setq-local outline-regexp "[ \t]*\\(?:\\[\\|.+[ \t\n]*{\\)")
  (setq-local outline-heading-end-regexp "[\n}]")
  (setq-local outline-level #'conf-outline-level)
  (setq-local imenu-generic-expression
	      '(("Parameters" "^[ \t]*\\(.+?\\)[ \t]*=" 1)
                ;; [section]
                (nil "^[ \t]*\\[[ \t]*\\(.+\\)[ \t]*\\]" 1)
                ;; section { ... }
                (nil "^[ \t]*\\([^=:{} \t\n][^=:{}\n]+\\)[ \t\n]*{" 1))))