Mercurial > emacs
annotate lisp/progmodes/cc-styles.el @ 65928:748096332c1d
*** empty log message ***
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Sat, 08 Oct 2005 19:29:25 +0000 |
parents | 8b5704a2934a |
children | 04d2abb755d9 aa89c814f853 |
rev | line source |
---|---|
18720 | 1 ;;; cc-styles.el --- support for styles in CC Mode |
2 | |
64699
629afbe74e61
Update copyright for release of 22.1 for progmodes directory.
Nick Roberts <nickrob@snap.net.nz>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 1985,1987,1992-2003, 2004, 2005 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 |
64085 | 28 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
29 ;; Boston, MA 02110-1301, USA. | |
18720 | 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 |
62641
27b53b1903b6
2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
56646
diff
changeset
|
51 (cc-bytecomp-obsolete-fun make-local-hook) ; Marked obsolete in Emacs 21.1. |
24282 | 52 |
18720 | 53 |
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
|
54 (defvar c-style-alist |
18720 | 55 '(("gnu" |
56 (c-basic-offset . 2) | |
57 (c-comment-only-line-offset . (0 . 0)) | |
58 (c-offsets-alist . ((statement-block-intro . +) | |
59 (knr-argdecl-intro . 5) | |
60 (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
|
61 (substatement-label . 0) |
18720 | 62 (label . 0) |
63 (statement-case-open . +) | |
64 (statement-cont . +) | |
65 (arglist-intro . c-lineup-arglist-intro-after-paren) | |
66 (arglist-close . c-lineup-arglist) | |
24282 | 67 (inline-open . 0) |
30400
58d2360c8677
(c-style-alist): The basic offset for the BSD
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
68 (brace-list-open . +) |
18720 | 69 )) |
70 (c-special-indent-hook . c-gnu-impose-minimum) | |
26817 | 71 (c-block-comment-prefix . "") |
18720 | 72 ) |
73 ("k&r" | |
74 (c-basic-offset . 5) | |
75 (c-comment-only-line-offset . 0) | |
76 (c-offsets-alist . ((statement-block-intro . +) | |
77 (knr-argdecl-intro . 0) | |
78 (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
|
79 (substatement-label . 0) |
18720 | 80 (label . 0) |
81 (statement-cont . +) | |
82 )) | |
83 ) | |
84 ("bsd" | |
30400
58d2360c8677
(c-style-alist): The basic offset for the BSD
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
85 (c-basic-offset . 8) |
18720 | 86 (c-comment-only-line-offset . 0) |
87 (c-offsets-alist . ((statement-block-intro . +) | |
88 (knr-argdecl-intro . +) | |
89 (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
|
90 (substatement-label . 0) |
18720 | 91 (label . 0) |
92 (statement-cont . +) | |
26817 | 93 (inline-open . 0) |
94 (inexpr-class . 0) | |
18720 | 95 )) |
96 ) | |
97 ("stroustrup" | |
98 (c-basic-offset . 4) | |
99 (c-comment-only-line-offset . 0) | |
100 (c-offsets-alist . ((statement-block-intro . +) | |
101 (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
|
102 (substatement-label . 0) |
18720 | 103 (label . 0) |
104 (statement-cont . +) | |
105 )) | |
106 ) | |
107 ("whitesmith" | |
108 (c-basic-offset . 4) | |
109 (c-comment-only-line-offset . 0) | |
26817 | 110 (c-offsets-alist . ((knr-argdecl-intro . +) |
18720 | 111 (label . 0) |
112 (statement-cont . +) | |
26817 | 113 (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
|
114 (substatement-label . +) |
26817 | 115 (block-open . +) |
116 (statement-block-intro . c-lineup-whitesmith-in-block) | |
117 (block-close . c-lineup-whitesmith-in-block) | |
118 (inline-open . +) | |
119 (defun-open . +) | |
120 (defun-block-intro . c-lineup-whitesmith-in-block) | |
121 (defun-close . c-lineup-whitesmith-in-block) | |
122 (brace-list-open . +) | |
123 (brace-list-intro . c-lineup-whitesmith-in-block) | |
124 (brace-entry-open . c-indent-multi-line-block) | |
125 (brace-list-close . c-lineup-whitesmith-in-block) | |
126 (class-open . +) | |
127 (inclass . c-lineup-whitesmith-in-block) | |
128 (class-close . +) | |
129 (inexpr-class . 0) | |
130 (extern-lang-open . +) | |
131 (inextern-lang . c-lineup-whitesmith-in-block) | |
132 (extern-lang-close . +) | |
133 (namespace-open . +) | |
134 (innamespace . c-lineup-whitesmith-in-block) | |
135 (namespace-close . +) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
136 (module-open . +) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
137 (inmodule . c-lineup-whitesmith-in-block) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
138 (module-close . +) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
139 (composition-open . +) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
140 (incomposition . c-lineup-whitesmith-in-block) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
141 (composition-close . +) |
18720 | 142 )) |
143 ) | |
144 ("ellemtel" | |
145 (c-basic-offset . 3) | |
146 (c-comment-only-line-offset . 0) | |
147 (c-hanging-braces-alist . ((substatement-open before after))) | |
148 (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
|
149 (substatement . +) |
18720 | 150 (substatement-open . 0) |
151 (case-label . +) | |
152 (access-label . -) | |
153 (inclass . ++) | |
154 (inline-open . 0) | |
155 )) | |
156 ) | |
157 ("linux" | |
158 (c-basic-offset . 8) | |
159 (c-comment-only-line-offset . 0) | |
160 (c-hanging-braces-alist . ((brace-list-open) | |
24282 | 161 (brace-entry-open) |
18720 | 162 (substatement-open after) |
163 (block-close . c-snug-do-while))) | |
164 (c-cleanup-list . (brace-else-brace)) | |
165 (c-offsets-alist . ((statement-block-intro . +) | |
166 (knr-argdecl-intro . 0) | |
167 (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
|
168 (substatement-label . 0) |
18720 | 169 (label . 0) |
170 (statement-cont . +) | |
171 )) | |
172 ) | |
173 ("python" | |
174 (indent-tabs-mode . t) | |
26817 | 175 (fill-column . 78) |
18720 | 176 (c-basic-offset . 8) |
177 (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
|
178 (inextern-lang . 0) |
86412da1174b
(c-style-alist) <python>:, knr-argdecl-intro == +
Richard M. Stallman <rms@gnu.org>
parents:
19376
diff
changeset
|
179 (arglist-intro . +) |
86412da1174b
(c-style-alist) <python>:, knr-argdecl-intro == +
Richard M. Stallman <rms@gnu.org>
parents:
19376
diff
changeset
|
180 (knr-argdecl-intro . +) |
18720 | 181 )) |
182 (c-hanging-braces-alist . ((brace-list-open) | |
183 (brace-list-intro) | |
184 (brace-list-close) | |
24282 | 185 (brace-entry-open) |
18720 | 186 (substatement-open after) |
187 (block-close . c-snug-do-while) | |
188 )) | |
26817 | 189 (c-block-comment-prefix . "") |
18720 | 190 ) |
191 ("java" | |
20918
8e64bd5b1b5f
(c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents:
20147
diff
changeset
|
192 (c-basic-offset . 4) |
18720 | 193 (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
|
194 ;; 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
|
195 (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
|
196 (topmost-intro-cont . +) |
18720 | 197 (statement-block-intro . +) |
198 (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
|
199 (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
|
200 (substatement-label . +) |
26817 | 201 (label . +) |
18720 | 202 (statement-case-open . +) |
203 (statement-cont . +) | |
204 (arglist-intro . c-lineup-arglist-intro-after-paren) | |
205 (arglist-close . c-lineup-arglist) | |
206 (access-label . 0) | |
207 (inher-cont . c-lineup-java-inher) | |
208 (func-decl-cont . c-lineup-java-throws) | |
209 )) | |
210 ) | |
211 ) | |
212 "Styles of indentation. | |
213 Elements of this alist are of the form: | |
214 | |
215 (STYLE-STRING [BASE-STYLE] (VARIABLE . VALUE) [(VARIABLE . VALUE) ...]) | |
216 | |
217 where STYLE-STRING is a short descriptive string used to select a | |
218 style, VARIABLE is any Emacs variable, and VALUE is the intended value | |
219 for that variable when using the selected style. | |
220 | |
221 Optional BASE-STYLE if present, is a string and must follow | |
222 STYLE-STRING. BASE-STYLE names a style that this style inherits from. | |
26817 | 223 By default, all styles inherit from the \"user\" style, which is |
18720 | 224 computed at run time. Style loops generate errors. |
225 | |
226 Two variables are treated specially. When VARIABLE is | |
227 `c-offsets-alist', the VALUE is a list containing elements of the | |
228 form: | |
229 | |
230 (SYNTACTIC-SYMBOL . OFFSET) | |
231 | |
232 as described in `c-offsets-alist'. These are passed directly to | |
233 `c-set-offset' so there is no need to set every syntactic symbol in | |
234 your style, only those that are different from the default. | |
235 | |
236 When VARIABLE is `c-special-indent-hook', its VALUE is added to | |
237 `c-special-indent-hook' using `add-hook'. If VALUE is a list, each | |
238 element of the list is added with `add-hook'. | |
239 | |
240 Do not change this variable directly. Use the function `c-add-style' | |
241 to add new styles or modify existing styles (it is not a good idea to | |
242 modify existing styles -- you should create a new style that inherits | |
243 the existing style.") | |
244 | |
245 | |
246 ;; Functions that manipulate styles | |
26817 | 247 (defun c-set-style-1 (conscell dont-override) |
18720 | 248 ;; 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
|
249 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
250 ;; This function does not do any hidden buffer changes. |
18720 | 251 (let ((attr (car conscell)) |
252 (val (cdr conscell))) | |
253 (cond | |
254 ;; first special variable | |
255 ((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
|
256 (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
|
257 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
|
258 (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
|
259 (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
|
260 (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
|
261 (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
|
262 (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
|
263 (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
|
264 (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
|
265 val))) |
18720 | 266 ;; second special variable |
267 ((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
|
268 ;; 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
|
269 ;; hooks? |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
270 (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
|
271 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
|
272 (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
|
273 (default-value 'c-special-indent-hook))) |
26817 | 274 (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
|
275 (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
|
276 (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
|
277 val) |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
278 (add-hook 'c-special-indent-hook val t t)))) |
18720 | 279 ;; 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
|
280 (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
|
281 (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
|
282 (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
|
283 (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
|
284 (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
|
285 '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
|
286 (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
|
287 ;; 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
|
288 ;; 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
|
289 (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
|
290 (c-setup-paragraph-variables))))))) |
18720 | 291 |
26817 | 292 (defun c-get-style-variables (style basestyles) |
293 ;; 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
|
294 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
295 ;; 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
|
296 (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
|
297 (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
|
298 (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
|
299 (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
|
300 (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
|
301 (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
|
302 (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
|
303 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
|
304 (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
|
305 (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
|
306 (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
|
307 (setq vars (cdr vars)))))) |
26817 | 308 (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
|
309 (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
|
310 (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
|
311 (copy-alist vars))))))) |
26817 | 312 |
18720 | 313 (defvar c-set-style-history nil) |
314 | |
315 ;;;###autoload | |
26817 | 316 (defun c-set-style (stylename &optional dont-override) |
18720 | 317 "Set CC Mode variables to use one of several different indentation styles. |
318 STYLENAME is a string representing the desired style from the list of | |
319 styles described in the variable `c-style-alist'. See that variable | |
320 for details of setting up styles. | |
321 | |
322 The variable `c-indentation-style' always contains the buffer's current | |
26817 | 323 style name. |
324 | |
45703
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
325 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
|
326 already have values will be overridden. I.e. in the case of |
26817 | 327 `c-offsets-alist', syntactic symbols will only be added, and in the |
328 case of all other style variables, only those set to `set-from-style' | |
329 will be reassigned. | |
330 | |
45703
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
331 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
|
332 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
|
333 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
|
334 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
|
335 \(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
|
336 default). |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
337 |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
338 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
|
339 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
|
340 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
|
341 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
|
342 (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
|
343 (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
|
344 (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
|
345 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
|
346 (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
|
347 ;; 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
|
348 ;; 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
|
349 ;; 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
|
350 (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
|
351 '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
|
352 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
|
353 (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
|
354 ;; 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
|
355 ;; 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
|
356 (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
|
357 (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
|
358 'c-set-style-history)))))) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52608
diff
changeset
|
359 (or (stringp stylename) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52608
diff
changeset
|
360 (error "Argument to c-set-style was not a string")) |
19254
81353d4e05b7
(c-styles-alist): In "java" style, set
Richard M. Stallman <rms@gnu.org>
parents:
19212
diff
changeset
|
361 (c-initialize-builtin-style) |
26817 | 362 (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
|
363 (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
|
364 ;; 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
|
365 ;; 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
|
366 ;; 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
|
367 ;; 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
|
368 ;; 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
|
369 (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
|
370 (default-value 'c-special-indent-hook))) |
26817 | 371 (mapcar (lambda (elem) |
372 (c-set-style-1 elem dont-override)) | |
373 ;; 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
|
374 ;; 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
|
375 (if (eq dont-override t) (nreverse vars) vars))) |
18720 | 376 (setq c-indentation-style stylename) |
377 (c-keep-region-active)) | |
378 | |
379 ;;;###autoload | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
380 (defun c-add-style (style description &optional set-p) |
18720 | 381 "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
|
382 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
|
383 is an association list describing the style and must be of the form: |
18720 | 384 |
385 ([BASESTYLE] (VARIABLE . VALUE) [(VARIABLE . VALUE) ...]) | |
386 | |
387 See the variable `c-style-alist' for the semantics of BASESTYLE, | |
388 VARIABLE and VALUE. This function also sets the current style to | |
389 STYLE using `c-set-style' if the optional SET-P flag is non-nil." | |
390 (interactive | |
391 (let ((stylename (completing-read "Style to add: " c-style-alist | |
392 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
|
393 (descr (eval-minibuffer "Style description: "))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
394 (list stylename descr |
18720 | 395 (y-or-n-p "Set the style too? ")))) |
396 (setq style (downcase style)) | |
397 (let ((s (assoc style c-style-alist))) | |
398 (if s | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
399 (setcdr s (copy-alist description)) ; replace |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
400 (setq c-style-alist (cons (cons style description) c-style-alist)))) |
18720 | 401 (and set-p (c-set-style style))) |
402 | |
403 | |
404 (defvar c-read-offset-history nil) | |
405 | |
406 (defun c-read-offset (langelem) | |
407 ;; read new offset value for LANGELEM from minibuffer. return a | |
408 ;; legal value only | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
409 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
410 ;; This function does not do any hidden buffer changes. |
26817 | 411 (let* ((oldoff (cdr-safe (or (assq langelem c-offsets-alist) |
412 (assq langelem (get 'c-offsets-alist | |
413 'c-stylevar-fallback))))) | |
24282 | 414 (symname (symbol-name langelem)) |
415 (defstr (format "(default %s): " oldoff)) | |
36920 | 416 (errmsg (concat "Offset must be int, func, var, vector, list, " |
24282 | 417 "or [+,-,++,--,*,/] " |
418 defstr)) | |
419 (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
|
420 (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
|
421 (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
|
422 (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
|
423 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
|
424 ;; 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
|
425 ;; 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
|
426 (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
|
427 (define-key keymap " " 'self-insert-command) |
18720 | 428 (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
|
429 (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
|
430 '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
|
431 (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
|
432 (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
|
433 (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
|
434 ;; 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
|
435 ;; 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
|
436 (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
|
437 (setq prompt errmsg))) |
18720 | 438 offset)) |
439 | |
19212
024594beef65
(c-set-offset): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
18845
diff
changeset
|
440 ;;;###autoload |
26817 | 441 (defun c-set-offset (symbol offset &optional ignored) |
18720 | 442 "Change the value of a syntactic element symbol in `c-offsets-alist'. |
443 SYMBOL is the syntactic element symbol to change and OFFSET is the new | |
26817 | 444 offset for that syntactic element. The optional argument is not used |
445 and exists only for compatibility reasons." | |
18720 | 446 (interactive |
447 (let* ((langelem | |
448 (intern (completing-read | |
449 (concat "Syntactic symbol to change" | |
450 (if current-prefix-arg " or add" "") | |
451 ": ") | |
452 (mapcar | |
453 #'(lambda (langelem) | |
454 (cons (format "%s" (car langelem)) nil)) | |
26817 | 455 (get 'c-offsets-alist 'c-stylevar-fallback)) |
18720 | 456 nil (not current-prefix-arg) |
457 ;; initial contents tries to be the last element | |
458 ;; on the syntactic analysis list for the current | |
459 ;; line | |
49660
425dcb97eca4
(c-set-offset): Don't find a default syntactic element through
Martin Stjernholm <mast@lysator.liu.se>
parents:
49478
diff
changeset
|
460 (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
|
461 (c-save-buffer-state |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
462 ((syntax (c-guess-basic-syntax)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
463 (len (length syntax)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
464 (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
|
465 (cons ic 0))) |
18720 | 466 ))) |
467 (offset (c-read-offset langelem))) | |
468 (list langelem offset current-prefix-arg))) | |
469 ;; 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
|
470 (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
|
471 (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
|
472 (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
|
473 (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
|
474 (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
|
475 (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
|
476 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
|
477 (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
|
478 (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
|
479 symbol offset)) |
18720 | 480 (c-keep-region-active)) |
481 | |
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
|
482 |
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 (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
|
484 "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
|
485 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
|
486 variables." |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
487 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
488 ;; 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
|
489 |
52608
fae5ff03687a
(c-setup-paragraph-variables): Made it interactive.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
490 (interactive) |
fae5ff03687a
(c-setup-paragraph-variables): Made it interactive.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
491 |
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
|
492 (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
|
493 (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
|
494 (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
|
495 (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
|
496 c-comment-prefix-regexp)) |
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 (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
|
499 (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
|
500 |
65811
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
501 (set (make-local-variable 'paragraph-start) |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
502 (concat comment-line-prefix |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
503 c-paragraph-start |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
504 "\\|" |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
505 page-delimiter)) |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
506 (set (make-local-variable 'paragraph-separate) |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
507 (concat comment-line-prefix |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
508 c-paragraph-separate |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
509 "\\|" |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
510 page-delimiter)) |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
511 (set (make-local-variable 'paragraph-ignore-fill-prefix) t) |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
512 (set (make-local-variable 'adaptive-fill-mode) t) |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
513 (set (make-local-variable 'adaptive-fill-regexp) |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
514 (concat comment-line-prefix |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
515 (if (default-value 'adaptive-fill-regexp) |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
516 (concat "\\(" |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
517 (default-value 'adaptive-fill-regexp) |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
518 "\\)") |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
519 ""))) |
52608
fae5ff03687a
(c-setup-paragraph-variables): Made it interactive.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
520 |
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
|
521 (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
|
522 ;; XEmacs (20.x) adaptive fill mode doesn't have this. |
65811
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
523 (set (make-local-variable 'adaptive-fill-first-line-regexp) |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
524 (concat "\\`" comment-line-prefix |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
525 ;; Maybe we should incorporate the old value here, |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
526 ;; but then we have to do all sorts of kludges to |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
527 ;; deal with the \` and \' it probably contains. |
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
528 "\\'"))))) |
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
|
529 |
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 |
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 ;; 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
|
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 (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
|
534 (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
|
535 (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
|
536 |
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 (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
|
538 "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
|
539 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
|
540 `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
|
541 `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
|
542 `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
|
543 ;; 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
|
544 ;; 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
|
545 ;; |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
546 ;; 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
|
547 |
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
|
548 ;; 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
|
549 ;; 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
|
550 ;; `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
|
551 (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
|
552 (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
|
553 (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
|
554 (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
|
555 (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
|
556 (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
|
557 (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
|
558 (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
|
559 (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
|
560 (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
|
561 (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
|
562 (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
|
563 (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
|
564 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
|
565 (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
|
566 (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
|
567 (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
|
568 filladapt-token-conversion-table)))) |
26817 | 569 |
24282 | 570 |
18720 | 571 (defun c-initialize-builtin-style () |
572 ;; Dynamically append the default value of most variables. This is | |
573 ;; crucial because future c-set-style calls will always reset the | |
574 ;; variables first to the `cc-mode' style before instituting the new | |
575 ;; style. Only do this once! | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
576 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
577 ;; This function does not do any hidden buffer changes. |
24282 | 578 (unless (get 'c-initialize-builtin-style 'is-run) |
579 (put 'c-initialize-builtin-style 'is-run t) | |
36920 | 580 ;;(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
|
581 (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
|
582 (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
|
583 (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
|
584 (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
|
585 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
|
586 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
|
587 (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
|
588 (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
|
589 (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
|
590 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 ((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
|
592 (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
|
593 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
|
594 (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
|
595 (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
|
596 (c-add-style "cc-mode" '("user"))) |
24282 | 597 (if c-style-variables-are-local-p |
598 (c-make-styles-buffer-local)))) | |
19254
81353d4e05b7
(c-styles-alist): In "java" style, set
Richard M. Stallman <rms@gnu.org>
parents:
19212
diff
changeset
|
599 |
20918
8e64bd5b1b5f
(c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents:
20147
diff
changeset
|
600 (defun c-make-styles-buffer-local (&optional this-buf-only-p) |
18720 | 601 "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
|
602 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
|
603 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
|
604 permanently buffer local in any buffer that change their values. |
18720 | 605 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
606 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
|
607 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
|
608 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
|
609 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
610 ;; This function does not do any hidden buffer changes. |
18720 | 611 |
612 ;; 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
|
613 (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
|
614 '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
|
615 'make-variable-buffer-local)) |
26817 | 616 (varsyms (cons 'c-indentation-style (copy-alist c-style-variables)))) |
617 (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
|
618 (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
|
619 ;; 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
|
620 (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
|
621 (make-local-hook 'c-special-indent-hook) |
26817 | 622 (make-variable-buffer-local 'c-special-indent-hook) |
623 (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
|
624 )) |
8e64bd5b1b5f
(c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents:
20147
diff
changeset
|
625 |
18720 | 626 |
627 | |
36920 | 628 (cc-provide 'cc-styles) |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38167
diff
changeset
|
629 |
65811
8b5704a2934a
(c-setup-paragraph-variables): Make sure we do
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64699
diff
changeset
|
630 ;; arch-tag: c764f61a-96ba-484a-a68f-101c0e9d5d2c |
18720 | 631 ;;; cc-styles.el ends here |