Mercurial > emacs
annotate lisp/textmodes/conf-mode.el @ 58389:dc700332c8ee
*** empty log message ***
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 21 Nov 2004 03:51:04 +0000 |
parents | 5da080855cb1 |
children | e5f1fb888f0b |
rev | line source |
---|---|
58115
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
1 ;;; conf-mode.el --- Simple major mode for editing conf/ini/properties files |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
2 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
3 ;; Copyright (C) 2004 by Daniel Pfeiffer <occitan@esperanto.org> |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
4 ;; Keywords: conf ini windows java |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
5 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
6 ;; This file is part of GNU Emacs. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
7 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
8 ;; GNU Emacs is free software; you can redistribute it and/or modify |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
9 ;; it under the terms of the GNU General Public License as published by |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
10 ;; the Free Software Foundation; either version 2, or (at your option) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
11 ;; any later version. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
12 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
13 ;; GNU Emacs is distributed in the hope that it will be useful, |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
16 ;; GNU General Public License for more details. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
17 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
18 ;; You should have received a copy of the GNU General Public License |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
19 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
20 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
21 ;; Boston, MA 02111-1307, USA. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
22 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
23 ;;; Commentary: |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
24 ;; |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
25 ;; This mode is designed to edit many similar varieties of Conf/Ini files and |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
26 ;; Java properties. It started out from Aurélien Tisné's ini-mode. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
27 ;; `conf-space-keywords' were inspired by Robert Fitzgerald's any-ini-mode. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
28 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
29 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
30 ;;; Code: |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
31 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
32 (require 'newcomment) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
33 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
34 ;; Variables: |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
35 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
36 (defgroup conf nil |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
37 "Configuration files." |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
38 :group 'data |
58128
5da080855cb1
Emacs 21.4, not 20.4
Daniel Pfeiffer <occitan@esperanto.org>
parents:
58116
diff
changeset
|
39 :version "21.4") |
58115
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
40 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
41 (defcustom conf-assignment-column 24 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
42 "Align assignments to this column by default with \\[conf-align-assignments]. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
43 If this number is negative, the `=' comes before the whitespace. Use 0 to |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
44 not align (only setting space according to `conf-assignment-space')." |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
45 :type 'integer |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
46 :group 'conf) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
47 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
48 (defcustom conf-javaprop-assignment-column 32 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
49 "Value for `conf-assignment-column' in Java properties buffers." |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
50 :type 'integer |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
51 :group 'conf) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
52 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
53 (defcustom conf-colon-assignment-column (- (abs conf-assignment-column)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
54 "Value for `conf-assignment-column' in Java properties buffers." |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
55 :type 'integer |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
56 :group 'conf) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
57 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
58 (defcustom conf-assignment-space t |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
59 "Put at least one space around assignments when aligning." |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
60 :type 'boolean |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
61 :group 'conf) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
62 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
63 (defcustom conf-colon-assignment-space nil |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
64 "Value for `conf-assignment-space' in colon style Conf mode buffers." |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
65 :type 'boolean |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
66 :group 'conf) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
67 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
68 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
69 (defvar conf-mode-map |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
70 (let ((map (make-sparse-keymap))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
71 (define-key map "\C-c\C-u" 'conf-unix-mode) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
72 (define-key map "\C-c\C-w" 'conf-windows-mode) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
73 (define-key map "\C-c\C-j" 'conf-javaprop-mode) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
74 (define-key map "\C-c\C-s" 'conf-space-mode) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
75 (define-key map "\C-c " 'conf-space-mode) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
76 (define-key map "\C-c\C-c" 'conf-colon-mode) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
77 (define-key map "\C-c:" 'conf-colon-mode) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
78 (define-key map "\C-c\C-x" 'conf-xdefaults-mode) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
79 (define-key map "\C-c\C-q" 'conf-quote-normal) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
80 (define-key map "\C-c\"" 'conf-quote-normal) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
81 (define-key map "\C-c'" 'conf-quote-normal) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
82 (define-key map "\C-c\C-a" 'conf-align-assignments) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
83 map) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
84 "Local keymap for conf-mode buffers.") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
85 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
86 (defvar conf-mode-syntax-table |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
87 (let ((table (make-syntax-table))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
88 (modify-syntax-entry ?= "." table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
89 (modify-syntax-entry ?_ "_" table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
90 (modify-syntax-entry ?- "_" table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
91 (modify-syntax-entry ?. "_" table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
92 (modify-syntax-entry ?\' "\"" table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
93 ; (modify-syntax-entry ?: "_" table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
94 (modify-syntax-entry ?\; "<" table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
95 (modify-syntax-entry ?\n ">" table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
96 (modify-syntax-entry ?\r ">" table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
97 table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
98 "Syntax table in use in Windows style conf-mode buffers.") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
99 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
100 (defvar conf-unix-mode-syntax-table |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
101 (let ((table (make-syntax-table conf-mode-syntax-table))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
102 (modify-syntax-entry ?\# "<" table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
103 ;; override |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
104 (modify-syntax-entry ?\; "." table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
105 table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
106 "Syntax table in use in Unix style conf-mode buffers.") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
107 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
108 (defvar conf-javaprop-mode-syntax-table |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
109 (let ((table (make-syntax-table conf-unix-mode-syntax-table))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
110 (modify-syntax-entry ?/ ". 124" table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
111 (modify-syntax-entry ?* ". 23b" table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
112 table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
113 "Syntax table in use in Java prperties buffers.") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
114 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
115 (defvar conf-xdefaults-mode-syntax-table |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
116 (let ((table (make-syntax-table conf-mode-syntax-table))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
117 (modify-syntax-entry ?! "<" table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
118 ;; override |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
119 (modify-syntax-entry ?\; "." table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
120 table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
121 "Syntax table in use in Xdefaults style conf-mode buffers.") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
122 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
123 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
124 (defvar conf-font-lock-keywords |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
125 `(;; [section] (do this first because it may look like a parameter) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
126 ("^[ \t]*\\[\\(.+\\)\\]" 1 'font-lock-type-face) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
127 ;; var=val or var[index]=val |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
128 ("^[ \t]*\\(.+?\\)\\(?:\\[\\(.*?\\)\\]\\)?[ \t]*=" |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
129 (1 'font-lock-variable-name-face) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
130 (2 'font-lock-constant-face nil t)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
131 ;; section { ... } (do this last because some assign ...{...) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
132 ("^[ \t]*\\([^=:\n]+?\\)[ \t\n]*{[^{}]*?$" 1 'font-lock-type-face prepend)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
133 "Keywords to hilight in Conf mode") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
134 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
135 (defvar conf-javaprop-font-lock-keywords |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
136 '(;; var=val |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
137 ("^[ \t]*\\(.+?\\)\\(?:\\.\\([0-9]+\\)\\(?:\\.\\(.+?\\)\\(?:\\.\\([0-9]+\\)\\(?:\\.\\(.+?\\)\\(?:\\.\\([0-9]+\\)\\(\\..+?\\)?\\)?\\)?\\)?\\)?\\)?\\([:= \t]\\|$\\)" |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
138 (1 'font-lock-variable-name-face) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
139 (2 'font-lock-constant-face nil t) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
140 (3 'font-lock-variable-name-face nil t) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
141 (4 'font-lock-constant-face nil t) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
142 (5 'font-lock-variable-name-face nil t) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
143 (6 'font-lock-constant-face nil t) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
144 (7 'font-lock-variable-name-face nil t))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
145 "Keywords to hilight in Conf Java Properties mode") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
146 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
147 (defvar conf-space-keywords-alist |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
148 '(("\\`/etc/gpm/" . "key\\|name\\|foreground\\|background\\|border\\|head") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
149 ("\\`/etc/magic\\'" . "[^ \t]+[ \t]+\\(?:[bl]?e?\\(?:short\\|long\\)\\|byte\\|string\\)[^ \t]*") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
150 ("/mod\\(?:ules\\|probe\\)\\.conf" . "alias\\|in\\(?:clude\\|stall\\)\\|options\\|remove") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
151 ("/manpath\\.config" . "MAN\\(?:DATORY_MANPATH\\|PATH_MAP\\|DB_MAP\\)") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
152 ("/sensors\\.conf" . "chip\\|bus\\|label\\|compute\\|set\\|ignore") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
153 ("/sane\\(\\.d\\)?/" . "option\\|device\\|port\\|usb\\|sc\\(?:si\\|anner\\)") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
154 ("/resmgr\\.conf" . "class\\|add\\|allow\\|deny") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
155 ("/dictionary\\.lst\\'" . "DICT\\|HYPH\\|THES") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
156 ("/tuxracer/options" . "set")) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
157 "File name based settings for `conf-space-keywords'.") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
158 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
159 (defvar conf-space-keywords nil |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
160 "Regexps for functions that may come before a space assignment. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
161 This allows constructs such as |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
162 keyword var value |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
163 This variable is best set in the file local variables, or through |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
164 `conf-space-keywords-alist'.") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
165 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
166 (defvar conf-space-font-lock-keywords |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
167 `(;; [section] (do this first because it may look like a parameter) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
168 ("^[ \t]*\\[\\(.+\\)\\]" 1 'font-lock-type-face) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
169 ;; section { ... } (do this first because it looks like a parameter) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
170 ("^[ \t]*\\(.+?\\)[ \t\n]*{[^{}]*?$" 1 'font-lock-type-face) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
171 ;; var val |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
172 (eval if conf-space-keywords |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
173 (list (concat "^[ \t]*\\(" conf-space-keywords "\\)[ \t]+\\([^\000- ]+\\)") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
174 '(1 'font-lock-keyword-face) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
175 '(2 'font-lock-variable-name-face)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
176 '("^[ \t]*\\([^\000- ]+\\)" 1 'font-lock-variable-name-face))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
177 "Keywords to hilight in Conf Space mode") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
178 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
179 (defvar conf-colon-font-lock-keywords |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
180 `(;; [section] (do this first because it may look like a parameter) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
181 ("^[ \t]*\\[\\(.+\\)\\]" 1 'font-lock-type-face) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
182 ;; var: val |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
183 ("^[ \t]*\\(.+?\\)[ \t]*:" |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
184 (1 'font-lock-variable-name-face)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
185 ;; section { ... } (do this last because some assign ...{...) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
186 ("^[ \t]*\\([^:\n]+\\)[ \t\n]*{[^{}]*?$" 1 'font-lock-type-face prepend)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
187 "Keywords to hilight in Conf Colon mode") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
188 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
189 (defvar conf-assignment-sign ?= |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
190 "What sign is used for assignments.") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
191 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
192 (defvar conf-assignment-regexp ".+?\\([ \t]*=[ \t]*\\)" |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
193 "Regexp to recognize assignments. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
194 It is anchored after the first sexp on a line. There must a |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
195 grouping for the assignment sign, including leading and trailing |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
196 whitespace.") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
197 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
198 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
199 ;; If anybody can figure out how to get the same effect by configuring |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
200 ;; `align', I'd be glad to hear. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
201 (defun conf-align-assignments (&optional arg) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
202 (interactive "P") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
203 (setq arg (if arg |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
204 (prefix-numeric-value arg) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
205 conf-assignment-column)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
206 (save-excursion |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
207 (goto-char (point-min)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
208 (while (not (eobp)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
209 (let ((cs (comment-beginning))) ; go before comment if within |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
210 (if cs (goto-char cs))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
211 (while (forward-comment 9)) ; max-int? |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
212 (when (and (not (eobp)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
213 (looking-at conf-assignment-regexp)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
214 (goto-char (match-beginning 1)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
215 (delete-region (point) (match-end 1)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
216 (if conf-assignment-sign |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
217 (if (>= arg 0) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
218 (progn |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
219 (indent-to-column arg) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
220 (or (not conf-assignment-space) (memq (char-before (point)) '(? ?\t)) (insert ? )) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
221 (insert conf-assignment-sign (if (and conf-assignment-space (not (eolp))) ?\ ""))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
222 (insert (if conf-assignment-space ?\ "") conf-assignment-sign) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
223 (unless (eolp) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
224 (indent-to-column (- arg)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
225 (or (not conf-assignment-space) (memq (char-before (point)) '(? ?\t)) (insert ? )))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
226 (unless (eolp) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
227 (if (>= (current-column) (abs arg)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
228 (insert ? ) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
229 (indent-to-column (abs arg)))))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
230 (forward-line)))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
231 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
232 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
233 (defun conf-quote-normal () |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
234 "Set the syntax of \" and ' to punctuation. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
235 This only affects the current buffer. Some conf files use quotes |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
236 to delimit strings, while others allow quotes as simple parts of |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
237 the assigned value. In those files font locking will be wrong, |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
238 and you can correct it with this command. (Some files even do |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
239 both, i.e. quotes delimit strings, except when they are |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
240 unbalanced, but hey...)" |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
241 (interactive) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
242 (let ((table (copy-syntax-table (syntax-table)))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
243 (modify-syntax-entry ?\" "." table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
244 (modify-syntax-entry ?\' "." table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
245 (set-syntax-table table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
246 (and (boundp 'font-lock-mode) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
247 font-lock-mode |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
248 (font-lock-fontify-buffer)))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
249 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
250 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
251 (defun conf-outline-level () |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
252 (let ((depth 0) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
253 (pt (match-end 0))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
254 (condition-case nil |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
255 (while (setq pt (scan-lists pt -1 1) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
256 depth (1+ depth))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
257 (scan-error depth)))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
258 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
259 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
260 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
261 ;;;###autoload |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
262 (defun conf-mode (&optional comment syntax-table name) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
263 "Mode for Unix and Windows Conf files and Java properties. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
264 Most conf files know only three kinds of constructs: parameter |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
265 assignments optionally grouped into sections and comments. Yet |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
266 there is a great range of variation in the exact syntax of conf |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
267 files. See below for various wrapper commands that set up the |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
268 details for some of the most widespread variants. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
269 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
270 This mode sets up font locking, outline, imenu and it provides |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
271 alignment support through `conf-align-assignments'. If strings |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
272 come out wrong, try `conf-quote-normal'. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
273 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
274 Some files allow continuation lines, either with a backslash at |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
275 the end of line, or by indenting the next line (further). These |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
276 constructs cannot currently be recognized. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
277 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
278 Because of this great variety of nuances, which are often not |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
279 even clearly specified, please don't expect it to get every file |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
280 quite right. Patches that clearly identify some special case, |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
281 without breaking the general ones, are welcome. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
282 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
283 If instead you start this mode with the generic `conf-mode' |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
284 command, it will parse the buffer. It will generally well |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
285 identify the first four cases listed below. If the buffer |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
286 doesn't have enough contents to decide, this is identical to |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
287 `conf-windows-mode' on Windows, elsewhere to `conf-unix-mode'. See |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
288 also `conf-space-mode', `conf-colon-mode', `conf-javaprop-mode' and |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
289 `conf-xdefaults-mode'. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
290 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
291 \\{conf-mode-map}" |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
292 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
293 (interactive) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
294 (if (not comment) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
295 (let ((unix 0) (win 0) (equal 0) (colon 0) (space 0) (jp 0)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
296 (save-excursion |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
297 (goto-char (point-min)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
298 (while (not (eobp)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
299 (skip-chars-forward " \t\f") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
300 (cond ((eq (char-after) ?\#) (setq unix (1+ unix))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
301 ((eq (char-after) ?\;) (setq win (1+ win))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
302 ((eq (char-after) ?\[)) ; nop |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
303 ((eolp)) ; nop |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
304 ((eq (char-after) ?})) ; nop |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
305 ;; recognize at most double spaces within names |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
306 ((looking-at "[^ \t\n=:]+\\(?: ?[^ \t\n=:]+\\)*[ \t]*[=:]") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
307 (if (eq (char-before (match-end 0)) ?=) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
308 (setq equal (1+ equal)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
309 (setq colon (1+ colon)))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
310 ((looking-at "/[/*]") (setq jp (1+ jp))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
311 ((looking-at ".*{")) ; nop |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
312 ((setq space (1+ space)))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
313 (forward-line))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
314 (if (> jp (max unix win 3)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
315 (conf-javaprop-mode) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
316 (if (> colon (max equal space)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
317 (conf-colon-mode) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
318 (if (> space (max equal colon)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
319 (conf-space-mode) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
320 (if (or (> win unix) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
321 (and (= win unix) (eq system-type 'windows-nt))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
322 (conf-windows-mode) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
323 (conf-unix-mode)))))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
324 (kill-all-local-variables) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
325 (use-local-map conf-mode-map) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
326 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
327 (setq major-mode 'conf-mode |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
328 mode-name name) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
329 (set (make-local-variable 'comment-start) comment) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
330 (set (make-local-variable 'comment-start-skip) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
331 (concat comment-start "+\\s *")) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
332 (set (make-local-variable 'comment-use-syntax) t) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
333 (set (make-local-variable 'parse-sexp-ignore-comments) t) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
334 (set (make-local-variable 'outline-regexp) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
335 "[ \t]*\\(?:\\[\\|.+[ \t\n]*{\\)") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
336 (set (make-local-variable 'outline-heading-end-regexp) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
337 "[\n}]") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
338 (set (make-local-variable 'outline-level) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
339 'conf-outline-level) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
340 (set-syntax-table syntax-table) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
341 (setq imenu-generic-expression |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
342 '(("Parameters" "^[ \t]*\\(.+?\\)[ \t]*=" 1) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
343 ;; [section] |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
344 (nil "^[ \t]*\\[[ \t]*\\(.+\\)[ \t]*\\]" 1) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
345 ;; section { ... } |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
346 (nil "^[ \t]*\\([^=:\n]+\\)[ \t\n]*{" 1))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
347 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
348 (run-mode-hooks 'conf-mode-hook))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
349 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
350 ;;;###autoload |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
351 (defun conf-unix-mode () |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
352 "Conf Mode starter for Unix style Conf files. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
353 Comments start with `#'. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
354 For details see `conf-mode'. Example: |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
355 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
356 # Conf mode font-locks this right on Unix and with C-c C-u |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
357 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
358 \[Desktop Entry] |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
359 Encoding=UTF-8 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
360 Name=The GIMP |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
361 Name[ca]=El GIMP |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
362 Name[cs]=GIMP" |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
363 (interactive) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
364 (conf-mode "#" conf-unix-mode-syntax-table "Conf[Unix]")) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
365 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
366 ;;;###autoload |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
367 (defun conf-windows-mode () |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
368 "Conf Mode starter for Windows style Conf files. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
369 Comments start with `;'. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
370 For details see `conf-mode'. Example: |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
371 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
372 ; Conf mode font-locks this right on Windows and with C-c C-w |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
373 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
374 \[ExtShellFolderViews] |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
375 Default={5984FFE0-28D4-11CF-AE66-08002B2E1262} |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
376 {5984FFE0-28D4-11CF-AE66-08002B2E1262}={5984FFE0-28D4-11CF-AE66-08002B2E1262} |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
377 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
378 \[{5984FFE0-28D4-11CF-AE66-08002B2E1262}] |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
379 PersistMoniker=file://Folder.htt" |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
380 (interactive) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
381 (conf-mode ";" conf-mode-syntax-table "Conf[WinIni]")) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
382 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
383 ;; Here are a few more or less widespread styles. There are others, so |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
384 ;; obscure, they are not covered. E.g. RFC 2614 allows both Unix and Windows |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
385 ;; comments. Or the donkey has (* Pascal comments *) -- roll your own starter |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
386 ;; if you need it. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
387 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
388 ;;;###autoload |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
389 (defun conf-javaprop-mode () |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
390 "Conf Mode starter for Java properties files. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
391 Comments start with `#' but are also recognized with `//' or |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
392 between `/*' and `*/'. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
393 For details see `conf-mode'. Example: |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
394 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
395 # Conf mode font-locks this right with C-c C-j (Java properties) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
396 // another kind of comment |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
397 /* yet another */ |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
398 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
399 name:value |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
400 name=value |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
401 name value |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
402 x.1 = |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
403 x.2.y.1.z.1 = |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
404 x.2.y.1.z.2.zz =" |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
405 (interactive) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
406 (conf-mode "#" conf-javaprop-mode-syntax-table "Conf[JavaProp]") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
407 (set (make-local-variable 'conf-assignment-column) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
408 conf-javaprop-assignment-column) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
409 (set (make-local-variable 'conf-assignment-regexp) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
410 ".+?\\([ \t]*[=: \t][ \t]*\\|$\\)") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
411 (set (make-local-variable 'conf-font-lock-keywords) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
412 conf-javaprop-font-lock-keywords) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
413 (setq comment-start-skip "\\(?:#+\\|/[/*]+\\)\\s *") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
414 (setq imenu-generic-expression |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
415 '(("Parameters" "^[ \t]*\\(.+?\\)[=: \t]" 1)))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
416 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
417 ;;;###autoload |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
418 (defun conf-space-mode (&optional keywords) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
419 "Conf Mode starter for space separated conf files. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
420 \"Assignments\" are with ` '. Keywords before the parameters are |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
421 recognized according to `conf-space-keywords'. Interactively |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
422 with a prefix ARG of `0' no keywords will be recognized. With |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
423 any other prefix arg you will be prompted for a regexp to match |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
424 the keywords. Programmatically you can pass such a regexp as |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
425 KEYWORDS, or any non-nil non-string for no keywords. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
426 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
427 For details see `conf-mode'. Example: |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
428 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
429 # Conf mode font-locks this right with C-c C-s (space separated) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
430 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
431 image/jpeg jpeg jpg jpe |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
432 image/png png |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
433 image/tiff tiff tif |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
434 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
435 # Or with keywords (from a recognized file name): |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
436 class desktop |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
437 # Standard multimedia devices |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
438 add /dev/audio desktop |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
439 add /dev/mixer desktop" |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
440 (interactive |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
441 (list (if current-prefix-arg |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
442 (if (> (prefix-numeric-value current-prefix-arg) 0) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
443 (read-string "Regexp to match keywords: ") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
444 t)))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
445 (conf-unix-mode) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
446 (setq mode-name "Conf[Space]") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
447 (set (make-local-variable 'conf-assignment-sign) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
448 nil) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
449 (set (make-local-variable 'conf-font-lock-keywords) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
450 conf-space-font-lock-keywords) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
451 ;; This doesn't seem right, but the next two depend on conf-space-keywords |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
452 ;; being set, while after-change-major-mode-hook might set up imenu, needing |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
453 ;; the following result: |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
454 (hack-local-variables-prop-line) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
455 (hack-local-variables) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
456 (if keywords |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
457 (set (make-local-variable 'conf-space-keywords) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
458 (if (stringp keywords) keywords)) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
459 (or conf-space-keywords |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
460 (not buffer-file-name) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
461 (set (make-local-variable 'conf-space-keywords) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
462 (assoc-default buffer-file-name conf-space-keywords-alist |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
463 'string-match)))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
464 (set (make-local-variable 'conf-assignment-regexp) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
465 (if conf-space-keywords |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
466 (concat "\\(?:" conf-space-keywords "\\)[ \t]+.+?\\([ \t]+\\|$\\)") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
467 ".+?\\([ \t]+\\|$\\)")) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
468 (setq imenu-generic-expression |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
469 `(,@(cdr imenu-generic-expression) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
470 ("Parameters" |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
471 ,(if conf-space-keywords |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
472 (concat "^[ \t]*\\(?:" conf-space-keywords |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
473 "\\)[ \t]+\\([^ \t\n]+\\)\\(?:[ \t]\\|$\\)") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
474 "^[ \t]*\\([^ \t\n[]+\\)\\(?:[ \t]\\|$\\)") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
475 1)))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
476 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
477 ;;;###autoload |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
478 (defun conf-colon-mode (&optional comment syntax-table name) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
479 "Conf Mode starter for Colon files. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
480 \"Assignments\" are with `:'. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
481 For details see `conf-mode'. Example: |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
482 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
483 # Conf mode font-locks this right with C-c C-c (colon) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
484 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
485 <Multi_key> <exclam> <exclam> : \"\\241\" exclamdown |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
486 <Multi_key> <c> <slash> : \"\\242\" cent" |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
487 (interactive) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
488 (if comment |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
489 (conf-mode comment syntax-table name) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
490 (conf-unix-mode) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
491 (setq mode-name "Conf[Colon]")) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
492 (set (make-local-variable 'conf-assignment-space) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
493 conf-colon-assignment-space) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
494 (set (make-local-variable 'conf-assignment-column) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
495 conf-colon-assignment-column) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
496 (set (make-local-variable 'conf-assignment-sign) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
497 ?:) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
498 (set (make-local-variable 'conf-assignment-regexp) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
499 ".+?\\([ \t]*:[ \t]*\\)") |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
500 (set (make-local-variable 'conf-font-lock-keywords) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
501 conf-colon-font-lock-keywords) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
502 (setq imenu-generic-expression |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
503 `(("Parameters" "^[ \t]*\\(.+?\\)[ \t]*:" 1) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
504 ,@(cdr imenu-generic-expression)))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
505 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
506 ;;;###autoload |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
507 (defun conf-xdefaults-mode () |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
508 "Conf Mode starter for Xdefaults files. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
509 Comments start with `!' and \"assignments\" are with `:'. |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
510 For details see `conf-mode'. Example: |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
511 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
512 ! Conf mode font-locks this right with C-c C-x (.Xdefaults) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
513 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
514 *background: gray99 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
515 *foreground: black" |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
516 (interactive) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
517 (conf-colon-mode "!" conf-xdefaults-mode-syntax-table "Conf[Xdefaults]")) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
518 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
519 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
520 ;; font lock support |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
521 (if (boundp 'font-lock-defaults-alist) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
522 (add-to-list |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
523 'font-lock-defaults-alist |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
524 (cons 'conf-mode |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
525 (list 'conf-font-lock-keywords nil t nil nil)))) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
526 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
527 |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
528 (provide 'conf-mode) |
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
529 |
58116
a026512a201c
Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents:
58115
diff
changeset
|
530 ;; arch-tag: 0a3805b2-0371-4d3a-8498-8897116b2356 |
58115
740fbca5078f
*** empty log message ***
Daniel Pfeiffer <occitan@esperanto.org>
parents:
diff
changeset
|
531 ;;; conf-mode.el ends here |