Mercurial > emacs
annotate lisp/progmodes/cc-styles.el @ 53682:7b5a4f5f9b52
*** empty log message ***
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 23 Jan 2004 00:14:48 +0000 |
parents | fae5ff03687a |
children | b7446b6f097d |
rev | line source |
---|---|
18720 | 1 ;;; cc-styles.el --- support for styles in CC Mode |
2 | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
3 ;; Copyright (C) 1985,1987,1992-2003 Free Software Foundation, Inc. |
18720 | 4 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
5 ;; Authors: 1998- Martin Stjernholm |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
6 ;; 1992-1999 Barry A. Warsaw |
18720 | 7 ;; 1987 Dave Detlefs and Stewart Clamen |
8 ;; 1985 Richard M. Stallman | |
24282 | 9 ;; Maintainer: bug-cc-mode@gnu.org |
18720 | 10 ;; Created: 22-Apr-1997 (split from cc-mode.el) |
20147 | 11 ;; Version: See cc-mode.el |
18720 | 12 ;; Keywords: c languages oop |
13 | |
14 ;; This file is part of GNU Emacs. | |
15 | |
16 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
17 ;; it under the terms of the GNU General Public License as published by | |
18 ;; the Free Software Foundation; either version 2, or (at your option) | |
19 ;; any later version. | |
20 | |
21 ;; GNU Emacs is distributed in the hope that it will be useful, | |
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 ;; GNU General Public License for more details. | |
25 | |
26 ;; You should have received a copy of the GNU General Public License | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
27 ;; along with GNU Emacs; see the file COPYING. If not, write to |
36920 | 28 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18720 | 29 ;; Boston, MA 02111-1307, USA. |
30 | |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38167
diff
changeset
|
31 ;;; Commentary: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38167
diff
changeset
|
32 |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38167
diff
changeset
|
33 ;;; Code: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38167
diff
changeset
|
34 |
26817 | 35 (eval-when-compile |
36 (let ((load-path | |
36920 | 37 (if (and (boundp 'byte-compile-dest-file) |
38 (stringp byte-compile-dest-file)) | |
39 (cons (file-name-directory byte-compile-dest-file) load-path) | |
26817 | 40 load-path))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
41 (load "cc-bytecomp" nil t))) |
18720 | 42 |
36920 | 43 (cc-require 'cc-defs) |
44 (cc-require 'cc-vars) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
45 (cc-require 'cc-align) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
46 ;; cc-align is only indirectly required: Styles added with |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
47 ;; `c-add-style' often contains references to functions defined there. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
48 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
49 ;; Silence the compiler. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
50 (cc-bytecomp-defvar adaptive-fill-first-line-regexp) ; Emacs |
24282 | 51 |
18720 | 52 |
51748
f3cad02bce62
(c-style-alist, c-lang-variable-inits, c-lang-variable-inits-tail): The
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
53 (defvar c-style-alist |
18720 | 54 '(("gnu" |
55 (c-basic-offset . 2) | |
56 (c-comment-only-line-offset . (0 . 0)) | |
57 (c-offsets-alist . ((statement-block-intro . +) | |
58 (knr-argdecl-intro . 5) | |
59 (substatement-open . +) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
60 (substatement-label . 0) |
18720 | 61 (label . 0) |
62 (statement-case-open . +) | |
63 (statement-cont . +) | |
64 (arglist-intro . c-lineup-arglist-intro-after-paren) | |
65 (arglist-close . c-lineup-arglist) | |
24282 | 66 (inline-open . 0) |
30400
58d2360c8677
(c-style-alist): The basic offset for the BSD
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
67 (brace-list-open . +) |
18720 | 68 )) |
69 (c-special-indent-hook . c-gnu-impose-minimum) | |
26817 | 70 (c-block-comment-prefix . "") |
18720 | 71 ) |
72 ("k&r" | |
73 (c-basic-offset . 5) | |
74 (c-comment-only-line-offset . 0) | |
75 (c-offsets-alist . ((statement-block-intro . +) | |
76 (knr-argdecl-intro . 0) | |
77 (substatement-open . 0) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
78 (substatement-label . 0) |
18720 | 79 (label . 0) |
80 (statement-cont . +) | |
81 )) | |
82 ) | |
83 ("bsd" | |
30400
58d2360c8677
(c-style-alist): The basic offset for the BSD
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
84 (c-basic-offset . 8) |
18720 | 85 (c-comment-only-line-offset . 0) |
86 (c-offsets-alist . ((statement-block-intro . +) | |
87 (knr-argdecl-intro . +) | |
88 (substatement-open . 0) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
89 (substatement-label . 0) |
18720 | 90 (label . 0) |
91 (statement-cont . +) | |
26817 | 92 (inline-open . 0) |
93 (inexpr-class . 0) | |
18720 | 94 )) |
95 ) | |
96 ("stroustrup" | |
97 (c-basic-offset . 4) | |
98 (c-comment-only-line-offset . 0) | |
99 (c-offsets-alist . ((statement-block-intro . +) | |
100 (substatement-open . 0) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
101 (substatement-label . 0) |
18720 | 102 (label . 0) |
103 (statement-cont . +) | |
104 )) | |
105 ) | |
106 ("whitesmith" | |
107 (c-basic-offset . 4) | |
108 (c-comment-only-line-offset . 0) | |
26817 | 109 (c-offsets-alist . ((knr-argdecl-intro . +) |
18720 | 110 (label . 0) |
111 (statement-cont . +) | |
26817 | 112 (substatement-open . +) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
113 (substatement-label . +) |
26817 | 114 (block-open . +) |
115 (statement-block-intro . c-lineup-whitesmith-in-block) | |
116 (block-close . c-lineup-whitesmith-in-block) | |
117 (inline-open . +) | |
118 (defun-open . +) | |
119 (defun-block-intro . c-lineup-whitesmith-in-block) | |
120 (defun-close . c-lineup-whitesmith-in-block) | |
121 (brace-list-open . +) | |
122 (brace-list-intro . c-lineup-whitesmith-in-block) | |
123 (brace-entry-open . c-indent-multi-line-block) | |
124 (brace-list-close . c-lineup-whitesmith-in-block) | |
125 (class-open . +) | |
126 (inclass . c-lineup-whitesmith-in-block) | |
127 (class-close . +) | |
128 (inexpr-class . 0) | |
129 (extern-lang-open . +) | |
130 (inextern-lang . c-lineup-whitesmith-in-block) | |
131 (extern-lang-close . +) | |
132 (namespace-open . +) | |
133 (innamespace . c-lineup-whitesmith-in-block) | |
134 (namespace-close . +) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
135 (module-open . +) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
136 (inmodule . c-lineup-whitesmith-in-block) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
137 (module-close . +) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
138 (composition-open . +) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
139 (incomposition . c-lineup-whitesmith-in-block) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
140 (composition-close . +) |
18720 | 141 )) |
142 ) | |
143 ("ellemtel" | |
144 (c-basic-offset . 3) | |
145 (c-comment-only-line-offset . 0) | |
146 (c-hanging-braces-alist . ((substatement-open before after))) | |
147 (c-offsets-alist . ((topmost-intro . 0) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
148 (substatement . +) |
18720 | 149 (substatement-open . 0) |
150 (case-label . +) | |
151 (access-label . -) | |
152 (inclass . ++) | |
153 (inline-open . 0) | |
154 )) | |
155 ) | |
156 ("linux" | |
157 (c-basic-offset . 8) | |
158 (c-comment-only-line-offset . 0) | |
159 (c-hanging-braces-alist . ((brace-list-open) | |
24282 | 160 (brace-entry-open) |
18720 | 161 (substatement-open after) |
162 (block-close . c-snug-do-while))) | |
163 (c-cleanup-list . (brace-else-brace)) | |
164 (c-offsets-alist . ((statement-block-intro . +) | |
165 (knr-argdecl-intro . 0) | |
166 (substatement-open . 0) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
167 (substatement-label . 0) |
18720 | 168 (label . 0) |
169 (statement-cont . +) | |
170 )) | |
171 ) | |
172 ("python" | |
173 (indent-tabs-mode . t) | |
26817 | 174 (fill-column . 78) |
18720 | 175 (c-basic-offset . 8) |
176 (c-offsets-alist . ((substatement-open . 0) | |
19807
86412da1174b
(c-style-alist) <python>:, knr-argdecl-intro == +
Richard M. Stallman <rms@gnu.org>
parents:
19376
diff
changeset
|
177 (inextern-lang . 0) |
86412da1174b
(c-style-alist) <python>:, knr-argdecl-intro == +
Richard M. Stallman <rms@gnu.org>
parents:
19376
diff
changeset
|
178 (arglist-intro . +) |
86412da1174b
(c-style-alist) <python>:, knr-argdecl-intro == +
Richard M. Stallman <rms@gnu.org>
parents:
19376
diff
changeset
|
179 (knr-argdecl-intro . +) |
18720 | 180 )) |
181 (c-hanging-braces-alist . ((brace-list-open) | |
182 (brace-list-intro) | |
183 (brace-list-close) | |
24282 | 184 (brace-entry-open) |
18720 | 185 (substatement-open after) |
186 (block-close . c-snug-do-while) | |
187 )) | |
26817 | 188 (c-block-comment-prefix . "") |
18720 | 189 ) |
190 ("java" | |
20918
8e64bd5b1b5f
(c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents:
20147
diff
changeset
|
191 (c-basic-offset . 4) |
18720 | 192 (c-comment-only-line-offset . (0 . 0)) |
19254
81353d4e05b7
(c-styles-alist): In "java" style, set
Richard M. Stallman <rms@gnu.org>
parents:
19212
diff
changeset
|
193 ;; the following preserves Javadoc starter lines |
20918
8e64bd5b1b5f
(c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents:
20147
diff
changeset
|
194 (c-offsets-alist . ((inline-open . 0) |
8e64bd5b1b5f
(c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents:
20147
diff
changeset
|
195 (topmost-intro-cont . +) |
18720 | 196 (statement-block-intro . +) |
197 (knr-argdecl-intro . 5) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
198 (substatement-open . +) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
199 (substatement-label . +) |
26817 | 200 (label . +) |
18720 | 201 (statement-case-open . +) |
202 (statement-cont . +) | |
203 (arglist-intro . c-lineup-arglist-intro-after-paren) | |
204 (arglist-close . c-lineup-arglist) | |
205 (access-label . 0) | |
206 (inher-cont . c-lineup-java-inher) | |
207 (func-decl-cont . c-lineup-java-throws) | |
208 )) | |
209 ) | |
210 ) | |
211 "Styles of indentation. | |
212 Elements of this alist are of the form: | |
213 | |
214 (STYLE-STRING [BASE-STYLE] (VARIABLE . VALUE) [(VARIABLE . VALUE) ...]) | |
215 | |
216 where STYLE-STRING is a short descriptive string used to select a | |
217 style, VARIABLE is any Emacs variable, and VALUE is the intended value | |
218 for that variable when using the selected style. | |
219 | |
220 Optional BASE-STYLE if present, is a string and must follow | |
221 STYLE-STRING. BASE-STYLE names a style that this style inherits from. | |
26817 | 222 By default, all styles inherit from the \"user\" style, which is |
18720 | 223 computed at run time. Style loops generate errors. |
224 | |
225 Two variables are treated specially. When VARIABLE is | |
226 `c-offsets-alist', the VALUE is a list containing elements of the | |
227 form: | |
228 | |
229 (SYNTACTIC-SYMBOL . OFFSET) | |
230 | |
231 as described in `c-offsets-alist'. These are passed directly to | |
232 `c-set-offset' so there is no need to set every syntactic symbol in | |
233 your style, only those that are different from the default. | |
234 | |
235 When VARIABLE is `c-special-indent-hook', its VALUE is added to | |
236 `c-special-indent-hook' using `add-hook'. If VALUE is a list, each | |
237 element of the list is added with `add-hook'. | |
238 | |
239 Do not change this variable directly. Use the function `c-add-style' | |
240 to add new styles or modify existing styles (it is not a good idea to | |
241 modify existing styles -- you should create a new style that inherits | |
242 the existing style.") | |
243 | |
244 | |
245 ;; Functions that manipulate styles | |
26817 | 246 (defun c-set-style-1 (conscell dont-override) |
18720 | 247 ;; Set the style for one variable |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
248 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
249 ;; This function does not do any hidden buffer changes. |
18720 | 250 (let ((attr (car conscell)) |
251 (val (cdr conscell))) | |
252 (cond | |
253 ;; first special variable | |
254 ((eq attr 'c-offsets-alist) | |
45703
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
255 (let ((offsets (cond ((eq dont-override t) |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
256 c-offsets-alist) |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
257 (dont-override |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
258 (default-value 'c-offsets-alist))))) |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
259 (mapcar (lambda (langentry) |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
260 (let ((langelem (car langentry)) |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
261 (offset (cdr langentry))) |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
262 (unless (assq langelem offsets) |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
263 (c-set-offset langelem offset)))) |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
264 val))) |
18720 | 265 ;; second special variable |
266 ((eq attr 'c-special-indent-hook) | |
45703
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
267 ;; Maybe we should ignore dont-override here and always add new |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
268 ;; hooks? |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
269 (unless (cond ((eq dont-override t) |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
270 c-special-indent-hook) |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
271 (dont-override |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
272 (default-value 'c-special-indent-hook))) |
26817 | 273 (if (listp val) |
45703
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
274 (mapcar (lambda (func) |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
275 (add-hook 'c-special-indent-hook func t t)) |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
276 val) |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
277 (add-hook 'c-special-indent-hook val t t)))) |
18720 | 278 ;; all other variables |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
279 (t (when (or (not dont-override) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
280 (not (memq attr c-style-variables)) |
45703
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
281 (eq (if (eq dont-override t) |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
282 (symbol-value attr) |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
283 (default-value attr)) |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
284 'set-from-style)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
285 (set attr val) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
286 ;; Must update a number of other variables if |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
287 ;; c-comment-prefix-regexp is set. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
288 (if (eq attr 'c-comment-prefix-regexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
289 (c-setup-paragraph-variables))))))) |
18720 | 290 |
26817 | 291 (defun c-get-style-variables (style basestyles) |
292 ;; Return all variables in a style by resolving inheritances. | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
293 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
294 ;; This function does not do any hidden buffer changes. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
295 (if (not style) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
296 (copy-alist c-fallback-style) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
297 (let ((vars (cdr (or (assoc (downcase style) c-style-alist) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
298 (assoc (upcase style) c-style-alist) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
299 (assoc style c-style-alist) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
300 (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
301 (c-benign-error "Undefined style: %s" style) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
302 nil))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
303 (let ((base (and (stringp (car-safe vars)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
304 (prog1 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
305 (downcase (car vars)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
306 (setq vars (cdr vars)))))) |
26817 | 307 (if (memq base basestyles) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
308 (c-benign-error "Style loop detected: %s in %s" base basestyles) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
309 (nconc (c-get-style-variables base (cons base basestyles)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
310 (copy-alist vars))))))) |
26817 | 311 |
18720 | 312 (defvar c-set-style-history nil) |
313 | |
314 ;;;###autoload | |
26817 | 315 (defun c-set-style (stylename &optional dont-override) |
18720 | 316 "Set CC Mode variables to use one of several different indentation styles. |
317 STYLENAME is a string representing the desired style from the list of | |
318 styles described in the variable `c-style-alist'. See that variable | |
319 for details of setting up styles. | |
320 | |
321 The variable `c-indentation-style' always contains the buffer's current | |
26817 | 322 style name. |
323 | |
45703
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
324 If the optional argument DONT-OVERRIDE is t, no style variables that |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
325 already have values will be overridden. I.e. in the case of |
26817 | 326 `c-offsets-alist', syntactic symbols will only be added, and in the |
327 case of all other style variables, only those set to `set-from-style' | |
328 will be reassigned. | |
329 | |
45703
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
330 If DONT-OVERRIDE is neither nil nor t, only those style variables that |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
331 have default (i.e. non-buffer local) values will keep their settings |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
332 while the rest will be overridden. This is useful to avoid overriding |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
333 global settings done in ~/.emacs when setting a style from a mode hook |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
334 \(providing the style variables are buffer local, which is the |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
335 default). |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
336 |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
337 Obviously, setting DONT-OVERRIDE to t is useful mainly when the |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
338 initial style is chosen for a CC Mode buffer by a major mode. Since |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
339 that is done internally by CC Mode, it typically won't have any effect |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
340 when used elsewhere." |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
341 (interactive |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
342 (list (let ((completion-ignore-case t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
343 (prompt (format "Which %s indentation style? " |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
344 mode-name))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
345 (condition-case nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
346 ;; The default argument is preferred over |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
347 ;; initial-contents, but it only exists in Emacs >= 20 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
348 ;; and XEmacs >= 21. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
349 (completing-read prompt c-style-alist nil t nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
350 'c-set-style-history |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
351 c-indentation-style) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
352 (wrong-number-of-arguments |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
353 ;; If the call above failed, we fall back to the old way |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
354 ;; of specifying the default value. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
355 (completing-read prompt c-style-alist nil t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
356 (cons c-indentation-style 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
357 'c-set-style-history)))))) |
19254
81353d4e05b7
(c-styles-alist): In "java" style, set
Richard M. Stallman <rms@gnu.org>
parents:
19212
diff
changeset
|
358 (c-initialize-builtin-style) |
26817 | 359 (let ((vars (c-get-style-variables stylename nil))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
360 (unless dont-override |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
361 ;; Since we always add to c-special-indent-hook we must reset it |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
362 ;; first, or else the hooks from the preceding style will |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
363 ;; remain. This is not necessary for c-offsets-alist, since |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
364 ;; c-get-style-variables contains every valid offset type in the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
365 ;; fallback entry. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
366 (setq c-special-indent-hook |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
367 (default-value 'c-special-indent-hook))) |
26817 | 368 (mapcar (lambda (elem) |
369 (c-set-style-1 elem dont-override)) | |
370 ;; Need to go through the variables backwards when we | |
45703
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
371 ;; don't override any settings. |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
372 (if (eq dont-override t) (nreverse vars) vars))) |
18720 | 373 (setq c-indentation-style stylename) |
374 (c-keep-region-active)) | |
375 | |
376 ;;;###autoload | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
377 (defun c-add-style (style description &optional set-p) |
18720 | 378 "Adds a style to `c-style-alist', or updates an existing one. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
379 STYLE is a string identifying the style to add or update. DESCRIPTION |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
380 is an association list describing the style and must be of the form: |
18720 | 381 |
382 ([BASESTYLE] (VARIABLE . VALUE) [(VARIABLE . VALUE) ...]) | |
383 | |
384 See the variable `c-style-alist' for the semantics of BASESTYLE, | |
385 VARIABLE and VALUE. This function also sets the current style to | |
386 STYLE using `c-set-style' if the optional SET-P flag is non-nil." | |
387 (interactive | |
388 (let ((stylename (completing-read "Style to add: " c-style-alist | |
389 nil nil nil 'c-set-style-history)) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
390 (descr (eval-minibuffer "Style description: "))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
391 (list stylename descr |
18720 | 392 (y-or-n-p "Set the style too? ")))) |
393 (setq style (downcase style)) | |
394 (let ((s (assoc style c-style-alist))) | |
395 (if s | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
396 (setcdr s (copy-alist description)) ; replace |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
397 (setq c-style-alist (cons (cons style description) c-style-alist)))) |
18720 | 398 (and set-p (c-set-style style))) |
399 | |
400 | |
401 (defvar c-read-offset-history nil) | |
402 | |
403 (defun c-read-offset (langelem) | |
404 ;; read new offset value for LANGELEM from minibuffer. return a | |
405 ;; legal value only | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
406 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
407 ;; This function does not do any hidden buffer changes. |
26817 | 408 (let* ((oldoff (cdr-safe (or (assq langelem c-offsets-alist) |
409 (assq langelem (get 'c-offsets-alist | |
410 'c-stylevar-fallback))))) | |
24282 | 411 (symname (symbol-name langelem)) |
412 (defstr (format "(default %s): " oldoff)) | |
36920 | 413 (errmsg (concat "Offset must be int, func, var, vector, list, " |
24282 | 414 "or [+,-,++,--,*,/] " |
415 defstr)) | |
416 (prompt (concat symname " offset " defstr)) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
417 (keymap (make-sparse-keymap)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
418 (minibuffer-completion-table obarray) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
419 (minibuffer-completion-predicate 'fboundp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
420 offset input) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
421 ;; In principle completing-read is used here, but SPC is unbound |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
422 ;; to make it less annoying to enter lists. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
423 (set-keymap-parent keymap minibuffer-local-completion-map) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
424 (define-key keymap " " 'self-insert-command) |
18720 | 425 (while (not offset) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
426 (setq input (read-from-minibuffer prompt nil keymap t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
427 'c-read-offset-history |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
428 (format "%s" oldoff))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
429 (if (c-valid-offset input) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
430 (setq offset input) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
431 ;; error, but don't signal one, keep trying |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
432 ;; to read an input value |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
433 (ding) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
434 (setq prompt errmsg))) |
18720 | 435 offset)) |
436 | |
19212
024594beef65
(c-set-offset): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
18845
diff
changeset
|
437 ;;;###autoload |
26817 | 438 (defun c-set-offset (symbol offset &optional ignored) |
18720 | 439 "Change the value of a syntactic element symbol in `c-offsets-alist'. |
440 SYMBOL is the syntactic element symbol to change and OFFSET is the new | |
26817 | 441 offset for that syntactic element. The optional argument is not used |
442 and exists only for compatibility reasons." | |
18720 | 443 (interactive |
444 (let* ((langelem | |
445 (intern (completing-read | |
446 (concat "Syntactic symbol to change" | |
447 (if current-prefix-arg " or add" "") | |
448 ": ") | |
449 (mapcar | |
450 #'(lambda (langelem) | |
451 (cons (format "%s" (car langelem)) nil)) | |
26817 | 452 (get 'c-offsets-alist 'c-stylevar-fallback)) |
18720 | 453 nil (not current-prefix-arg) |
454 ;; initial contents tries to be the last element | |
455 ;; on the syntactic analysis list for the current | |
456 ;; line | |
49660
425dcb97eca4
(c-set-offset): Don't find a default syntactic element through
Martin Stjernholm <mast@lysator.liu.se>
parents:
49478
diff
changeset
|
457 (and c-buffer-is-cc-mode |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
458 (c-save-buffer-state |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
459 ((syntax (c-guess-basic-syntax)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
460 (len (length syntax)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
461 (ic (format "%s" (car (nth (1- len) syntax))))) |
49660
425dcb97eca4
(c-set-offset): Don't find a default syntactic element through
Martin Stjernholm <mast@lysator.liu.se>
parents:
49478
diff
changeset
|
462 (cons ic 0))) |
18720 | 463 ))) |
464 (offset (c-read-offset langelem))) | |
465 (list langelem offset current-prefix-arg))) | |
466 ;; sanity check offset | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
467 (if (c-valid-offset offset) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
468 (let ((entry (assq symbol c-offsets-alist))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
469 (if entry |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
470 (setcdr entry offset) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
471 (if (assq symbol (get 'c-offsets-alist 'c-stylevar-fallback)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
472 (setq c-offsets-alist (cons (cons symbol offset) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
473 c-offsets-alist)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
474 (c-benign-error "%s is not a valid syntactic symbol" symbol)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
475 (c-benign-error "Invalid indentation setting for symbol %s: %s" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
476 symbol offset)) |
18720 | 477 (c-keep-region-active)) |
478 | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
479 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
480 (defun c-setup-paragraph-variables () |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
481 "Fix things up for paragraph recognition and filling inside comments by |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
482 incorporating the value of `c-comment-prefix-regexp' in the relevant |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
483 variables." |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
484 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
485 ;; This function does not do any hidden buffer changes. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
486 |
52608
fae5ff03687a
(c-setup-paragraph-variables): Made it interactive.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
487 (interactive) |
fae5ff03687a
(c-setup-paragraph-variables): Made it interactive.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
488 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
489 (setq c-current-comment-prefix |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
490 (if (listp c-comment-prefix-regexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
491 (cdr-safe (or (assoc major-mode c-comment-prefix-regexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
492 (assoc 'other c-comment-prefix-regexp))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
493 c-comment-prefix-regexp)) |
52608
fae5ff03687a
(c-setup-paragraph-variables): Made it interactive.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
494 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
495 (let ((comment-line-prefix |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
496 (concat "[ \t]*\\(" c-current-comment-prefix "\\)[ \t]*"))) |
52608
fae5ff03687a
(c-setup-paragraph-variables): Made it interactive.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
497 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
498 (setq paragraph-start (concat comment-line-prefix |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
499 c-paragraph-start |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
500 "\\|" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
501 page-delimiter) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
502 paragraph-separate (concat comment-line-prefix |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
503 c-paragraph-separate |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
504 "\\|" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
505 page-delimiter) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
506 paragraph-ignore-fill-prefix t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
507 adaptive-fill-mode t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
508 adaptive-fill-regexp |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
509 (concat comment-line-prefix |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
510 (if (default-value 'adaptive-fill-regexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
511 (concat "\\(" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
512 (default-value 'adaptive-fill-regexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
513 "\\)") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
514 ""))) |
52608
fae5ff03687a
(c-setup-paragraph-variables): Made it interactive.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
515 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
516 (when (boundp 'adaptive-fill-first-line-regexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
517 ;; XEmacs (20.x) adaptive fill mode doesn't have this. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
518 (make-local-variable 'adaptive-fill-first-line-regexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
519 (setq adaptive-fill-first-line-regexp |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
520 (concat "\\`" comment-line-prefix |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
521 ;; Maybe we should incorporate the old value here, |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
522 ;; but then we have to do all sorts of kludges to |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
523 ;; deal with the \` and \' it probably contains. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
524 "\\'"))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
525 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
526 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
527 ;; Helper for setting up Filladapt mode. It's not used by CC Mode itself. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
528 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
529 (cc-bytecomp-defvar filladapt-token-table) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
530 (cc-bytecomp-defvar filladapt-token-match-table) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
531 (cc-bytecomp-defvar filladapt-token-conversion-table) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
532 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
533 (defun c-setup-filladapt () |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
534 "Convenience function to configure Kyle E. Jones' Filladapt mode for |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
535 CC Mode by making sure the proper entries are present on |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
536 `filladapt-token-table', `filladapt-token-match-table', and |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
537 `filladapt-token-conversion-table'. This is intended to be used on |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
538 `c-mode-common-hook' or similar." |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
539 ;; This function is intended to be used explicitly by the end user |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
540 ;; only. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
541 ;; |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
542 ;; This function does not do any hidden buffer changes. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
543 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
544 ;; The default configuration already handles C++ comments, but we |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
545 ;; need to add handling of C block comments. A new filladapt token |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
546 ;; `c-comment' is added for that. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
547 (let (p) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
548 (setq p filladapt-token-table) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
549 (while (and p (not (eq (car-safe (cdr-safe (car-safe p))) 'c-comment))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
550 (setq p (cdr-safe p))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
551 (if p |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
552 (setcar (car p) c-current-comment-prefix) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
553 (setq filladapt-token-table |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
554 (append (list (car filladapt-token-table) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
555 (list c-current-comment-prefix 'c-comment)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
556 (cdr filladapt-token-table))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
557 (unless (assq 'c-comment filladapt-token-match-table) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
558 (setq filladapt-token-match-table |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
559 (append '((c-comment c-comment)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
560 filladapt-token-match-table))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
561 (unless (assq 'c-comment filladapt-token-conversion-table) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
562 (setq filladapt-token-conversion-table |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
563 (append '((c-comment . exact)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
564 filladapt-token-conversion-table)))) |
26817 | 565 |
24282 | 566 |
18720 | 567 (defun c-initialize-builtin-style () |
568 ;; Dynamically append the default value of most variables. This is | |
569 ;; crucial because future c-set-style calls will always reset the | |
570 ;; variables first to the `cc-mode' style before instituting the new | |
571 ;; style. Only do this once! | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
572 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
573 ;; This function does not do any hidden buffer changes. |
24282 | 574 (unless (get 'c-initialize-builtin-style 'is-run) |
575 (put 'c-initialize-builtin-style 'is-run t) | |
36920 | 576 ;;(c-initialize-cc-mode) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
577 (unless (assoc "user" c-style-alist) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
578 (let ((vars c-style-variables) var val uservars) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
579 (while vars |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
580 (setq var (car vars) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
581 val (symbol-value var) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
582 vars (cdr vars)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
583 (cond ((eq var 'c-offsets-alist) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
584 (or (null val) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
585 (setq uservars (cons (cons 'c-offsets-alist val) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
586 uservars)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
587 ((not (eq val 'set-from-style)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
588 (setq uservars (cons (cons var val) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
589 uservars))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
590 (c-add-style "user" uservars))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
591 (unless (assoc "cc-mode" c-style-alist) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
592 (c-add-style "cc-mode" '("user"))) |
24282 | 593 (if c-style-variables-are-local-p |
594 (c-make-styles-buffer-local)))) | |
19254
81353d4e05b7
(c-styles-alist): In "java" style, set
Richard M. Stallman <rms@gnu.org>
parents:
19212
diff
changeset
|
595 |
20918
8e64bd5b1b5f
(c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents:
20147
diff
changeset
|
596 (defun c-make-styles-buffer-local (&optional this-buf-only-p) |
18720 | 597 "Make all CC Mode style variables buffer local. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
598 If `this-buf-only-p' is non-nil, the style variables will be made |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
599 buffer local only in the current buffer. Otherwise they'll be made |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
600 permanently buffer local in any buffer that change their values. |
18720 | 601 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
602 The buffer localness of the style variables are normally controlled |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
603 with the variable `c-style-variables-are-local-p', so there's seldom |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
604 any reason to call this function directly." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
605 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
606 ;; This function does not do any hidden buffer changes. |
18720 | 607 |
608 ;; style variables | |
20918
8e64bd5b1b5f
(c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents:
20147
diff
changeset
|
609 (let ((func (if this-buf-only-p |
8e64bd5b1b5f
(c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents:
20147
diff
changeset
|
610 'make-local-variable |
8e64bd5b1b5f
(c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents:
20147
diff
changeset
|
611 'make-variable-buffer-local)) |
26817 | 612 (varsyms (cons 'c-indentation-style (copy-alist c-style-variables)))) |
613 (delq 'c-special-indent-hook varsyms) | |
20918
8e64bd5b1b5f
(c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents:
20147
diff
changeset
|
614 (mapcar func varsyms) |
8e64bd5b1b5f
(c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents:
20147
diff
changeset
|
615 ;; Hooks must be handled specially |
8e64bd5b1b5f
(c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents:
20147
diff
changeset
|
616 (if this-buf-only-p |
8e64bd5b1b5f
(c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents:
20147
diff
changeset
|
617 (make-local-hook 'c-special-indent-hook) |
26817 | 618 (make-variable-buffer-local 'c-special-indent-hook) |
619 (setq c-style-variables-are-local-p t)) | |
20918
8e64bd5b1b5f
(c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents:
20147
diff
changeset
|
620 )) |
8e64bd5b1b5f
(c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents:
20147
diff
changeset
|
621 |
18720 | 622 |
623 | |
36920 | 624 (cc-provide 'cc-styles) |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38167
diff
changeset
|
625 |
52401 | 626 ;;; arch-tag: c764f61a-96ba-484a-a68f-101c0e9d5d2c |
18720 | 627 ;;; cc-styles.el ends here |