Mercurial > emacs
annotate lisp/progmodes/cc-styles.el @ 72025:7b30bf7651d1
(compilation-error-regexp-alist-alist) <gnu>:
Try to rule out false positives due to time stamps.
(compilation-mode-font-lock-keywords): Remove rules made redundant
because of the above change. Add `segmentation fault' to the known and
highlighted compilation termination messages.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 19 Jul 2006 19:20:11 +0000 |
parents | 6d812049e04c |
children | cf3e4c6cd4c3 a8190f7e546e |
rev | line source |
---|---|
18720 | 1 ;;; cc-styles.el --- support for styles in CC Mode |
2 | |
69140
3d8b060d10fb
cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents:
68773
diff
changeset
|
3 ;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software |
3d8b060d10fb
cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents:
68773
diff
changeset
|
4 ;; Foundation, Inc. |
18720 | 5 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
6 ;; Authors: 1998- Martin Stjernholm |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
7 ;; 1992-1999 Barry A. Warsaw |
18720 | 8 ;; 1987 Dave Detlefs and Stewart Clamen |
9 ;; 1985 Richard M. Stallman | |
24282 | 10 ;; Maintainer: bug-cc-mode@gnu.org |
18720 | 11 ;; Created: 22-Apr-1997 (split from cc-mode.el) |
20147 | 12 ;; Version: See cc-mode.el |
18720 | 13 ;; Keywords: c languages oop |
14 | |
15 ;; This file is part of GNU Emacs. | |
16 | |
17 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
18 ;; it under the terms of the GNU General Public License as published by | |
19 ;; the Free Software Foundation; either version 2, or (at your option) | |
20 ;; any later version. | |
21 | |
22 ;; GNU Emacs is distributed in the hope that it will be useful, | |
23 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
24 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
25 ;; GNU General Public License for more details. | |
26 | |
27 ;; You should have received a copy of the GNU General Public License | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
28 ;; along with this program; see the file COPYING. If not, write to |
64085 | 29 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
30 ;; Boston, MA 02110-1301, USA. | |
18720 | 31 |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38167
diff
changeset
|
32 ;;; Commentary: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38167
diff
changeset
|
33 |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38167
diff
changeset
|
34 ;;; Code: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38167
diff
changeset
|
35 |
26817 | 36 (eval-when-compile |
37 (let ((load-path | |
36920 | 38 (if (and (boundp 'byte-compile-dest-file) |
39 (stringp byte-compile-dest-file)) | |
40 (cons (file-name-directory byte-compile-dest-file) load-path) | |
26817 | 41 load-path))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
42 (load "cc-bytecomp" nil t))) |
18720 | 43 |
36920 | 44 (cc-require 'cc-defs) |
45 (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
|
46 (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
|
47 ;; 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
|
48 ;; `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
|
49 |
7a3ac6c387fe
CC Mode 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 ;; 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
|
51 (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
|
52 (cc-bytecomp-obsolete-fun make-local-hook) ; Marked obsolete in Emacs 21.1. |
24282 | 53 |
18720 | 54 |
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
|
55 (defvar c-style-alist |
18720 | 56 '(("gnu" |
57 (c-basic-offset . 2) | |
58 (c-comment-only-line-offset . (0 . 0)) | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
59 (c-hanging-braces-alist . ((substatement-open before after))) |
18720 | 60 (c-offsets-alist . ((statement-block-intro . +) |
61 (knr-argdecl-intro . 5) | |
62 (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
|
63 (substatement-label . 0) |
18720 | 64 (label . 0) |
65 (statement-case-open . +) | |
66 (statement-cont . +) | |
67 (arglist-intro . c-lineup-arglist-intro-after-paren) | |
68 (arglist-close . c-lineup-arglist) | |
24282 | 69 (inline-open . 0) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
70 (brace-list-open . +))) |
18720 | 71 (c-special-indent-hook . c-gnu-impose-minimum) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
72 (c-block-comment-prefix . "")) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
73 |
18720 | 74 ("k&r" |
75 (c-basic-offset . 5) | |
76 (c-comment-only-line-offset . 0) | |
77 (c-offsets-alist . ((statement-block-intro . +) | |
78 (knr-argdecl-intro . 0) | |
79 (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
|
80 (substatement-label . 0) |
18720 | 81 (label . 0) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
82 (statement-cont . +)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
83 |
18720 | 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) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
94 (inexpr-class . 0)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
95 |
18720 | 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) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
103 (statement-cont . +)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
104 |
18720 | 105 ("whitesmith" |
106 (c-basic-offset . 4) | |
107 (c-comment-only-line-offset . 0) | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
108 ;; It's obvious that the CC Mode way of choosing anchor positions |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
109 ;; doesn't fit this style at all. :P |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
110 (c-offsets-alist . ((defun-open . +) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
111 (defun-close . c-lineup-whitesmith-in-block) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
112 (defun-block-intro . (add c-lineup-whitesmith-in-block |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
113 c-indent-multi-line-block)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
114 (class-open . +) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
115 (class-close . +) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
116 (inline-open . +) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
117 (inline-close . c-lineup-whitesmith-in-block) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
118 (knr-argdecl-intro . +) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
119 (block-open . 0) ; Get indentation from `statement' instead. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
120 (block-close . c-lineup-whitesmith-in-block) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
121 (brace-list-open . +) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
122 (brace-list-close . c-lineup-whitesmith-in-block) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
123 (brace-list-intro . (add c-lineup-whitesmith-in-block |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
124 c-indent-multi-line-block)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
125 (brace-list-entry . (add c-lineup-after-whitesmith-blocks |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
126 c-indent-multi-line-block)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
127 (brace-entry-open . (add c-lineup-after-whitesmith-blocks |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
128 c-indent-multi-line-block)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
129 (statement . (add c-lineup-after-whitesmith-blocks |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
130 c-indent-multi-line-block)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
131 (statement-block-intro . (add c-lineup-whitesmith-in-block |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
132 c-indent-multi-line-block)) |
26817 | 133 (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
|
134 (substatement-label . +) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
135 (label . 0) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
136 (arglist-intro . (add c-lineup-whitesmith-in-block |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
137 c-indent-multi-line-block)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
138 (arglist-cont . (add c-lineup-after-whitesmith-blocks |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
139 c-indent-multi-line-block)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
140 (arglist-cont-nonempty . (add c-lineup-whitesmith-in-block |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
141 c-indent-multi-line-block)) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
142 (arglist-close . c-lineup-whitesmith-in-block) |
26817 | 143 (inclass . c-lineup-whitesmith-in-block) |
144 (extern-lang-open . +) | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
145 (namespace-open . +) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
146 (module-open . +) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
147 (composition-open . +) |
26817 | 148 (extern-lang-close . +) |
149 (namespace-close . +) | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
150 (module-close . +) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
151 (composition-close . +) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
152 (inextern-lang . c-lineup-whitesmith-in-block) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
153 (innamespace . c-lineup-whitesmith-in-block) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
154 (inmodule . c-lineup-whitesmith-in-block) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
155 (incomposition . c-lineup-whitesmith-in-block) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
156 (inexpr-class . 0)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
157 |
18720 | 158 ("ellemtel" |
159 (c-basic-offset . 3) | |
160 (c-comment-only-line-offset . 0) | |
161 (c-hanging-braces-alist . ((substatement-open before after))) | |
162 (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
|
163 (substatement . +) |
18720 | 164 (substatement-open . 0) |
165 (case-label . +) | |
166 (access-label . -) | |
167 (inclass . ++) | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
168 (inline-open . 0)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
169 |
18720 | 170 ("linux" |
171 (c-basic-offset . 8) | |
172 (c-comment-only-line-offset . 0) | |
173 (c-hanging-braces-alist . ((brace-list-open) | |
24282 | 174 (brace-entry-open) |
18720 | 175 (substatement-open after) |
176 (block-close . c-snug-do-while))) | |
177 (c-cleanup-list . (brace-else-brace)) | |
178 (c-offsets-alist . ((statement-block-intro . +) | |
179 (knr-argdecl-intro . 0) | |
180 (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
|
181 (substatement-label . 0) |
18720 | 182 (label . 0) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
183 (statement-cont . +)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
184 |
18720 | 185 ("python" |
186 (indent-tabs-mode . t) | |
26817 | 187 (fill-column . 78) |
18720 | 188 (c-basic-offset . 8) |
189 (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
|
190 (inextern-lang . 0) |
86412da1174b
(c-style-alist) <python>:, knr-argdecl-intro == +
Richard M. Stallman <rms@gnu.org>
parents:
19376
diff
changeset
|
191 (arglist-intro . +) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
192 (knr-argdecl-intro . +))) |
18720 | 193 (c-hanging-braces-alist . ((brace-list-open) |
194 (brace-list-intro) | |
195 (brace-list-close) | |
24282 | 196 (brace-entry-open) |
18720 | 197 (substatement-open after) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
198 (block-close . c-snug-do-while))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
199 (c-block-comment-prefix . "")) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
200 |
18720 | 201 ("java" |
20918
8e64bd5b1b5f
(c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents:
20147
diff
changeset
|
202 (c-basic-offset . 4) |
18720 | 203 (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
|
204 ;; 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
|
205 (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
|
206 (topmost-intro-cont . +) |
18720 | 207 (statement-block-intro . +) |
208 (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
|
209 (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
|
210 (substatement-label . +) |
26817 | 211 (label . +) |
18720 | 212 (statement-case-open . +) |
213 (statement-cont . +) | |
214 (arglist-intro . c-lineup-arglist-intro-after-paren) | |
215 (arglist-close . c-lineup-arglist) | |
216 (access-label . 0) | |
217 (inher-cont . c-lineup-java-inher) | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
218 (func-decl-cont . c-lineup-java-throws)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
219 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
220 ;; awk style exists primarily for auto-newline settings. Otherwise it's |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
221 ;; pretty much like k&r. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
222 ("awk" |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
223 (c-basic-offset . 4) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
224 (c-comment-only-line-offset . 0) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
225 (c-hanging-braces-alist . ((defun-open after) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
226 (defun-close . c-snug-1line-defun-close) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
227 (substatement-open after) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
228 (block-close . c-snug-do-while))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
229 (c-hanging-semi&comma-criteria . nil) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
230 (c-cleanup-list . nil) ; You might want one-liner-defun here. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
231 (c-offsets-alist . ((statement-block-intro . +) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
232 (substatement-open . 0) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
233 (statement-cont . +)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
234 |
18720 | 235 ) |
236 "Styles of indentation. | |
237 Elements of this alist are of the form: | |
238 | |
239 (STYLE-STRING [BASE-STYLE] (VARIABLE . VALUE) [(VARIABLE . VALUE) ...]) | |
240 | |
241 where STYLE-STRING is a short descriptive string used to select a | |
242 style, VARIABLE is any Emacs variable, and VALUE is the intended value | |
243 for that variable when using the selected style. | |
244 | |
245 Optional BASE-STYLE if present, is a string and must follow | |
246 STYLE-STRING. BASE-STYLE names a style that this style inherits from. | |
26817 | 247 By default, all styles inherit from the \"user\" style, which is |
18720 | 248 computed at run time. Style loops generate errors. |
249 | |
250 Two variables are treated specially. When VARIABLE is | |
251 `c-offsets-alist', the VALUE is a list containing elements of the | |
252 form: | |
253 | |
254 (SYNTACTIC-SYMBOL . OFFSET) | |
255 | |
256 as described in `c-offsets-alist'. These are passed directly to | |
257 `c-set-offset' so there is no need to set every syntactic symbol in | |
258 your style, only those that are different from the default. | |
259 | |
260 When VARIABLE is `c-special-indent-hook', its VALUE is added to | |
261 `c-special-indent-hook' using `add-hook'. If VALUE is a list, each | |
262 element of the list is added with `add-hook'. | |
263 | |
264 Do not change this variable directly. Use the function `c-add-style' | |
265 to add new styles or modify existing styles (it is not a good idea to | |
266 modify existing styles -- you should create a new style that inherits | |
70742 | 267 the existing style).") |
18720 | 268 |
269 | |
270 ;; Functions that manipulate styles | |
26817 | 271 (defun c-set-style-1 (conscell dont-override) |
18720 | 272 ;; Set the style for one variable |
273 (let ((attr (car conscell)) | |
274 (val (cdr conscell))) | |
275 (cond | |
276 ;; first special variable | |
277 ((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
|
278 (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
|
279 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
|
280 (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
|
281 (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
|
282 (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
|
283 (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
|
284 (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
|
285 (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
|
286 (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
|
287 val))) |
18720 | 288 ;; second special variable |
289 ((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
|
290 ;; 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
|
291 ;; hooks? |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
292 (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
|
293 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
|
294 (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
|
295 (default-value 'c-special-indent-hook))) |
26817 | 296 (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
|
297 (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
|
298 (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
|
299 val) |
b022aba47c59
(c-set-style, c-set-style-1): Added another state for the
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
300 (add-hook 'c-special-indent-hook val t t)))) |
18720 | 301 ;; 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
|
302 (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
|
303 (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
|
304 (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
|
305 (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
|
306 (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
|
307 '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
|
308 (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
|
309 ;; 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
|
310 ;; 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
|
311 (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
|
312 (c-setup-paragraph-variables))))))) |
18720 | 313 |
26817 | 314 (defun c-get-style-variables (style basestyles) |
315 ;; Return all variables in a style by resolving inheritances. | |
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
|
316 (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
|
317 (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
|
318 (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
|
319 (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
|
320 (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
|
321 (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
|
322 (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
|
323 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
|
324 (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
|
325 (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
|
326 (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
|
327 (setq vars (cdr vars)))))) |
26817 | 328 (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
|
329 (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
|
330 (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
|
331 (copy-alist vars))))))) |
26817 | 332 |
18720 | 333 (defvar c-set-style-history nil) |
334 | |
335 ;;;###autoload | |
26817 | 336 (defun c-set-style (stylename &optional dont-override) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
337 "Set the current buffer to use the style STYLENAME. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
338 STYLENAME, a string, must be an existing CC Mode style - These are contained |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
339 in the variable `c-style-alist'. |
18720 | 340 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
341 The variable `c-indentation-style' will get set to STYLENAME. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
342 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
343 \"Setting the style\" is done by setting CC Mode's \"style variables\" to the |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
344 values indicated by the pertinent entry in `c-style-alist'. Other variables |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
345 might get set too. |
26817 | 346 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
347 If DONT-OVERRIDE is neither nil nor t, style variables whose default values |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
348 have been set (more precisely, whose default values are not the symbol |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
349 `set-from-style') will not be changed. This avoids overriding global settings |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
350 done in ~/.emacs. It is useful to call c-set-style from a mode hook in this |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
351 way. |
26817 | 352 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
353 If DONT-OVERRIDE is t, style variables that already have values (i.e., whose |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
354 values are not the symbol `set-from-style') will not be overridden. CC Mode |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
355 calls c-set-style internally in this way whilst initializing a buffer; if |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
356 cc-set-style is called like this from anywhere else, it will usually behave as |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
357 a null operation." |
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
|
358 (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
|
359 (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
|
360 (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
|
361 mode-name))) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
362 (completing-read prompt c-style-alist nil t nil |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
363 'c-set-style-history |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
364 c-indentation-style)))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
365 (or c-buffer-is-cc-mode |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
366 (error "Buffer %s is not a CC Mode buffer (c-set-style)" (buffer-name))) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52608
diff
changeset
|
367 (or (stringp stylename) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52608
diff
changeset
|
368 (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
|
369 (c-initialize-builtin-style) |
26817 | 370 (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
|
371 (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
|
372 ;; 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
|
373 ;; 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
|
374 ;; 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
|
375 ;; 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
|
376 ;; 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
|
377 (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
|
378 (default-value 'c-special-indent-hook))) |
26817 | 379 (mapcar (lambda (elem) |
380 (c-set-style-1 elem dont-override)) | |
381 ;; 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
|
382 ;; 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
|
383 (if (eq dont-override t) (nreverse vars) vars))) |
18720 | 384 (setq c-indentation-style stylename) |
385 (c-keep-region-active)) | |
386 | |
387 ;;;###autoload | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
388 (defun c-add-style (style description &optional set-p) |
18720 | 389 "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
|
390 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
|
391 is an association list describing the style and must be of the form: |
18720 | 392 |
393 ([BASESTYLE] (VARIABLE . VALUE) [(VARIABLE . VALUE) ...]) | |
394 | |
395 See the variable `c-style-alist' for the semantics of BASESTYLE, | |
396 VARIABLE and VALUE. This function also sets the current style to | |
397 STYLE using `c-set-style' if the optional SET-P flag is non-nil." | |
398 (interactive | |
399 (let ((stylename (completing-read "Style to add: " c-style-alist | |
400 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
|
401 (descr (eval-minibuffer "Style description: "))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
402 (list stylename descr |
18720 | 403 (y-or-n-p "Set the style too? ")))) |
404 (setq style (downcase style)) | |
405 (let ((s (assoc style c-style-alist))) | |
406 (if s | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
407 (setcdr s (copy-alist description)) ; replace |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
408 (setq c-style-alist (cons (cons style description) c-style-alist)))) |
18720 | 409 (and set-p (c-set-style style))) |
410 | |
411 | |
412 (defvar c-read-offset-history nil) | |
413 | |
414 (defun c-read-offset (langelem) | |
415 ;; read new offset value for LANGELEM from minibuffer. return a | |
416 ;; legal value only | |
26817 | 417 (let* ((oldoff (cdr-safe (or (assq langelem c-offsets-alist) |
418 (assq langelem (get 'c-offsets-alist | |
419 'c-stylevar-fallback))))) | |
24282 | 420 (symname (symbol-name langelem)) |
421 (defstr (format "(default %s): " oldoff)) | |
36920 | 422 (errmsg (concat "Offset must be int, func, var, vector, list, " |
24282 | 423 "or [+,-,++,--,*,/] " |
424 defstr)) | |
425 (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
|
426 (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
|
427 (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
|
428 (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
|
429 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 ;; 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
|
431 ;; 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
|
432 (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
|
433 (define-key keymap " " 'self-insert-command) |
18720 | 434 (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
|
435 (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
|
436 '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
|
437 (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
|
438 (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
|
439 (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
|
440 ;; 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
|
441 ;; 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
|
442 (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
|
443 (setq prompt errmsg))) |
18720 | 444 offset)) |
445 | |
19212
024594beef65
(c-set-offset): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
18845
diff
changeset
|
446 ;;;###autoload |
26817 | 447 (defun c-set-offset (symbol offset &optional ignored) |
18720 | 448 "Change the value of a syntactic element symbol in `c-offsets-alist'. |
449 SYMBOL is the syntactic element symbol to change and OFFSET is the new | |
26817 | 450 offset for that syntactic element. The optional argument is not used |
451 and exists only for compatibility reasons." | |
18720 | 452 (interactive |
453 (let* ((langelem | |
454 (intern (completing-read | |
455 (concat "Syntactic symbol to change" | |
456 (if current-prefix-arg " or add" "") | |
457 ": ") | |
458 (mapcar | |
459 #'(lambda (langelem) | |
460 (cons (format "%s" (car langelem)) nil)) | |
26817 | 461 (get 'c-offsets-alist 'c-stylevar-fallback)) |
18720 | 462 nil (not current-prefix-arg) |
463 ;; initial contents tries to be the last element | |
464 ;; on the syntactic analysis list for the current | |
465 ;; line | |
49660
425dcb97eca4
(c-set-offset): Don't find a default syntactic element through
Martin Stjernholm <mast@lysator.liu.se>
parents:
49478
diff
changeset
|
466 (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
|
467 (c-save-buffer-state |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
468 ((syntax (c-guess-basic-syntax)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
469 (len (length syntax)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
470 (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
|
471 (cons ic 0))) |
18720 | 472 ))) |
473 (offset (c-read-offset langelem))) | |
474 (list langelem offset current-prefix-arg))) | |
475 ;; 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
|
476 (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
|
477 (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
|
478 (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
|
479 (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
|
480 (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
|
481 (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
|
482 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
|
483 (c-benign-error "%s is not a valid syntactic symbol" symbol)))) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
484 (c-benign-error "Invalid indentation setting for symbol %s: %S" |
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
|
485 symbol offset)) |
18720 | 486 (c-keep-region-active)) |
487 | |
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
|
488 |
7a3ac6c387fe
CC Mode 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 (defun c-setup-paragraph-variables () |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
490 "Fix things up for paragraph recognition and filling inside comments and |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
491 strings by incorporating the values of `c-comment-prefix-regexp', |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
492 `sentence-end', `paragraph-start' and `paragraph-separate' in the relevant |
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
|
493 variables." |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
494 |
52608
fae5ff03687a
(c-setup-paragraph-variables): Made it interactive.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
495 (interactive) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
496 (or c-buffer-is-cc-mode |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
497 (error "Buffer %s is not a CC Mode buffer (c-setup-paragraph-variables)" |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
498 (buffer-name))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
499 ;; Set up the values for use in comments. |
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 (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
|
501 (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
|
502 (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
|
503 (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
|
504 c-comment-prefix-regexp)) |
52608
fae5ff03687a
(c-setup-paragraph-variables): Made it interactive.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
505 |
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
|
506 (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
|
507 (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
|
508 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
509 (setq paragraph-start (concat comment-line-prefix |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
510 c-paragraph-start |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
511 "\\|" |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
512 page-delimiter) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
513 paragraph-separate (concat comment-line-prefix |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
514 c-paragraph-separate |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
515 "\\|" |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
516 page-delimiter) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
517 paragraph-ignore-fill-prefix t |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
518 adaptive-fill-mode t |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
519 adaptive-fill-regexp |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
520 (concat comment-line-prefix |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
521 (if (default-value 'adaptive-fill-regexp) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
522 (concat "\\(" |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
523 (default-value 'adaptive-fill-regexp) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
524 "\\)") |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
525 ""))) |
52608
fae5ff03687a
(c-setup-paragraph-variables): Made it interactive.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
526 |
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
|
527 (when (boundp 'adaptive-fill-first-line-regexp) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
528 ;; XEmacs adaptive fill mode doesn't have this. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
529 (make-local-variable 'adaptive-fill-first-line-regexp) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
530 (setq adaptive-fill-first-line-regexp |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
531 (concat "\\`" comment-line-prefix |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
532 ;; Maybe we should incorporate the old value here, |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
533 ;; but then we have to do all sorts of kludges to |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
534 ;; deal with the \` and \' it probably contains. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
535 "\\'")))) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
536 |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
537 ;; Set up the values for use in strings. These are the default |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
538 ;; paragraph-start/separate values, enhanced to accept escaped EOLs as |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
539 ;; whitespace. Used in c-beginning/end-of-sentence-in-string in cc-cmds. |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
540 (setq c-string-par-start |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
541 ;;(concat "\\(" (default-value 'paragraph-start) "\\)\\|[ \t]*\\\\$")) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
542 "\f\\|[ \t]*\\\\?$") |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
543 (setq c-string-par-separate |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
544 ;;(concat "\\(" (default-value 'paragraph-separate) "\\)\\|[ \t]*\\\\$")) |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
545 "[ \t\f]*\\\\?$") |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
546 (setq c-sentence-end-with-esc-eol |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
547 (concat "\\(\\(" (c-default-value-sentence-end) "\\)" |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
548 ;; N.B.: "$" would be illegal when not enclosed like "\\($\\)". |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
549 "\\|" "[.?!][]\"')}]* ?\\\\\\($\\)[ \t\n]*" |
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
550 "\\)"))) |
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
|
551 |
7a3ac6c387fe
CC Mode 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 |
7a3ac6c387fe
CC Mode 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 ;; 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
|
554 |
7a3ac6c387fe
CC Mode 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 (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
|
556 (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
|
557 (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
|
558 |
7a3ac6c387fe
CC Mode 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 (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
|
560 "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
|
561 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
|
562 `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
|
563 `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
|
564 `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
|
565 ;; 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
|
566 ;; only. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
567 |
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
|
568 ;; 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
|
569 ;; 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
|
570 ;; `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
|
571 (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
|
572 (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
|
573 (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
|
574 (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
|
575 (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
|
576 (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
|
577 (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
|
578 (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
|
579 (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
|
580 (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
|
581 (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
|
582 (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
|
583 (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
|
584 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
|
585 (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
|
586 (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
|
587 (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
|
588 filladapt-token-conversion-table)))) |
26817 | 589 |
24282 | 590 |
18720 | 591 (defun c-initialize-builtin-style () |
592 ;; Dynamically append the default value of most variables. This is | |
593 ;; crucial because future c-set-style calls will always reset the | |
594 ;; variables first to the `cc-mode' style before instituting the new | |
595 ;; style. Only do this once! | |
24282 | 596 (unless (get 'c-initialize-builtin-style 'is-run) |
597 (put 'c-initialize-builtin-style 'is-run t) | |
36920 | 598 ;;(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
|
599 (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
|
600 (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
|
601 (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
|
602 (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
|
603 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
|
604 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
|
605 (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
|
606 (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
|
607 (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
|
608 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
|
609 ((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
|
610 (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
|
611 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
|
612 (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
|
613 (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
|
614 (c-add-style "cc-mode" '("user"))) |
24282 | 615 (if c-style-variables-are-local-p |
616 (c-make-styles-buffer-local)))) | |
19254
81353d4e05b7
(c-styles-alist): In "java" style, set
Richard M. Stallman <rms@gnu.org>
parents:
19212
diff
changeset
|
617 |
20918
8e64bd5b1b5f
(c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents:
20147
diff
changeset
|
618 (defun c-make-styles-buffer-local (&optional this-buf-only-p) |
18720 | 619 "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
|
620 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
|
621 buffer local only in the current buffer. Otherwise they'll be made |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
622 permanently buffer local in any buffer that changes their values. |
18720 | 623 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49660
diff
changeset
|
624 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
|
625 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
|
626 any reason to call this function directly." |
18720 | 627 |
628 ;; 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
|
629 (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
|
630 '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
|
631 'make-variable-buffer-local)) |
26817 | 632 (varsyms (cons 'c-indentation-style (copy-alist c-style-variables)))) |
633 (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
|
634 (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
|
635 ;; 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
|
636 (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
|
637 (make-local-hook 'c-special-indent-hook) |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
638 (with-no-warnings (make-variable-buffer-local 'c-special-indent-hook)) |
26817 | 639 (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
|
640 )) |
8e64bd5b1b5f
(c-make-styles-buffer-local): Take an optional argument which switches
Richard M. Stallman <rms@gnu.org>
parents:
20147
diff
changeset
|
641 |
18720 | 642 |
643 | |
36920 | 644 (cc-provide 'cc-styles) |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38167
diff
changeset
|
645 |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
65811
diff
changeset
|
646 ;;; arch-tag: c764f61a-96ba-484a-a68f-101c0e9d5d2c |
18720 | 647 ;;; cc-styles.el ends here |