comparison lisp/modes/cc-mode.el @ 110:fe104dbd9147 r20-1b7

Import from CVS: tag r20-1b7
author cvs
date Mon, 13 Aug 2007 09:19:45 +0200
parents c7528f8e288d
children 8619ce7e4c50
comparison
equal deleted inserted replaced
109:e183fc049578 110:fe104dbd9147
1 ;;; cc-mode.el --- major mode for editing C, C++, Objective-C, and Java code 1 ;;; cc-mode.el --- major mode for editing C, C++, Objective-C, and Java code
2 2
3 ;; Copyright (C) 1985, 87, 92, 93, 94, 95, 96 Free Software Foundation, Inc. 3 ;; Copyright (C) 1985,87,92,93,94,95,96,97 Free Software Foundation, Inc.
4 4
5 ;; Authors: 1992-1996 Barry A. Warsaw 5 ;; Authors: 1992-1997 Barry A. Warsaw
6 ;; 1987 Dave Detlefs and Stewart Clamen 6 ;; 1987 Dave Detlefs and Stewart Clamen
7 ;; 1985 Richard M. Stallman 7 ;; 1985 Richard M. Stallman
8 ;; Created: a long, long, time ago. adapted from the original c-mode.el 8 ;; Created: a long, long, time ago. adapted from the original c-mode.el
9 ;; Version: 4.322 9 ;; Version: 4.379
10 ;; Last Modified: 1996/10/04 20:28:14 10 ;; Last Modified: 1997/03/10 00:59:10
11 ;; Keywords: c languages oop 11 ;; Keywords: c languages oop
12 12
13 ;; NOTE: Read the commentary below for the right way to submit bug reports! 13 ;; NOTE: Read the commentary below for the right way to submit bug reports!
14 ;; NOTE: See the accompanying texinfo manual for details on using this mode! 14 ;; NOTE: See the accompanying texinfo manual for details on using this mode!
15 15
30 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 30 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
31 ;; Boston, MA 02111-1307, USA. 31 ;; Boston, MA 02111-1307, USA.
32 32
33 ;;; Commentary: 33 ;;; Commentary:
34 34
35 ;; This package provides modes in GNU Emacs for editing C, C++, 35 ;; This package provides modes in GNU Emacs for editing C, C++,
36 ;; Objective-C, and Java code. It is intended to be a replacement for 36 ;; Objective-C, and Java code. It is intended to be a replacement for
37 ;; c-mode.el (a.k.a. BOCM -- Boring Old C-Mode), and c++-mode.el 37 ;; c-mode.el (a.k.a. BOCM -- Boring Old C-Mode), c++-mode.el,
38 ;; (a.k.a cplus-md.el and cplus-md1.el), both of which are ancestors 38 ;; cplus-md.el, and cplus-md1.el, all of which are in some way
39 ;; of this file. A number of important improvements have been made, 39 ;; ancestors of this file. A number of important improvements have
40 ;; briefly: complete K&R C, ANSI C, `ARM' C++, Objective-C, and Java 40 ;; been made, briefly: complete K&R C, ANSI C, `ARM' C++, Objective-C,
41 ;; support with consistent indentation across all modes, more 41 ;; and Java support with consistent indentation across all modes, more
42 ;; intuitive indentation controlling variables, compatibility across 42 ;; intuitive indentation controlling variables, compatibility across
43 ;; all known Emacsen, nice new features, and tons of bug fixes. This 43 ;; all known Emacsen, nice new features, and tons of bug fixes. This
44 ;; package is called "cc-mode" to distinguish it from its ancestors, 44 ;; package is called "CC Mode" to distinguish it from its ancestors,
45 ;; but there really is no top-level cc-mode. Usage and programming 45 ;; but there is no cc-mode command. Usage and programming details are
46 ;; details are contained in an accompanying texinfo manual. 46 ;; contained in an accompanying texinfo manual.
47 47
48 ;; NOTE: This mode does not perform font-locking (a.k.a syntactic 48 ;; NOTE: This mode does not perform font-locking (a.k.a syntactic
49 ;; coloring, keyword highlighting, etc.). Typically this is done by a 49 ;; coloring, keyword highlighting, etc.) for any of the supported
50 ;; package called font-lock.el which I do *not* maintain. You should 50 ;; modes. Typically this is done by a package called font-lock.el
51 ;; contact the Emacs maintainer for questions about coloring or 51 ;; which I do *not* maintain. You should contact the Emacs
52 ;; highlighting in any language mode. 52 ;; maintainers for questions about coloring or highlighting in any
53 ;; language mode.
53 54
54 ;; To submit bug reports, type "C-c C-b". These will be sent to 55 ;; To submit bug reports, type "C-c C-b". These will be sent to
55 ;; bug-gnu-emacs@prep.ai.mit.edu as well as cc-mode-help@python.org, 56 ;; bug-gnu-emacs@prep.ai.mit.edu as well as cc-mode-help@python.org,
56 ;; and I'll read about them there (the former is mirrored as the 57 ;; and I'll read about them there (the former is mirrored as the
57 ;; Usenet newsgroup gnu.emacs.bug). Questions can sent to 58 ;; Usenet newsgroup gnu.emacs.bug). Questions can sent to
58 ;; help-gnu-emacs@prep.ai.mit.edu (mirrored as gnu.emacs.help) or 59 ;; help-gnu-emacs@prep.ai.mit.edu (mirrored as gnu.emacs.help) and/or
59 ;; cc-mode-help@python.org. Please do not send bugs or questions to 60 ;; cc-mode-help@python.org. Please do not send bugs or questions to
60 ;; my personal account. 61 ;; my personal account.
61 62
62 ;; YOU CAN IGNORE ALL BYTE-COMPILER WARNINGS. They are the result of 63 ;; YOU CAN IGNORE ALL BYTE-COMPILER WARNINGS. They are the result of
63 ;; the multi-Emacsen support. Emacs 19 (from the FSF), XEmacs 19 64 ;; the cross-Emacsen support. GNU Emacs 19 (from the FSF), GNU XEmacs
64 ;; (formerly Lucid Emacs), and GNU Emacs 18 all do things differently 65 ;; 19 (formerly Lucid Emacs), and GNU Emacs 18 all do things
65 ;; and there's no way to shut the byte-compiler up at the necessary 66 ;; differently and there's no way to shut the byte-compiler up at the
66 ;; granularity. Let me say this again: YOU CAN IGNORE ALL 67 ;; necessary granularity. Let me say this again: YOU CAN IGNORE ALL
67 ;; BYTE-COMPILER WARNINGS (you'd be surprised at how many people don't 68 ;; BYTE-COMPILER WARNINGS (you'd be surprised at how many people don't
68 ;; follow this advice :-). 69 ;; follow this advice :-).
69 70
70 ;; If your Emacs is dumped with c-mode.el and/or c++-mode.el, you will 71 ;; As of this writing (24-Feb-1997), CC Mode comes with the latest
71 ;; need to add the following to your .emacs file before any other 72 ;; Emacs and XEmacs distributions (19.34 and 19.14 respectively), but
72 ;; reference to c-mode or c++-mode: 73 ;; is no longer pre-loaded by default. To use the latest version of
73 ;; 74 ;; CC Mode, you need only make sure that this copy of cc-mode.el is
74 ;; (fmakunbound 'c-mode) 75 ;; found first on your load-path.
75 ;; (makunbound 'c-mode-map) 76
76 ;; (fmakunbound 'c++-mode) 77 ;; If your Emacs is pre-loaded with any version of cc-mode.el,
77 ;; (makunbound 'c++-mode-map) 78 ;; c-mode.el, or c++-mode.el, you will need to consult the
78 ;; (makunbound 'c-style-alist) 79 ;; cc-mode.texinfo manual for details on upgrading your Emacs.
79
80 ;; If your Emacs comes with cc-mode already (and as of 5-Jul-1996
81 ;; XEmacs 19.14 and Emacs 19.31 both do), you only need to add the
82 ;; following to use the latest version of cc-mode:
83 ;;
84 ;; (load "cc-mode")
85 ;;
86 ;; Make sure the new version is earlier on your load-path.
87 80
88 ;; There are four major mode entry points provided by this package, 81 ;; There are four major mode entry points provided by this package,
89 ;; one for editing C++ code, one for editing C code (both K&R and 82 ;; one for editing C++ code, one for editing C code (both K&R and
90 ;; ANSI), one for editing Objective-C code, and one for editing Java 83 ;; ANSI), one for editing Objective-C code, and one for editing Java
91 ;; code. The commands are M-x c-mode, M-x c++-mode, M-x objc-mode, 84 ;; code. The commands are M-x c-mode, M-x c++-mode, M-x objc-mode,
92 ;; and M-x java-mode. 85 ;; and M-x java-mode.
93 86
94 ;; If you are using an old version of Emacs which does not come
95 ;; with cc-mode.el, you will need to do these things
96 ;; to use it:
97 ;;
98 ;; (autoload 'c++-mode "cc-mode" "C++ Editing Mode" t)
99 ;; (autoload 'c-mode "cc-mode" "C Editing Mode" t)
100 ;; (autoload 'objc-mode "cc-mode" "Objective-C Editing Mode" t)
101 ;; (autoload 'java-mode "cc-mode" "Java Editing Mode" t)
102 ;; (setq auto-mode-alist
103 ;; (append '(("\\.C$" . c++-mode)
104 ;; ("\\.cc$" . c++-mode)
105 ;; ("\\.c$" . c-mode)
106 ;; ("\\.h$" . c-mode)
107 ;; ("\\.m$" . objc-mode)
108 ;; ("\\.java$" . java-mode)
109 ;; ) auto-mode-alist))
110 ;;
111 ;; You do not need these changes in Emacs versions that come with cc-mode.
112
113 ;; Many, many thanks go out to all the folks on the beta test list. 87 ;; Many, many thanks go out to all the folks on the beta test list.
114 ;; Without their patience, testing, insight, code contributions, and 88 ;; Without their patience, testing, insight, code contributions, and
115 ;; encouragement cc-mode.el would be a far inferior package. 89 ;; encouragement CC Mode would be a far inferior package.
116 90
117 ;; You can get the latest version of cc-mode, including PostScript 91 ;; You can get the latest version of CC Mode, including PostScript
118 ;; documentation and separate individual files from: 92 ;; documentation and separate individual files from:
119 ;; 93 ;;
120 ;; http://www.python.org/ftp/emacs/ 94 ;; http://www.python.org/ftp/emacs/
121 95
122 ;; Or if you don't have access to the World Wide Web, through 96 ;; Or if you don't have access to the World Wide Web, through
140 (defvar c-echo-syntactic-information-p nil 114 (defvar c-echo-syntactic-information-p nil
141 "*If non-nil, syntactic info is echoed when the line is indented.") 115 "*If non-nil, syntactic info is echoed when the line is indented.")
142 (defvar c-basic-offset 4 116 (defvar c-basic-offset 4
143 "*Amount of basic offset used by + and - symbols in `c-offsets-alist'.") 117 "*Amount of basic offset used by + and - symbols in `c-offsets-alist'.")
144 118
145 (defvar c-offsets-alist 119 (defconst c-offsets-alist
146 '((string . -1000) 120 '((string . -1000)
147 (c . c-lineup-C-comments) 121 (c . c-lineup-C-comments)
148 (defun-open . 0) 122 (defun-open . 0)
149 (defun-close . 0) 123 (defun-close . 0)
150 (defun-block-intro . +) 124 (defun-block-intro . +)
151 (class-open . 0) 125 (class-open . 0)
152 (class-close . 0) 126 (class-close . 0)
153 (inline-open . +) 127 (inline-open . +)
154 (inline-close . 0) 128 (inline-close . 0)
155 (ansi-funcdecl-cont . +) 129 (func-decl-cont . +)
156 (knr-argdecl-intro . +) 130 (knr-argdecl-intro . +)
157 (knr-argdecl . 0) 131 (knr-argdecl . 0)
158 (topmost-intro . 0) 132 (topmost-intro . 0)
159 (topmost-intro-cont . 0) 133 (topmost-intro-cont . 0)
160 (member-init-intro . +) 134 (member-init-intro . +)
202 "*Association list of syntactic element symbols and indentation offsets. 176 "*Association list of syntactic element symbols and indentation offsets.
203 As described below, each cons cell in this list has the form: 177 As described below, each cons cell in this list has the form:
204 178
205 (SYNTACTIC-SYMBOL . OFFSET) 179 (SYNTACTIC-SYMBOL . OFFSET)
206 180
207 When a line is indented, cc-mode first determines the syntactic 181 When a line is indented, CC Mode first determines the syntactic
208 context of the line by generating a list of symbols called syntactic 182 context of the line by generating a list of symbols called syntactic
209 elements. This list can contain more than one syntactic element and 183 elements. This list can contain more than one syntactic element and
210 the global variable `c-syntactic-context' contains the context list 184 the global variable `c-syntactic-context' contains the context list
211 for the line being indented. Each element in this list is actually a 185 for the line being indented. Each element in this list is actually a
212 cons cell of the syntactic symbol and a buffer position. This buffer 186 cons cell of the syntactic symbol and a buffer position. This buffer
213 position is called the relative indent point for the line. Some 187 position is called the relative indent point for the line. Some
214 syntactic symbols may not have a relative indent point associated with 188 syntactic symbols may not have a relative indent point associated with
215 them. 189 them.
216 190
217 After the syntactic context list for a line is generated, cc-mode 191 After the syntactic context list for a line is generated, CC Mode
218 calculates the absolute indentation for the line by looking at each 192 calculates the absolute indentation for the line by looking at each
219 syntactic element in the list. First, it compares the syntactic 193 syntactic element in the list. First, it compares the syntactic
220 element against the SYNTACTIC-SYMBOL's in `c-offsets-alist'. When it 194 element against the SYNTACTIC-SYMBOL's in `c-offsets-alist'. When it
221 finds a match, it adds the OFFSET to the column of the relative indent 195 finds a match, it adds the OFFSET to the column of the relative indent
222 point. The sum of this calculation for each element in the syntactic 196 point. The sum of this calculation for each element in the syntactic
223 list is the absolute offset for line being indented. 197 list is the absolute offset for line being indented.
224 198
225 If the syntactic element does not match any in the `c-offsets-alist', 199 If the syntactic element does not match any in the `c-offsets-alist',
226 an error is generated if `c-strict-syntax-p' is non-nil, otherwise 200 an error is generated if `c-strict-syntax-p' is non-nil, otherwise the
227 the element is ignored. 201 element is ignored.
228 202
229 Actually, OFFSET can be an integer, a function, a variable, or one of 203 Actually, OFFSET can be an integer, a function, a variable, or one of
230 the following symbols: `+', `-', `++', `--', `*', or `/'. These 204 the following symbols: `+', `-', `++', `--', `*', or `/'. These
231 latter designate positive or negative multiples of `c-basic-offset', 205 latter designate positive or negative multiples of `c-basic-offset',
232 respectively: *1, *-1, *2, *-2, *0.5, and *-0.5. If OFFSET is a 206 respectively: *1, *-1, *2, *-2, *0.5, and *-0.5. If OFFSET is a
243 defun-block-intro -- the first line in a top-level defun 217 defun-block-intro -- the first line in a top-level defun
244 class-open -- brace that opens a class definition 218 class-open -- brace that opens a class definition
245 class-close -- brace that closes a class definition 219 class-close -- brace that closes a class definition
246 inline-open -- brace that opens an in-class inline method 220 inline-open -- brace that opens an in-class inline method
247 inline-close -- brace that closes an in-class inline method 221 inline-close -- brace that closes an in-class inline method
248 ansi-funcdecl-cont -- the nether region between an ANSI function 222 func-decl-cont -- the nether region between a function
249 declaration and the defun opening brace 223 declaration and the defun opening brace.
224 In C++ and Java, this can include `throws'
225 declarations
250 knr-argdecl-intro -- first line of a K&R C argument declaration 226 knr-argdecl-intro -- first line of a K&R C argument declaration
251 knr-argdecl -- subsequent lines in a K&R C argument declaration 227 knr-argdecl -- subsequent lines in a K&R C argument declaration
252 topmost-intro -- the first line in a topmost construct definition 228 topmost-intro -- the first line in a topmost construct definition
253 topmost-intro-cont -- topmost definition continuation lines 229 topmost-intro-cont -- topmost definition continuation lines
254 member-init-intro -- first line in a member initialization list 230 member-init-intro -- first line in a member initialization list
297 (defvar c-tab-always-indent t 273 (defvar c-tab-always-indent t
298 "*Controls the operation of the TAB key. 274 "*Controls the operation of the TAB key.
299 If t, hitting TAB always just indents the current line. If nil, 275 If t, hitting TAB always just indents the current line. If nil,
300 hitting TAB indents the current line if point is at the left margin or 276 hitting TAB indents the current line if point is at the left margin or
301 in the line's indentation, otherwise it insert a `real' tab character 277 in the line's indentation, otherwise it insert a `real' tab character
302 \(see note\). If other than nil or t, then tab is inserted only within 278 \(see note\). If other than nil or t, then tab is inserted only
303 literals -- defined as comments and strings -- and inside preprocessor 279 within literals -- defined as comments and strings -- and inside
304 directives, but line is always reindented. 280 preprocessor directives, but line is always reindented.
305 281
306 Note: The value of `indent-tabs-mode' will determine whether a real 282 Note: The value of `indent-tabs-mode' will determine whether a real
307 tab character will be inserted, or the equivalent number of space. 283 tab character will be inserted, or the equivalent number of space.
308 When inserting a tab, actually the function stored in the variable 284 When inserting a tab, actually the function stored in the variable
309 `c-insert-tab-function' is called. 285 `c-insert-tab-function' is called.
331 "*Specifies how comment-only lines should be indented. 307 "*Specifies how comment-only lines should be indented.
332 When this variable is non-nil, comment-only lines are indented 308 When this variable is non-nil, comment-only lines are indented
333 according to syntactic analysis via `c-offsets-alist', even when 309 according to syntactic analysis via `c-offsets-alist', even when
334 \\[indent-for-comment] is used.") 310 \\[indent-for-comment] is used.")
335 311
336 (defvar c-block-comments-indent-p nil
337 "*Specifies how to re-indent C style block comments.
338
339 Examples of the supported styles of C block comment indentation are
340 shown below. When this variable is nil, block comments are indented
341 as shown in styles 1 through 4. If this variable is non-nil, block
342 comments are indented as shown in style 5.
343
344 Note that cc-mode does not automatically insert any stars or block
345 comment delimiters. You must type these in manually. This variable
346 only controls how the lines within the block comment are indented when
347 you hit ``\\[c-indent-command]''.
348
349 style 1: style 2 (GNU): style 3: style 4: style 5:
350 /* /* Blah /* /* /*
351 blah blah. */ * blah ** blah blah
352 blah * blah ** blah blah
353 */ */ */ */")
354
355 (defvar c-cleanup-list '(scope-operator) 312 (defvar c-cleanup-list '(scope-operator)
356 "*List of various C/C++/ObjC constructs to \"clean up\". 313 "*List of various C/C++/ObjC constructs to \"clean up\".
357 These clean ups only take place when the auto-newline feature is turned 314 These clean ups only take place when the auto-newline feature is
358 on, as evidenced by the `/a' or `/ah' appearing next to the mode name. 315 turned on, as evidenced by the `/a' or `/ah' appearing next to the
359 Valid symbols are: 316 mode name. Valid symbols are:
360 317
361 brace-else-brace -- cleans up `} else {' constructs by placing entire 318 brace-else-brace -- cleans up `} else {' constructs by placing entire
362 construct on a single line. This clean up only 319 construct on a single line. This clean up
363 takes place when there is nothing but white 320 only takes place when there is nothing but
364 space between the braces and the `else'. Clean 321 white space between the braces and the `else'.
365 up occurs when the open-brace after the `else' 322 Clean up occurs when the open-brace after the
366 is typed. 323 `else' is typed.
324 brace-elseif-brace -- similar to brace-else-brace, but cleans up
325 `} else if {' constructs.
367 empty-defun-braces -- cleans up empty defun braces by placing the 326 empty-defun-braces -- cleans up empty defun braces by placing the
368 braces on the same line. Clean up occurs when 327 braces on the same line. Clean up occurs when
369 the defun closing brace is typed. 328 the defun closing brace is typed.
370 defun-close-semi -- cleans up the terminating semi-colon on defuns 329 defun-close-semi -- cleans up the terminating semi-colon on defuns
371 by placing the semi-colon on the same line as 330 by placing the semi-colon on the same line as
438 397
439 If every function in the list is called with no determination made, 398 If every function in the list is called with no determination made,
440 then no newline is inserted.") 399 then no newline is inserted.")
441 400
442 (defvar c-hanging-comment-ender-p t 401 (defvar c-hanging-comment-ender-p t
443 "*If nil, `c-fill-paragraph' leaves C block comment enders on their own line. 402 "*Controls what \\[fill-paragraph] does to C block comment enders.
444 Default value is t, which inhibits leaving block comment ending string 403 When set to nil, C block comment enders are left on their own line.
445 `*/' on a line by itself. This is BOCM's sole behavior.") 404 When set to t, block comment enders will be placed at the end of the
405 previous line (i.e. they `hang' on that line).")
406
407 (defvar c-hanging-comment-starter-p t
408 "*Controls what \\[fill-paragraph] does to C block comment starters.
409 When set to nil, C block comment starters are left on their own line.
410 When set to t, text that follows a block comment starter will be
411 placed on the same line as the block comment starter (i.e. the text
412 `hangs' on that line).")
446 413
447 (defvar c-backslash-column 48 414 (defvar c-backslash-column 48
448 "*Column to insert backslashes when macroizing a region.") 415 "*Column to insert backslashes when macroizing a region.")
449 (defvar c-special-indent-hook nil 416 (defvar c-special-indent-hook nil
450 "*Hook for user defined special indentation adjustments. 417 "*Hook for user defined special indentation adjustments.
458 "*Minimum indentation for labels and case tags in `gnu' style.") 425 "*Minimum indentation for labels and case tags in `gnu' style.")
459 426
460 (defvar c-progress-interval 5 427 (defvar c-progress-interval 5
461 "*Interval used to update progress status during long re-indentation. 428 "*Interval used to update progress status during long re-indentation.
462 If a number, percentage complete gets updated after each interval of 429 If a number, percentage complete gets updated after each interval of
463 that many seconds. Set to nil to inhibit updating. This is only 430 that many seconds. Set to nil to inhibit updating. This is only
464 useful for Emacs 19.") 431 useful for Emacs 19.")
465 432
466 (defconst c-style-alist 433 (defconst c-style-alist
467 '(("gnu" 434 '(("gnu"
468 (c-basic-offset . 2) 435 (c-basic-offset . 2)
522 (c-basic-offset . 3) 489 (c-basic-offset . 3)
523 (c-comment-only-line-offset . 0) 490 (c-comment-only-line-offset . 0)
524 (c-hanging-braces-alist . ((substatement-open before after))) 491 (c-hanging-braces-alist . ((substatement-open before after)))
525 (c-offsets-alist . ((topmost-intro . 0) 492 (c-offsets-alist . ((topmost-intro . 0)
526 (topmost-intro-cont . 0) 493 (topmost-intro-cont . 0)
527 (substatement . 3) 494 (substatement . +)
528 (substatement-open . 0) 495 (substatement-open . 0)
529 (statement-case-intro . 0)
530 (case-label . +) 496 (case-label . +)
531 (access-label . -3) 497 (access-label . -)
532 (inclass . 6) 498 (inclass . ++)
533 (inline-open . 0) 499 (inline-open . 0)
534 )) 500 ))
535 ) 501 )
536 ("linux" 502 ("linux"
537 (c-basic-offset . 8) 503 (c-basic-offset . 8)
545 (substatement-open . 0) 511 (substatement-open . 0)
546 (label . 0) 512 (label . 0)
547 (statement-cont . +) 513 (statement-cont . +)
548 )) 514 ))
549 ) 515 )
516 ("python"
517 (indent-tabs-mode . t)
518 (c-basic-offset . 8)
519 (c-offsets-alist . ((substatement-open . 0)
520 ))
521 (c-hanging-braces-alist . ((brace-list-open)
522 (brace-list-intro)
523 (brace-list-close)
524 (substatement-open after)
525 (block-close . c-snug-do-while)
526 ))
527 )
550 ("java" 528 ("java"
551 (c-basic-offset . 2) 529 (c-basic-offset . 2)
552 (c-comment-only-line-offset . (0 . 0)) 530 (c-comment-only-line-offset . (0 . 0))
553 (c-offsets-alist . ((statement-block-intro . +) 531 (c-offsets-alist . ((statement-block-intro . +)
554 (knr-argdecl-intro . 5) 532 (knr-argdecl-intro . 5)
557 (statement-case-open . +) 535 (statement-case-open . +)
558 (statement-cont . +) 536 (statement-cont . +)
559 (arglist-intro . c-lineup-arglist-intro-after-paren) 537 (arglist-intro . c-lineup-arglist-intro-after-paren)
560 (arglist-close . c-lineup-arglist) 538 (arglist-close . c-lineup-arglist)
561 (access-label . 0) 539 (access-label . 0)
540 (inher-cont . c-lineup-java-inher)
562 )) 541 ))
563 542
564 ) 543 )
565 ) 544 )
566 "Styles of Indentation. 545 "Styles of Indentation.
567 Elements of this alist are of the form: 546 Elements of this alist are of the form:
568 547
569 (STYLE-STRING (VARIABLE . VALUE) [(VARIABLE . VALUE) ...]) 548 (STYLE-STRING (VARIABLE . VALUE) [(VARIABLE . VALUE) ...])
570 549
571 where STYLE-STRING is a short descriptive string used to select a 550 where STYLE-STRING is a short descriptive string used to select a
572 style, VARIABLE is any cc-mode variable, and VALUE is the intended 551 style, VARIABLE is any CC Mode variable, and VALUE is the intended
573 value for that variable when using the selected style. 552 value for that variable when using the selected style.
574 553
575 There is one special case when VARIABLE is `c-offsets-alist'. In this 554 There is one special case when VARIABLE is `c-offsets-alist'. In this
576 case, the VALUE is a list containing elements of the form: 555 case, the VALUE is a list containing elements of the form:
577 556
585 computed at the time the mode is loaded.") 564 computed at the time the mode is loaded.")
586 565
587 (defvar c-file-style nil 566 (defvar c-file-style nil
588 "*Variable interface for setting style via File Local Variables. 567 "*Variable interface for setting style via File Local Variables.
589 In a file's Local Variable section, you can set this variable to a 568 In a file's Local Variable section, you can set this variable to a
590 string suitable for `c-set-style'. When the file is visited, cc-mode 569 string suitable for `c-set-style'. When the file is visited, CC Mode
591 will set the style of the file to this value automatically. 570 will set the style of the file to this value automatically.
592 571
593 Note that file style settings are applied before file offset settings 572 Note that file style settings are applied before file offset settings
594 as designated in the variable `c-file-offsets'.") 573 as designated in the variable `c-file-offsets'.")
595 574
596 (defvar c-file-offsets nil 575 (defvar c-file-offsets nil
597 "*Variable interface for setting offsets via File Local Variables. 576 "*Variable interface for setting offsets via File Local Variables.
598 In a file's Local Variable section, you can set this variable to an 577 In a file's Local Variable section, you can set this variable to an
599 association list similar to the values allowed in `c-offsets-alist'. 578 association list similar to the values allowed in `c-offsets-alist'.
600 When the file is visited, cc-mode will institute these offset settings 579 When the file is visited, CC Mode will institute these offset settings
601 automatically. 580 automatically.
602 581
603 Note that file offset settings are applied after file style settings 582 Note that file offset settings are applied after file style settings
604 as designated in the variable `c-file-style'.") 583 as designated in the variable `c-file-style'.")
605 584
606 (defvar c-site-default-style "gnu" 585 (defvar c-site-default-style "gnu"
607 "Default style for your site. 586 "Default style for your site.
608 To change the default style at your site, you can set this variable to 587 To change the default style at your site, you can set this variable to
609 any style defined in `c-style-alist'. However, if cc-mode is usually 588 any style defined in `c-style-alist'. However, if CC Mode is usually
610 loaded into your Emacs at compile time, you will need to set this 589 loaded into your Emacs at compile time, you will need to set this
611 variable in the `site-init.el' file before cc-mode is loaded, then 590 variable in the `site-init.el' file before CC Mode is loaded, then
612 re-dump Emacs.") 591 re-dump Emacs.")
613 592
593 (defvar c-style-variables-are-local-p t
594 "*Whether style variables should be buffer local by default.
595 If non-nil, then all indentation style related variables will be made
596 buffer local by default. If nil, they will remain global. Variables
597 are made buffer local when this file is loaded, and once buffer
598 localized, they cannot be made global again.
599
600 The list of variables to buffer localize are:
601 c-offsets-alist
602 c-basic-offset
603 c-file-style
604 c-file-offsets
605 c-comment-only-line-offset
606 c-cleanup-list
607 c-hanging-braces-alist
608 c-hanging-colons-alist
609 c-hanging-comment-starter-p
610 c-hanging-comment-ender-p
611 c-backslash-column
612 c-label-minimum-indentation
613 c-special-indent-hook
614 c-indentation-style")
615
616
614 (defvar c-mode-hook nil 617 (defvar c-mode-hook nil
615 "*Hook called by `c-mode'.") 618 "*Hook called by `c-mode'.")
616 (defvar c++-mode-hook nil 619 (defvar c++-mode-hook nil
617 "*Hook called by `c++-mode'.") 620 "*Hook called by `c++-mode'.")
618 (defvar objc-mode-hook nil 621 (defvar objc-mode-hook nil
619 "*Hook called by `objc-mode'.") 622 "*Hook called by `objc-mode'.")
620 (defvar java-mode-hook nil 623 (defvar java-mode-hook nil
621 "*Hook called by `java-mode'.") 624 "*Hook called by `java-mode'.")
622 625
623 (defvar c-mode-common-hook nil 626 (defvar c-mode-common-hook nil
624 "*Hook called by all cc-mode modes for common initializations.") 627 "*Hook called by all CC Mode modes for common initializations.")
625 628
626 (defvar c-mode-menu 629 (defvar c-mode-menu
627 '(["Comment Out Region" comment-region (mark)] 630 '(["Comment Out Region" comment-region (mark)]
628 ["Macro Expand Region" c-macro-expand (mark)] 631 ["Macro Expand Region" c-macro-expand (mark)]
629 ["Backslashify" c-backslash-region (mark)] 632 ["Backslashify" c-backslash-region (mark)]
635 ["Backward Conditional" c-backward-conditional t] 638 ["Backward Conditional" c-backward-conditional t]
636 ["Forward Conditional" c-forward-conditional t] 639 ["Forward Conditional" c-forward-conditional t]
637 ["Backward Statement" c-beginning-of-statement t] 640 ["Backward Statement" c-beginning-of-statement t]
638 ["Forward Statement" c-end-of-statement t] 641 ["Forward Statement" c-end-of-statement t]
639 ) 642 )
640 "XEmacs 19 menu for C/C++/ObjC/Java modes.") 643 "Basic XEmacs 19 menu for C/C++/ObjC/Java modes.")
641 644
642 ;; Sadly we need this for a macro in Emacs 19. 645
643 (eval-when-compile 646 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
644 ;; Imenu isn't used in XEmacs, so just ignore load errors. 647 ;; NO USER DEFINABLE VARIABLES BEYOND THIS POINT
645 (condition-case () 648
646 (require 'imenu) 649 ;; imenu integration
647 (error nil)))
648
649 (defvar cc-imenu-c++-generic-expression 650 (defvar cc-imenu-c++-generic-expression
650 (` 651 (`
651 ((nil 652 ((nil
652 (, 653 (,
653 (concat 654 (concat
654 "^" ; beginning of line is required 655 "^" ; beginning of line is required
655 "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>" 656 "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>"
656 "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no 657 "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no
657 "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right? 658 "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right?
658 659
659 "\\(" ; last type spec including */& 660 "\\(" ; last type spec including */&
660 "[a-zA-Z0-9_:]+" 661 "[a-zA-Z0-9_:]+"
661 "\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either pointer/ref sign or whitespace 662 "\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either ptr/ref sign or ws
662 "\\)?" ; if there is a last type spec 663 "\\)?" ; if there is a last type spec
663 "\\(" ; name; take that into the imenu entry 664 "\\(" ; name, take into the imenu entry
664 "[a-zA-Z0-9_:~]+" ; member function, ctor or dtor... 665 "[a-zA-Z0-9_:~]+" ; member func, ctor or dtor...
665 ; (may not contain * because then 666 ; (may not contain * because then
666 ; "a::operator char*" would become "char*"!) 667 ; "a::operator char*" would
668 ; become "char*"!)
667 "\\|" 669 "\\|"
668 "\\([a-zA-Z0-9_:~]*::\\)?operator" 670 "\\([a-zA-Z0-9_:~]*::\\)?operator"
669 "[^a-zA-Z1-9_][^(]*" ; ...or operator 671 "[^a-zA-Z1-9_][^(]*" ; ...or operator
670 " \\)" 672 " \\)"
671 "[ \t]*([^)]*)[ \t\n]*[^ ;]" ; require something other than a ; after 673 "[ \t]*([^)]*)[ \t\n]*[^ ;]" ; require something other than
672 ; the (...) to avoid prototypes. Can't 674 ; a `;' after the (...) to
673 ; catch cases with () inside the parentheses 675 ; avoid prototypes. Can't
674 ; surrounding the parameters 676 ; catch cases with () inside
675 ; (like "int foo(int a=bar()) {...}" 677 ; the parentheses surrounding
678 ; the parameters. e.g.:
679 ; "int foo(int a=bar()) {...}"
676 680
677 )) 6) 681 )) 6)
678 ("Class" 682 ("Class"
679 (, (concat 683 (, (concat
680 "^" ; beginning of line is required 684 "^" ; beginning of line is required
681 "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>" 685 "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>"
682 "class[ \t]+" 686 "class[ \t]+"
683 "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get 687 "\\([a-zA-Z0-9_]+\\)" ; the string we want to get
684 "[ \t]*[:{]" 688 "[ \t]*[:{]"
685 )) 2))) 689 )) 2)))
686 "Imenu generic expression for C++ mode. See `imenu-generic-expression'.") 690 "Imenu generic expression for C++ mode. See `imenu-generic-expression'.")
687 691
688 (defvar cc-imenu-c-generic-expression 692 (defvar cc-imenu-c-generic-expression
689 cc-imenu-c++-generic-expression 693 cc-imenu-c++-generic-expression
690 "Imenu generic expression for C mode. See `imenu-generic-expression'.") 694 "Imenu generic expression for C mode. See `imenu-generic-expression'.")
691 695
696 ;(defvar cc-imenu-objc-generic-expression
697 ; ())
698 ; Please contribute one!
699
700 (defvar cc-imenu-java-generic-expression
701 (`
702 ((nil
703 (,
704 (concat
705 "^\\([ \t]\\)*"
706 "\\([A-Za-z0-9_-]+[ \t]+\\)?" ; type specs; there can be
707 "\\([A-Za-z0-9_-]+[ \t]+\\)?" ; more than 3 tokens, right?
708 "\\([A-Za-z0-9_-]+[ \t]*[[]?[]]?\\)"
709 "\\([ \t]\\)"
710 "\\([A-Za-z0-9_-]+\\)" ; the string we want to get
711 "\\([ \t]*\\)+("
712 "\\([a-zA-Z,_1-9\n \t]*[[]?[]]?\\)*" ; arguments
713 ")[ \t]*"
714 "[^;(]"
715 "[,a-zA-Z_1-9\n \t]*{"
716 )) 6)))
717 "Imenu generic expression for Java mode. See `imenu-generic-expression'.")
718
719
692 720
693 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
694 ;; NO USER DEFINABLE VARIABLES BEYOND THIS POINT
695
696 ;; Shut the byte-compiler up. Requires Emacs 19 or JWZ's improved 721 ;; Shut the byte-compiler up. Requires Emacs 19 or JWZ's improved
697 ;; byte-compiler. Otherwise, comment this line out and ignore 722 ;; byte-compiler. Otherwise, comment this line out and ignore
698 ;; any warnings. 723 ;; any warnings.
699 ;;(byte-compiler-options (warnings nil)) 724 ;;(byte-compiler-options (warnings nil))
700 725
703 (let ((major (and (boundp 'emacs-major-version) 728 (let ((major (and (boundp 'emacs-major-version)
704 emacs-major-version)) 729 emacs-major-version))
705 (minor (and (boundp 'emacs-minor-version) 730 (minor (and (boundp 'emacs-minor-version)
706 emacs-minor-version)) 731 emacs-minor-version))
707 (re-suite 'old-re) 732 (re-suite 'old-re)
708 flavor comments) 733 flavor comments infodock-p)
709 ;; figure out version numbers if not already discovered 734 ;; figure out version numbers if not already discovered
710 (and (or (not major) (not minor)) 735 (and (or (not major) (not minor))
711 (string-match "\\([0-9]+\\).\\([0-9]+\\)" emacs-version) 736 (string-match "\\([0-9]+\\).\\([0-9]+\\)" emacs-version)
712 (setq major (string-to-int (substring emacs-version 737 (setq major (string-to-int (substring emacs-version
713 (match-beginning 1) 738 (match-beginning 1)
722 ((= major 18) (setq major 'v18)) ;Emacs 18 747 ((= major 18) (setq major 'v18)) ;Emacs 18
723 ((= major 4) (setq major 'v18)) ;Epoch 4 748 ((= major 4) (setq major 'v18)) ;Epoch 4
724 ((= major 19) (setq major 'v19 ;Emacs 19 749 ((= major 19) (setq major 'v19 ;Emacs 19
725 flavor (if (or (string-match "Lucid" emacs-version) 750 flavor (if (or (string-match "Lucid" emacs-version)
726 (string-match "XEmacs" emacs-version)) 751 (string-match "XEmacs" emacs-version))
727 'XEmacs 'FSF))) 752 'XEmacs 'FSF)
753 infodock-p (boundp 'infodock-version)))
728 ((= major 20) (setq major 'v20 ;XEmacs 20 754 ((= major 20) (setq major 'v20 ;XEmacs 20
729 flavor 'XEmacs)) 755 flavor 'XEmacs))
730 ;; I don't know 756 ;; I don't know
731 (t (error "Cannot recognize major version number: %s" major))) 757 (t (error "Cannot recognize major version number: %s" major)))
732 ;; Regular expression suites... 758 ;; Regular expression suites...
766 (not c-inhibit-startup-warnings-p)) 792 (not c-inhibit-startup-warnings-p))
767 (with-output-to-temp-buffer "*cc-mode warnings*" 793 (with-output-to-temp-buffer "*cc-mode warnings*"
768 (print (format 794 (print (format
769 "The version of Emacs that you are running, %s, 795 "The version of Emacs that you are running, %s,
770 has known bugs in its syntax.c parsing routines which will affect the 796 has known bugs in its syntax.c parsing routines which will affect the
771 performance of cc-mode. You should strongly consider upgrading to the 797 performance of CC Mode. You should strongly consider upgrading to the
772 latest available version. cc-mode may continue to work, after a 798 latest available version. CC Mode may continue to work, after a
773 fashion, but strange indentation errors could be encountered." 799 fashion, but strange indentation errors could be encountered."
774 emacs-version)))) 800 emacs-version))))
775 ;; Emacs 18, with no patch is not too good 801 ;; Emacs 18, with no patch is not too good
776 (if (and (eq major 'v18) (eq comments 'no-dual-comments) 802 (if (and (eq major 'v18) (eq comments 'no-dual-comments)
777 (not c-inhibit-startup-warnings-p)) 803 (not c-inhibit-startup-warnings-p))
784 if you are doing much C++ editing, you should strongly consider 810 if you are doing much C++ editing, you should strongly consider
785 upgrading to one of the latest Emacs 19's. In Emacs 18, you may also 811 upgrading to one of the latest Emacs 19's. In Emacs 18, you may also
786 experience performance degradations. Emacs 19 has some new built-in 812 experience performance degradations. Emacs 19 has some new built-in
787 routines which will speed things up for you. 813 routines which will speed things up for you.
788 814
789 Because of these inherent problems, cc-mode is no longer being 815 Because of these inherent problems, CC Mode is no longer being
790 actively maintained for Emacs 18, however, until you can upgrade to 816 actively maintained for Emacs 18, however, until you can upgrade to
791 Emacs 19, you may want to look at cc-mode-18.el in the cc-mode 817 Emacs 19, you may want to look at cc-mode-18.el in the CC Mode
792 distribution. THIS FILE IS COMPLETELY UNSUPPORTED! If you use it, 818 distribution. THIS FILE IS COMPLETELY UNSUPPORTED! If you use it,
793 you are on your own, although patch contributions will be folded into 819 you are on your own, although patch contributions will be folded into
794 the main release." 820 the main release."
795 emacs-version)))) 821 emacs-version))))
796 ;; Emacs 18 with the syntax patches are no longer supported 822 ;; Emacs 18 with the syntax patches are no longer supported
799 (with-output-to-temp-buffer "*cc-mode warnings*" 825 (with-output-to-temp-buffer "*cc-mode warnings*"
800 (print (format 826 (print (format
801 "You are running a syntax patched Emacs 18 variant. While this should 827 "You are running a syntax patched Emacs 18 variant. While this should
802 work for you, you may want to consider upgrading to Emacs 19. The 828 work for you, you may want to consider upgrading to Emacs 19. The
803 syntax patches are no longer supported either for syntax.c or 829 syntax patches are no longer supported either for syntax.c or
804 cc-mode.")))) 830 CC Mode."))))
805 (list major comments re-suite)) 831 (if infodock-p
832 (list major comments re-suite 'infodock)
833 (list major comments re-suite)))
806 "A list of features extant in the Emacs you are using. 834 "A list of features extant in the Emacs you are using.
807 There are many flavors of Emacs out there, each with different 835 There are many flavors of Emacs out there, each with different
808 features supporting those needed by cc-mode. Here's the current 836 features supporting those needed by CC Mode. Here's the current
809 supported list, along with the values for this variable: 837 supported list, along with the values for this variable:
810 838
811 Emacs 18/Epoch 4: (v18 no-dual-comments RS) 839 Emacs 18/Epoch 4: (v18 no-dual-comments RS)
812 Emacs 18/Epoch 4 (patch2): (v18 8-bit RS) 840 Emacs 18/Epoch 4 (patch2): (v18 8-bit RS)
813 XEmacs 19: (v19 8-bit RS) 841 XEmacs 19: (v19 8-bit RS)
814 XEmacs 20: (v20 8-bit RS) 842 XEmacs 20: (v20 8-bit RS)
815 Emacs 19: (v19 1-bit RS) 843 Emacs 19: (v19 1-bit RS)
816 844
817 RS is the regular expression suite to use. XEmacs versions after 845 RS is the regular expression suite to use. XEmacs versions after
818 19.13, and Emacs versions after 19.29 use the `new-re' regex suite. 846 19.13, and Emacs versions after 19.29 use the `new-re' regex suite.
819 All other Emacsen use the `old-re' suite.") 847 All other Emacsen use the `old-re' suite.
848
849 Infodock (based on XEmacs) has an additional symbol on this list:
850 'infodock")
820 851
821 (defvar c++-mode-abbrev-table nil 852 (defvar c++-mode-abbrev-table nil
822 "Abbrev table in use in c++-mode buffers.") 853 "Abbrev table in use in c++-mode buffers.")
823 (define-abbrev-table 'c++-mode-abbrev-table ()) 854 (define-abbrev-table 'c++-mode-abbrev-table ())
824 855
833 (defvar java-mode-abbrev-table nil 864 (defvar java-mode-abbrev-table nil
834 "Abbrev table in use in java-mode buffers.") 865 "Abbrev table in use in java-mode buffers.")
835 (define-abbrev-table 'java-mode-abbrev-table ()) 866 (define-abbrev-table 'java-mode-abbrev-table ())
836 867
837 (defun c-mode-fsf-menu (name map) 868 (defun c-mode-fsf-menu (name map)
838 ;; Add menu to a keymap. FSF menus suck. Don't add them for 869 ;; Add menu to a keymap, but don't add them for XEmacs. This
839 ;; XEmacs. This feature test will fail on other than Emacs 19. 870 ;; feature test will fail on other than Emacs 19.
840 (condition-case nil 871 (condition-case nil
841 (progn 872 (progn
842 (define-key map [menu-bar] (make-sparse-keymap)) 873 (define-key map [menu-bar] (make-sparse-keymap))
843 (define-key map [menu-bar c] (cons name (make-sparse-keymap name))) 874 (define-key map [menu-bar c] (cons name (make-sparse-keymap name)))
844 875
852 '("Indent Expression" . c-indent-exp)) 883 '("Indent Expression" . c-indent-exp))
853 (define-key map [menu-bar c indent-line] 884 (define-key map [menu-bar c indent-line]
854 '("Indent Line" . c-indent-command)) 885 '("Indent Line" . c-indent-command))
855 (define-key map [menu-bar c fill] 886 (define-key map [menu-bar c fill]
856 '("Fill Comment Paragraph" . c-fill-paragraph)) 887 '("Fill Comment Paragraph" . c-fill-paragraph))
888 (define-key map [menu-bar c separator2]
889 '("----"))
857 (define-key map [menu-bar c up] 890 (define-key map [menu-bar c up]
858 '("Up Conditional" . c-up-conditional)) 891 '("Up Conditional" . c-up-conditional))
859 (define-key map [menu-bar c backward] 892 (define-key map [menu-bar c backward]
860 '("Backward Conditional" . c-backward-conditional)) 893 '("Backward Conditional" . c-backward-conditional))
861 (define-key map [menu-bar c forward] 894 (define-key map [menu-bar c forward]
895 (define-key c-mode-map "\C-c\C-m" 'c-mark-function) 928 (define-key c-mode-map "\C-c\C-m" 'c-mark-function)
896 (define-key c-mode-map "\e\C-q" 'c-indent-exp) 929 (define-key c-mode-map "\e\C-q" 'c-indent-exp)
897 (define-key c-mode-map "\ea" 'c-beginning-of-statement) 930 (define-key c-mode-map "\ea" 'c-beginning-of-statement)
898 (define-key c-mode-map "\ee" 'c-end-of-statement) 931 (define-key c-mode-map "\ee" 'c-end-of-statement)
899 ;; Emacs 19.30 introduces fill-paragraph-function, but it's not in 932 ;; Emacs 19.30 introduces fill-paragraph-function, but it's not in
900 ;; every version of Emacs cc-mode supports. 933 ;; every version of Emacs CC Mode supports.
901 (if (not (boundp 'fill-paragraph-function)) 934 (if (not (boundp 'fill-paragraph-function))
902 ;; I'd rather use an adaptive fill program instead of this. 935 ;; I'd rather use an adaptive fill program instead of this.
903 (define-key c-mode-map "\eq" 'c-fill-paragraph)) 936 (define-key c-mode-map "\eq" 'c-fill-paragraph))
904 (define-key c-mode-map "\C-c\C-n" 'c-forward-conditional) 937 (define-key c-mode-map "\C-c\C-n" 'c-forward-conditional)
905 (define-key c-mode-map "\C-c\C-p" 'c-backward-conditional) 938 (define-key c-mode-map "\C-c\C-p" 'c-backward-conditional)
918 (define-key c-mode-map "\C-c\C-d" 'c-toggle-hungry-state) 951 (define-key c-mode-map "\C-c\C-d" 'c-toggle-hungry-state)
919 (define-key c-mode-map "\C-c\C-e" 'c-macro-expand) 952 (define-key c-mode-map "\C-c\C-e" 'c-macro-expand)
920 (define-key c-mode-map "\C-c\C-o" 'c-set-offset) 953 (define-key c-mode-map "\C-c\C-o" 'c-set-offset)
921 (define-key c-mode-map "\C-c\C-s" 'c-show-syntactic-information) 954 (define-key c-mode-map "\C-c\C-s" 'c-show-syntactic-information)
922 (define-key c-mode-map "\C-c\C-t" 'c-toggle-auto-hungry-state) 955 (define-key c-mode-map "\C-c\C-t" 'c-toggle-auto-hungry-state)
956 (define-key c-mode-map "\C-c." 'c-set-style)
923 ;; conflicts with OOBR 957 ;; conflicts with OOBR
924 ;;(define-key c-mode-map "\C-c\C-v" 'c-version) 958 ;;(define-key c-mode-map "\C-c\C-v" 'c-version)
925 ;; 959 ;;
926 ;; Emacs 19 defines menus in the mode map. This call will return 960 (if (and
927 ;; t on Emacs 19, otherwise no-op and return nil. 961 ;; Infodock has it's own menu
928 (if (and (not (c-mode-fsf-menu "CC-Mode" c-mode-map)) 962 (not (memq 'infodock c-emacs-features))
929 ;; in XEmacs 19, we want the menu to popup when the 3rd 963 ;; Emacs 19 defines menus in the mode map. This call will
930 ;; button is hit. In Lucid Emacs 19.10 and beyond this is 964 ;; return t on Emacs 19, otherwise no-op and return nil.
931 ;; done automatically if we put the menu on mode-popup-menu 965 (not (c-mode-fsf-menu "CC Mode" c-mode-map))
932 ;; variable, see c-common-init. Emacs 19 uses C-Mouse-3 for 966 ;; In XEmacs 19, we want the menu to popup when the 3rd button
933 ;; this, and it works with no special effort. 967 ;; is hit. In Lucid Emacs 19.10 and beyond this is done
934 (boundp 'current-menubar) 968 ;; automatically if we put the menu on mode-popup-menu
935 (not (boundp 'mode-popup-menu))) 969 ;; variable, see c-common-init. Emacs 19 uses C-Mouse-3 for
970 ;; this, and it works with no special effort.
971 (boundp 'current-menubar)
972 (not (boundp 'mode-popup-menu)))
936 (define-key c-mode-map 'button3 'c-popup-menu))) 973 (define-key c-mode-map 'button3 'c-popup-menu)))
937 974
938 (defvar c++-mode-map () 975 (defvar c++-mode-map ()
939 "Keymap used in c++-mode buffers.") 976 "Keymap used in c++-mode buffers.")
940 (if c++-mode-map 977 (if c++-mode-map
1136 "Regexp describing C++ base classes in a derived class definition.") 1173 "Regexp describing C++ base classes in a derived class definition.")
1137 1174
1138 ;; defconst'd instead of defvar'd to override any old pre-loaded versions 1175 ;; defconst'd instead of defvar'd to override any old pre-loaded versions
1139 (defconst c-recognize-knr-p t 1176 (defconst c-recognize-knr-p t
1140 "Non-nil means K&R style argument declarations are valid.") 1177 "Non-nil means K&R style argument declarations are valid.")
1141 1178 (defvar c-indentation-style c-site-default-style
1179 "Name of style installed in the current buffer.")
1180
1181 ;; these variables should always be buffer local. they do not affect
1182 ;; indentation styles.
1183 ;;
1142 ;; minor mode variables 1184 ;; minor mode variables
1143 (make-variable-buffer-local 'c-auto-newline) 1185 (make-variable-buffer-local 'c-auto-newline)
1144 (make-variable-buffer-local 'c-hungry-delete-key) 1186 (make-variable-buffer-local 'c-hungry-delete-key)
1145 (make-variable-buffer-local 'c-auto-hungry-string) 1187 (make-variable-buffer-local 'c-auto-hungry-string)
1146 ;; language differences 1188 ;; language differences
1155 ;; style variables are made buffer local at tail end of this file. 1197 ;; style variables are made buffer local at tail end of this file.
1156 1198
1157 ;; cmacexp is lame because it uses no preprocessor symbols. 1199 ;; cmacexp is lame because it uses no preprocessor symbols.
1158 ;; It isn't very extensible either -- hardcodes /lib/cpp. 1200 ;; It isn't very extensible either -- hardcodes /lib/cpp.
1159 ;; [I add it here only because c-mode has it -- BAW] 1201 ;; [I add it here only because c-mode has it -- BAW]
1160 ;(autoload 'c-macro-expand "cmacexp" 1202 (autoload 'c-macro-expand "cmacexp"
1161 ; "Display the result of expanding all C macros occurring in the region. 1203 "Display the result of expanding all C macros occurring in the region.
1162 ;The expansion is entirely correct because it uses the C preprocessor." 1204 The expansion is entirely correct because it uses the C preprocessor."
1163 ; t) 1205 t)
1164 1206
1165 1207
1166 ;; constant regular expressions for looking at various constructs 1208 ;; constant regular expressions for looking at various constructs
1167 (defconst c-C++-class-key "\\(class\\|struct\\|union\\)" 1209 (defconst c-C++-class-key "\\(class\\|struct\\|union\\)"
1168 "Regexp describing a C++ class declaration, including templates.") 1210 "Regexp describing a C++ class declaration, including templates.")
1228 "\\(([^)]*)\\)?" ; return type 1270 "\\(([^)]*)\\)?" ; return type
1229 ;; \\s- in java syntax table does not include \n 1271 ;; \\s- in java syntax table does not include \n
1230 ;; since it is considered the end of //-comments. 1272 ;; since it is considered the end of //-comments.
1231 "[ \t\n]*" c-symbol-key) 1273 "[ \t\n]*" c-symbol-key)
1232 "Regexp describing a Java method intro.") 1274 "Regexp describing a Java method intro.")
1233 (defconst c-Java-access-key 1275 (defconst c-Java-access-key nil
1234 (concat c-protection-key) 1276 "Regexp describing access labels for Java.")
1235 "Regexp describing access specification keywords for Java.")
1236 (defconst c-Java-class-key 1277 (defconst c-Java-class-key
1237 (concat 1278 (concat
1279 "\\(" c-protection-key "\\s +\\)?"
1238 "\\(interface\\|class\\)\\s +" 1280 "\\(interface\\|class\\)\\s +"
1239 c-symbol-key ;name of the class 1281 c-symbol-key ;name of the class
1240 "\\(\\s *extends\\s *" c-symbol-key "\\)?" ;maybe followed by superclass 1282 "\\(\\s *extends\\s *" c-symbol-key "\\)?" ;maybe followed by superclass
1241 ;;"\\(\\s *implements *[^{]+{\\)?" ;and maybe the adopted protocols list 1283 ;;"\\(\\s *implements *[^{]+{\\)?" ;and maybe the adopted protocols list
1242 ) 1284 )
1243 "Regexp describing a class or protocol declaration for Java.") 1285 "Regexp describing a class or protocol declaration for Java.")
1286 (defconst c-Java-special-key "\\(implements\\|extends\\|throws\\)[^_]"
1287 "Regexp describing Java inheritance and throws clauses.")
1244 (defconst c-Java-conditional-key 1288 (defconst c-Java-conditional-key
1245 (concat "\\b\\(" 1289 (concat "\\b\\("
1246 (mapconcat 'identity 1290 (mapconcat 'identity
1247 (append '("try" "catch" "finally" "synchronized") 1291 (append '("try" "catch" "finally" "synchronized")
1248 c-C-conditionals) "\\|") 1292 c-C-conditionals) "\\|")
1249 "\\)\\b[^_]") 1293 "\\)\\b[^_]")
1250 "Regexp describing a conditional control for Java.") 1294 "Regexp describing a conditional control for Java.")
1295 (defconst c-Java-defun-prompt-regexp
1296 "^[ \t]*\\(\\(\\(public\\|protected\\|private\\|const\\|abstract\\|synchronized\\|final\\|static\\|threadsafe\\|transient\\|native\\|volatile\\)\\s-+\\)*\\(\\(\\([[a-zA-Z][][_$.a-zA-Z0-9]*[][_$.a-zA-Z0-9]+\\|[[a-zA-Z]\\)\\s-*\\)\\s-+\\)\\)?\\(\\([[a-zA-Z][][_$.a-zA-Z0-9]*\\s-+\\)\\s-*\\)?\\([_a-zA-Z][^][ \t:;.,{}()=]*\\|\\([_$a-zA-Z][_$.a-zA-Z0-9]*\\)\\)\\s-*\\(([^);{}]*)\\)?\\([] \t]*\\)\\(\\s-*\\<throws\\>\\s-*\\(\\([_$a-zA-Z][_$.a-zA-Z0-9]*\\)[, \t\n\r\f]*\\)+\\)?\\s-*"
1297 "Regexp describing the beginning of a Java top-level definition.")
1251 1298
1252 ;; KLUDGE ALERT. We default these variables to their `C' values so 1299 ;; KLUDGE ALERT. We default these variables to their `C' values so
1253 ;; that non-cc-mode-ized modes that depend on c-mode will still work 1300 ;; that non-cc-mode-ized modes that depend on c-mode will still work
1254 ;; out of the box. The most glaring example is awk-mode. There ought 1301 ;; out of the box. The most glaring example is awk-mode. There ought
1255 ;; to be a better way. 1302 ;; to be a better way.
1267 To submit a problem report, enter `\\[c-submit-bug-report]' from a 1314 To submit a problem report, enter `\\[c-submit-bug-report]' from a
1268 c-mode buffer. This automatically sets up a mail buffer with version 1315 c-mode buffer. This automatically sets up a mail buffer with version
1269 information already added. You just need to add a description of the 1316 information already added. You just need to add a description of the
1270 problem, including a reproducible test case and send the message. 1317 problem, including a reproducible test case and send the message.
1271 1318
1272 To see what version of cc-mode you are running, enter `\\[c-version]'. 1319 To see what version of CC Mode you are running, enter `\\[c-version]'.
1273 1320
1274 The hook variable `c-mode-hook' is run with no args, if that value is 1321 The hook variable `c-mode-hook' is run with no args, if that value is
1275 bound and has a non-nil value. Also the hook `c-mode-common-hook' is 1322 bound and has a non-nil value. Also the hook `c-mode-common-hook' is
1276 run first. 1323 run first.
1277 1324
1304 c++-mode buffer. This automatically sets up a mail buffer with 1351 c++-mode buffer. This automatically sets up a mail buffer with
1305 version information already added. You just need to add a description 1352 version information already added. You just need to add a description
1306 of the problem, including a reproducible test case, and send the 1353 of the problem, including a reproducible test case, and send the
1307 message. 1354 message.
1308 1355
1309 To see what version of cc-mode you are running, enter `\\[c-version]'. 1356 To see what version of CC Mode you are running, enter `\\[c-version]'.
1310 1357
1311 The hook variable `c++-mode-hook' is run with no args, if that 1358 The hook variable `c++-mode-hook' is run with no args, if that
1312 variable is bound and has a non-nil value. Also the hook 1359 variable is bound and has a non-nil value. Also the hook
1313 `c-mode-common-hook' is run first. 1360 `c-mode-common-hook' is run first.
1314 1361
1343 objc-mode buffer. This automatically sets up a mail buffer with 1390 objc-mode buffer. This automatically sets up a mail buffer with
1344 version information already added. You just need to add a description 1391 version information already added. You just need to add a description
1345 of the problem, including a reproducible test case, and send the 1392 of the problem, including a reproducible test case, and send the
1346 message. 1393 message.
1347 1394
1348 To see what version of cc-mode you are running, enter `\\[c-version]'. 1395 To see what version of CC Mode you are running, enter `\\[c-version]'.
1349 1396
1350 The hook variable `objc-mode-hook' is run with no args, if that value 1397 The hook variable `objc-mode-hook' is run with no args, if that value
1351 is bound and has a non-nil value. Also the hook `c-mode-common-hook' 1398 is bound and has a non-nil value. Also the hook `c-mode-common-hook'
1352 is run first. 1399 is run first.
1353 1400
1382 java-mode buffer. This automatically sets up a mail buffer with 1429 java-mode buffer. This automatically sets up a mail buffer with
1383 version information already added. You just need to add a description 1430 version information already added. You just need to add a description
1384 of the problem, including a reproducible test case and send the 1431 of the problem, including a reproducible test case and send the
1385 message. 1432 message.
1386 1433
1387 To see what version of cc-mode you are running, enter `\\[c-version]'. 1434 To see what version of CC Mode you are running, enter `\\[c-version]'.
1388 1435
1389 The hook variable `java-mode-hook' is run with no args, if that value 1436 The hook variable `java-mode-hook' is run with no args, if that value
1390 is bound and has a non-nil value. Also the common hook 1437 is bound and has a non-nil value. Also the common hook
1391 `c-mode-common-hook' is run first. Note that this mode automatically 1438 `c-mode-common-hook' is run first. Note that this mode automatically
1392 sets the \"java\" style before calling any hooks so be careful if you 1439 sets the \"java\" style before calling any hooks so be careful if you
1410 c-class-key c-Java-class-key 1457 c-class-key c-Java-class-key
1411 c-method-key c-Java-method-key 1458 c-method-key c-Java-method-key
1412 c-double-slash-is-comments-p t 1459 c-double-slash-is-comments-p t
1413 c-baseclass-key nil 1460 c-baseclass-key nil
1414 c-recognize-knr-p nil 1461 c-recognize-knr-p nil
1415 c-access-key c-Java-access-key) 1462 c-access-key c-Java-access-key
1463 ;defun-prompt-regexp c-Java-defun-prompt-regexp
1464 imenu-generic-expression cc-imenu-java-generic-expression
1465 )
1416 (c-set-style "java") 1466 (c-set-style "java")
1417 (run-hooks 'c-mode-common-hook) 1467 (run-hooks 'c-mode-common-hook)
1418 (run-hooks 'java-mode-hook)) 1468 (run-hooks 'java-mode-hook))
1419 (setq c-list-of-mode-names (cons "Java" c-list-of-mode-names)) 1469 (setq c-list-of-mode-names (cons "Java" c-list-of-mode-names))
1420 1470
1423 For use with the variable `java-mode-hook'." 1473 For use with the variable `java-mode-hook'."
1424 (c-set-style "java")) 1474 (c-set-style "java"))
1425 1475
1426 (defun c-common-init () 1476 (defun c-common-init ()
1427 ;; Common initializations for c++-mode and c-mode. 1477 ;; Common initializations for c++-mode and c-mode.
1428 ;; make local variables 1478 ;;
1479 ;; these variables should always be buffer local; they do not affect
1480 ;; indentation style.
1429 (make-local-variable 'paragraph-start) 1481 (make-local-variable 'paragraph-start)
1430 (make-local-variable 'paragraph-separate) 1482 (make-local-variable 'paragraph-separate)
1431 (make-local-variable 'paragraph-ignore-fill-prefix) 1483 (make-local-variable 'paragraph-ignore-fill-prefix)
1432 (make-local-variable 'require-final-newline) 1484 (make-local-variable 'require-final-newline)
1433 (make-local-variable 'parse-sexp-ignore-comments) 1485 (make-local-variable 'parse-sexp-ignore-comments)
1459 indent-region-function 'c-indent-region 1511 indent-region-function 'c-indent-region
1460 outline-regexp "[^#\n\^M]" 1512 outline-regexp "[^#\n\^M]"
1461 outline-level 'c-outline-level 1513 outline-level 'c-outline-level
1462 comment-column 32 1514 comment-column 32
1463 comment-start-skip "/\\*+ *\\|// *" 1515 comment-start-skip "/\\*+ *\\|// *"
1464 adaptive-fill-regexp nil) 1516 ;; For all but XEmacs 19.13, the default should be nil
1517 adaptive-fill-regexp (and (memq 'v19 c-emacs-features)
1518 (= emacs-minor-version 13)
1519 "[ \t]*\\([#;>*]+ +\\)?")
1520 )
1465 ;; we have to do something special for c-offsets-alist so that the 1521 ;; we have to do something special for c-offsets-alist so that the
1466 ;; buffer local value has its own alist structure. 1522 ;; buffer local value has its own alist structure.
1467 (setq c-offsets-alist (copy-alist c-offsets-alist)) 1523 (setq c-offsets-alist (copy-alist c-offsets-alist))
1468 ;; setup the comment indent variable in a Emacs version portable way 1524 ;; setup the comment indent variable in a Emacs version portable way
1469 ;; ignore any byte compiler warnings you might get here 1525 ;; ignore any byte compiler warnings you might get here
1472 (make-local-variable 'comment-indent-function) 1528 (make-local-variable 'comment-indent-function)
1473 (setq comment-indent-function 'c-comment-indent)) 1529 (setq comment-indent-function 'c-comment-indent))
1474 (make-local-variable 'comment-indent-hook) 1530 (make-local-variable 'comment-indent-hook)
1475 (setq comment-indent-hook 'c-comment-indent)) 1531 (setq comment-indent-hook 'c-comment-indent))
1476 ;; Put C menu into menubar and on popup menu for XEmacs 19. I think 1532 ;; Put C menu into menubar and on popup menu for XEmacs 19. I think
1477 ;; this happens automatically for Emacs 19. 1533 ;; this happens automatically for Emacs 19. Skip it for Infodock.
1478 (if (and (boundp 'current-menubar) 1534 (if (and (not (memq 'infodock c-emacs-features))
1535 (boundp 'current-menubar)
1479 current-menubar 1536 current-menubar
1480 (not (assoc mode-name current-menubar))) 1537 (not (assoc mode-name current-menubar)))
1481 ;; its possible that this buffer has changed modes from one of 1538 ;; its possible that this buffer has changed modes from one of
1482 ;; the other cc-mode modes. In that case, only the menubar 1539 ;; the other CC Mode modes. In that case, only the menubar
1483 ;; title of the menu changes. 1540 ;; title of the menu changes.
1484 (let ((modes (copy-sequence c-list-of-mode-names)) 1541 (let ((modes (copy-sequence c-list-of-mode-names))
1485 changed-p) 1542 changed-p)
1486 (setq modes (delete major-mode modes)) 1543 (setq modes (delete major-mode modes))
1487 (while modes 1544 (while modes
1491 (setq modes nil 1548 (setq modes nil
1492 changed-p t))) 1549 changed-p t)))
1493 (if (not changed-p) 1550 (if (not changed-p)
1494 (progn 1551 (progn
1495 (set-buffer-menubar (copy-sequence current-menubar)) 1552 (set-buffer-menubar (copy-sequence current-menubar))
1496 (add-menu nil mode-name c-mode-menu))))) 1553 (if (fboundp 'add-submenu)
1554 (add-submenu nil (c-mode-menu))
1555 (add-menu nil mode-name c-mode-menu)
1556 )))))
1497 (if (boundp 'mode-popup-menu) 1557 (if (boundp 'mode-popup-menu)
1498 (setq mode-popup-menu 1558 (setq mode-popup-menu (c-mode-menu)))
1499 (cons (concat mode-name " Mode Commands") c-mode-menu)))
1500 ;; put auto-hungry designators onto minor-mode-alist, but only once 1559 ;; put auto-hungry designators onto minor-mode-alist, but only once
1501 (or (assq 'c-auto-hungry-string minor-mode-alist) 1560 (or (assq 'c-auto-hungry-string minor-mode-alist)
1502 (setq minor-mode-alist 1561 (setq minor-mode-alist
1503 (cons '(c-auto-hungry-string c-auto-hungry-string) 1562 (cons '(c-auto-hungry-string c-auto-hungry-string)
1504 minor-mode-alist)))) 1563 minor-mode-alist))))
1714 (if c-auto-newline 1773 (if c-auto-newline
1715 (if c-hungry-delete-key "/ah" "/a") 1774 (if c-hungry-delete-key "/ah" "/a")
1716 (if c-hungry-delete-key "/h" nil))) 1775 (if c-hungry-delete-key "/h" nil)))
1717 ;; updates the modeline for all Emacsen 1776 ;; updates the modeline for all Emacsen
1718 (if (or (memq 'v19 c-emacs-features) (memq 'v20 c-emacs-features)) 1777 (if (or (memq 'v19 c-emacs-features) (memq 'v20 c-emacs-features))
1719 (force-mode-line-update) 1778 (if (boundp 'redraw-modeline)
1779 (redraw-modeline)
1780 (force-mode-line-update))
1720 (set-buffer-modified-p (buffer-modified-p)))) 1781 (set-buffer-modified-p (buffer-modified-p))))
1721 1782
1722 (defun c-calculate-state (arg prevstate) 1783 (defun c-calculate-state (arg prevstate)
1723 ;; Calculate the new state of PREVSTATE, t or nil, based on arg. If 1784 ;; Calculate the new state of PREVSTATE, t or nil, based on arg. If
1724 ;; arg is nil or zero, toggle the state. If arg is negative, turn 1785 ;; arg is nil or zero, toggle the state. If arg is negative, turn
1964 (= mend here)) 2025 (= mend here))
1965 (not (c-in-literal))) 2026 (not (c-in-literal)))
1966 (progn 2027 (progn
1967 (delete-region mbeg mend) 2028 (delete-region mbeg mend)
1968 (insert "} else {"))) 2029 (insert "} else {")))
2030 ;; clean up brace-elseif-brace
2031 (if (and c-auto-newline
2032 (memq 'brace-elseif-brace c-cleanup-list)
2033 (= last-command-char ?\{)
2034 (re-search-backward "}[ \t\n]*else[ \t\n]+if[ \t\n]*" nil t)
2035 (save-excursion
2036 (goto-char (match-end 0))
2037 (c-safe (forward-sexp 1))
2038 (skip-chars-forward " \t\n")
2039 (setq mbeg (match-beginning 0)
2040 mend (match-end 0))
2041 (= here (1+ (point))))
2042 (not (c-in-literal)))
2043 (progn
2044 (delete-region mbeg mend)
2045 (insert "} else if ")))
1969 (goto-char (- (point-max) pos)) 2046 (goto-char (- (point-max) pos))
1970 ) 2047 )
1971 ;; does a newline go after the brace? 2048 ;; does a newline go after the brace?
1972 (if (memq 'after newlines) 2049 (if (memq 'after newlines)
1973 (progn 2050 (progn
2219 (put 'c-electric-delete 'delete-selection 'supersede) ; delsel 2296 (put 'c-electric-delete 'delete-selection 'supersede) ; delsel
2220 (put 'c-electric-delete 'pending-delete 'supersede) ; pending-del 2297 (put 'c-electric-delete 'pending-delete 'supersede) ; pending-del
2221 2298
2222 2299
2223 2300
2301 (defvar c-read-offset-history nil)
2302
2224 (defun c-read-offset (langelem) 2303 (defun c-read-offset (langelem)
2225 ;; read new offset value for LANGELEM from minibuffer. return a 2304 ;; read new offset value for LANGELEM from minibuffer. return a
2226 ;; legal value only 2305 ;; legal value only
2227 (let* ((oldoff (cdr-safe (assq langelem c-offsets-alist))) 2306 (let* ((oldoff (cdr-safe (assq langelem c-offsets-alist)))
2228 (defstr (format "(default %s): " oldoff)) 2307 (defstr (format "(default %s): " oldoff))
2230 "or in [+,-,++,--,*,/] " 2309 "or in [+,-,++,--,*,/] "
2231 defstr)) 2310 defstr))
2232 (prompt (concat "Offset " defstr)) 2311 (prompt (concat "Offset " defstr))
2233 offset input interned raw) 2312 offset input interned raw)
2234 (while (not offset) 2313 (while (not offset)
2235 (setq input (read-string prompt) 2314 (setq input (completing-read prompt obarray 'fboundp nil nil
2315 'c-read-offset-history)
2236 offset (cond ((string-equal "" input) oldoff) ; default 2316 offset (cond ((string-equal "" input) oldoff) ; default
2237 ((string-equal "+" input) '+) 2317 ((string-equal "+" input) '+)
2238 ((string-equal "-" input) '-) 2318 ((string-equal "-" input) '-)
2239 ((string-equal "++" input) '++) 2319 ((string-equal "++" input) '++)
2240 ((string-equal "--" input) '--) 2320 ((string-equal "--" input) '--)
2334 (add-hook 'c-special-indent-hook val))) 2414 (add-hook 'c-special-indent-hook val)))
2335 (t (set attr val))) 2415 (t (set attr val)))
2336 ))) 2416 )))
2337 stylevars)) 2417 stylevars))
2338 2418
2419 (defvar c-set-style-history nil)
2420
2339 ;;;###autoload 2421 ;;;###autoload
2340 (defun c-set-style (stylename) 2422 (defun c-set-style (stylename)
2341 "Set cc-mode variables to use one of several different indentation styles. 2423 "Set CC Mode variables to use one of several different indentation styles.
2342 STYLENAME is a string representing the desired style from the list of 2424 STYLENAME is a string representing the desired style from the list of
2343 styles described in the variable `c-style-alist'. See that variable 2425 styles described in the variable `c-style-alist'. See that variable
2344 for details of setting up styles." 2426 for details of setting up styles.
2427
2428 The variable `c-indentation-style' always contains the buffer's current
2429 style name."
2345 (interactive (list (let ((completion-ignore-case t) 2430 (interactive (list (let ((completion-ignore-case t)
2346 (prompt (format "Which %s indentation style? " 2431 (prompt (format "Which %s indentation style? "
2347 mode-name))) 2432 mode-name)))
2348 (completing-read prompt c-style-alist nil t)))) 2433 (completing-read prompt c-style-alist nil t
2434 (cons c-indentation-style 0)
2435 'c-set-style-history))))
2349 (let ((vars (cdr (or (assoc (downcase stylename) c-style-alist) 2436 (let ((vars (cdr (or (assoc (downcase stylename) c-style-alist)
2350 (assoc (upcase stylename) c-style-alist) 2437 (assoc (upcase stylename) c-style-alist)
2351 (assoc stylename c-style-alist) 2438 (assoc stylename c-style-alist)
2352 ))) 2439 )))
2353 (default (cdr (assoc "cc-mode" c-style-alist)))) 2440 (default (cdr (assoc "cc-mode" c-style-alist))))
2354 (or vars (error "Invalid indentation style `%s'" stylename)) 2441 (or vars (error "Invalid indentation style `%s'" stylename))
2355 (or default (error "No `cc-mode' style found!")) 2442 (or default (error "No `cc-mode' style found!"))
2356 ;; first reset the style to `cc-mode' to give every style a common 2443 ;; first reset the style to `cc-mode' to give every style a common
2357 ;; base. Then institute the new style. 2444 ;; base. Then institute the new style.
2358 (c-set-style-1 default) 2445 (c-set-style-1 default)
2446 (setq c-indentation-style stylename)
2359 (if (not (string= stylename "cc-mode")) 2447 (if (not (string= stylename "cc-mode"))
2360 (c-set-style-1 vars))) 2448 (c-set-style-1 vars)))
2361 (c-keep-region-active)) 2449 (c-keep-region-active))
2362 2450
2363 (defun c-add-style (style descrip &optional set-p) 2451 (defun c-add-style (style descrip &optional set-p)
2501 ;; Lines containing just a comment start or just an end 2589 ;; Lines containing just a comment start or just an end
2502 ;; should not be filled into paragraphs they are next 2590 ;; should not be filled into paragraphs they are next
2503 ;; to. 2591 ;; to.
2504 (paragraph-start (concat paragraph-start re1)) 2592 (paragraph-start (concat paragraph-start re1))
2505 (paragraph-separate (concat paragraph-separate re1)) 2593 (paragraph-separate (concat paragraph-separate re1))
2506 (chars-to-delete 0)) 2594 (chars-to-delete 0)
2595 )
2507 (save-restriction 2596 (save-restriction
2508 ;; Don't fill the comment together with the code 2597 ;; Don't fill the comment together with the code
2509 ;; following it. So temporarily exclude everything 2598 ;; following it. So temporarily exclude everything
2510 ;; before the comment start, and everything after the 2599 ;; before the comment start, and everything after the
2511 ;; line where the comment ends. If comment-start-place 2600 ;; line where the comment ends. If comment-start-place
2513 ;; point is inside the comment. 2602 ;; point is inside the comment.
2514 (narrow-to-region (save-excursion 2603 (narrow-to-region (save-excursion
2515 (if comment-start-place 2604 (if comment-start-place
2516 (goto-char comment-start-place) 2605 (goto-char comment-start-place)
2517 (search-backward "/*")) 2606 (search-backward "/*"))
2607 (if (and (not c-hanging-comment-starter-p)
2608 (looking-at "/\\*[ \t]*$"))
2609 (forward-line 1))
2518 ;; Protect text before the comment 2610 ;; Protect text before the comment
2519 ;; start by excluding it. Add 2611 ;; start by excluding it. Add
2520 ;; spaces to bring back proper 2612 ;; spaces to bring back proper
2521 ;; indentation of that point. 2613 ;; indentation of that point.
2522 (let ((column (current-column))) 2614 (let ((column (current-column)))
2605 (goto-char lim) 2697 (goto-char lim)
2606 (setq state (parse-partial-sexp (point) here nil nil))) 2698 (setq state (parse-partial-sexp (point) here nil nil)))
2607 (if (and sentence-flag 2699 (if (and sentence-flag
2608 (or (nth 3 state) 2700 (or (nth 3 state)
2609 (nth 4 state) 2701 (nth 4 state)
2610 (looking-at (concat "[ \t]*" comment-start-skip)) 2702 ; (looking-at (concat "[ \t]*" comment-start-skip))
2611 (save-excursion 2703 (save-excursion
2612 (skip-chars-backward " \t") 2704 (skip-chars-backward " \t")
2613 (goto-char (- (point) 2)) 2705 (goto-char (- (point) 2))
2614 (looking-at "\\*/")))) 2706 (looking-at "\\*/"))))
2615 (forward-sentence (- count)) 2707 (forward-sentence (- count))
2639 nil t)) 2731 nil t))
2640 (c-beginning-of-statement (- (or count 1)) lim sentence-flag) 2732 (c-beginning-of-statement (- (or count 1)) lim sentence-flag)
2641 (c-keep-region-active)) 2733 (c-keep-region-active))
2642 2734
2643 ;; WARNING: Be *exceptionally* careful about modifications to this 2735 ;; WARNING: Be *exceptionally* careful about modifications to this
2644 ;; function! Much of cc-mode depends on this Doing The Right Thing. 2736 ;; function! Much of CC Mode depends on this Doing The Right Thing.
2645 ;; If you break it you will be sorry. 2737 ;; If you break it you will be sorry.
2646 (defun c-beginning-of-statement-1 (&optional lim) 2738 (defun c-beginning-of-statement-1 (&optional lim)
2647 ;; move to the start of the current statement, or the previous 2739 ;; move to the start of the current statement, or the previous
2648 ;; statement if already at the beginning of one. 2740 ;; statement if already at the beginning of one.
2649 (let ((firstp t) 2741 (let ((firstp t)
2651 donep c-in-literal-cache 2743 donep c-in-literal-cache
2652 ;; KLUDGE ALERT: maybe-labelp is used to pass information 2744 ;; KLUDGE ALERT: maybe-labelp is used to pass information
2653 ;; between c-crosses-statement-barrier-p and 2745 ;; between c-crosses-statement-barrier-p and
2654 ;; c-beginning-of-statement-1. A better way should be 2746 ;; c-beginning-of-statement-1. A better way should be
2655 ;; implemented. 2747 ;; implemented.
2656 maybe-labelp 2748 maybe-labelp saved
2657 (last-begin (point))) 2749 (last-begin (point)))
2658 (while (not donep) 2750 ;; first check for bare semicolon
2659 ;; stop at beginning of buffer 2751 (if (and (progn (c-backward-syntactic-ws lim)
2660 (if (bobp) (setq donep t) 2752 (= (preceding-char) ?\;))
2661 ;; go backwards one balanced expression, but be careful of 2753 (c-safe (progn (forward-char -1)
2662 ;; unbalanced paren being reached 2754 (setq saved (point))
2663 (if (not (c-safe (progn (backward-sexp 1) t))) 2755 t))
2664 (progn 2756 (progn (c-backward-syntactic-ws lim)
2665 (if firstp 2757 (memq (preceding-char) '(?\; ?{ ?} ?:)))
2666 (backward-up-list 1) 2758 )
2667 (goto-char last-begin)) 2759 (setq last-begin saved)
2668 ;; skip over any unary operators, or other special 2760 (goto-char last-begin)
2669 ;; characters appearing at front of identifier 2761 (while (not donep)
2670 (save-excursion 2762 ;; stop at beginning of buffer
2671 (c-backward-syntactic-ws lim) 2763 (if (bobp) (setq donep t)
2672 (skip-chars-backward "-+!*&:.~ \t\n") 2764 ;; go backwards one balanced expression, but be careful of
2673 (if (= (preceding-char) ?\() 2765 ;; unbalanced paren being reached
2674 (setq last-begin (point)))) 2766 (if (not (c-safe (progn (backward-sexp 1) t)))
2675 (goto-char last-begin)
2676 (setq last-begin (point)
2677 donep t)))
2678
2679 (setq maybe-labelp nil)
2680 ;; see if we're in a literal. if not, then this bufpos may be
2681 ;; a candidate for stopping
2682 (cond
2683 ;; CASE 0: did we hit the error condition above?
2684 (donep)
2685 ;; CASE 1: are we in a literal?
2686 ((eq (c-in-literal lim) 'pound)
2687 (beginning-of-line))
2688 ;; CASE 2: some other kind of literal?
2689 ((c-in-literal lim))
2690 ;; CASE 3: are we looking at a conditional keyword?
2691 ((or (looking-at c-conditional-key)
2692 (and (= (following-char) ?\()
2693 (save-excursion
2694 (forward-sexp 1)
2695 (c-forward-syntactic-ws)
2696 (/= (following-char) ?\;))
2697 (let ((here (point))
2698 (foundp (progn
2699 (c-backward-syntactic-ws lim)
2700 (forward-word -1)
2701 (and lim
2702 (<= lim (point))
2703 (not (c-in-literal lim))
2704 (looking-at c-conditional-key)
2705 ))))
2706 ;; did we find a conditional?
2707 (if (not foundp)
2708 (goto-char here))
2709 foundp)))
2710 ;; are we in the middle of an else-if clause?
2711 (if (save-excursion
2712 (and (not substmt-p)
2713 (c-safe (progn (forward-sexp -1) t))
2714 (looking-at "\\<else\\>[ \t\n]+\\<if\\>")
2715 (not (c-in-literal lim))))
2716 (progn 2767 (progn
2717 (forward-sexp -1) 2768 (if firstp
2718 (c-backward-to-start-of-if lim))) 2769 (backward-up-list 1)
2719 ;; are we sitting at an else clause, that we are not a 2770 (goto-char last-begin))
2720 ;; substatement of? 2771 ;; skip over any unary operators, or other special
2721 (if (and (not substmt-p) 2772 ;; characters appearing at front of identifier
2722 (looking-at "\\<else\\>[^_]")) 2773 (save-excursion
2723 (c-backward-to-start-of-if lim)) 2774 (c-backward-syntactic-ws lim)
2724 ;; are we sitting at the while of a do-while? 2775 (skip-chars-backward "-+!*&:.~ \t\n")
2725 (if (and (looking-at "\\<while\\>[^_]") 2776 (if (= (preceding-char) ?\()
2726 (c-backward-to-start-of-do lim)) 2777 (setq last-begin (point))))
2727 (setq substmt-p nil)) 2778 (goto-char last-begin)
2728 (setq last-begin (point) 2779 (setq last-begin (point)
2729 donep substmt-p)) 2780 donep t)))
2730 ;; CASE 4: are we looking at a label? 2781
2731 ((looking-at c-label-key)) 2782 (setq maybe-labelp nil)
2732 ;; CASE 5: is this the first time we're checking? 2783 ;; see if we're in a literal. if not, then this bufpos may be
2733 (firstp (setq firstp nil 2784 ;; a candidate for stopping
2734 substmt-p (not (c-crosses-statement-barrier-p 2785 (cond
2735 (point) last-begin)) 2786 ;; CASE 0: did we hit the error condition above?
2736 last-begin (point))) 2787 (donep)
2737 ;; CASE 6: have we crossed a statement barrier? 2788 ;; CASE 1: are we in a literal?
2738 ((c-crosses-statement-barrier-p (point) last-begin) 2789 ((eq (c-in-literal lim) 'pound)
2739 (setq donep t)) 2790 (beginning-of-line))
2740 ;; CASE 7: ignore labels 2791 ;; CASE 2: some other kind of literal?
2741 ((and maybe-labelp 2792 ((c-in-literal lim))
2742 (or (and c-access-key (looking-at c-access-key)) 2793 ;; CASE 3: are we looking at a conditional keyword?
2743 ;; with switch labels, we have to go back further 2794 ((or (looking-at c-conditional-key)
2744 ;; to try to pick up the case or default 2795 (and (= (following-char) ?\()
2745 ;; keyword. Potential bogosity alert: we assume 2796 (save-excursion
2746 ;; `case' or `default' is first thing on line 2797 (forward-sexp 1)
2747 (let ((here (point))) 2798 (c-forward-syntactic-ws)
2748 (beginning-of-line) 2799 (/= (following-char) ?\;))
2749 (c-forward-syntactic-ws) 2800 (let ((here (point))
2750 (if (looking-at c-switch-label-key) 2801 (foundp (progn
2751 t 2802 (c-backward-syntactic-ws lim)
2752 (goto-char here) 2803 (forward-word -1)
2753 nil)) 2804 (and lim
2754 (looking-at c-label-key)))) 2805 (<= lim (point))
2755 ;; CASE 8: ObjC or Java method def 2806 (not (c-in-literal lim))
2756 ((and c-method-key 2807 (looking-at c-conditional-key)
2757 (setq last-begin (c-in-method-def-p))) 2808 ))))
2758 (setq donep t)) 2809 ;; did we find a conditional?
2759 ;; CASE 9: nothing special 2810 (if (not foundp)
2760 (t (setq last-begin (point))) 2811 (goto-char here))
2761 ))) 2812 foundp)))
2813 ;; are we in the middle of an else-if clause?
2814 (if (save-excursion
2815 (and (not substmt-p)
2816 (c-safe (progn (forward-sexp -1) t))
2817 (looking-at "\\<else\\>[ \t\n]+\\<if\\>")
2818 (not (c-in-literal lim))))
2819 (progn
2820 (forward-sexp -1)
2821 (c-backward-to-start-of-if lim)))
2822 ;; are we sitting at an else clause, that we are not a
2823 ;; substatement of?
2824 (if (and (not substmt-p)
2825 (looking-at "\\<else\\>[^_]"))
2826 (c-backward-to-start-of-if lim))
2827 ;; are we sitting at the while of a do-while?
2828 (if (and (looking-at "\\<while\\>[^_]")
2829 (c-backward-to-start-of-do lim))
2830 (setq substmt-p nil))
2831 (setq last-begin (point)
2832 donep substmt-p))
2833 ;; CASE 4: are we looking at a label?
2834 ((looking-at c-label-key))
2835 ;; CASE 5: is this the first time we're checking?
2836 (firstp (setq firstp nil
2837 substmt-p (not (c-crosses-statement-barrier-p
2838 (point) last-begin))
2839 last-begin (point)))
2840 ;; CASE 6: have we crossed a statement barrier?
2841 ((c-crosses-statement-barrier-p (point) last-begin)
2842 (setq donep t))
2843 ;; CASE 7: ignore labels
2844 ((and maybe-labelp
2845 (or (and c-access-key (looking-at c-access-key))
2846 ;; with switch labels, we have to go back further
2847 ;; to try to pick up the case or default
2848 ;; keyword. Potential bogosity alert: we assume
2849 ;; `case' or `default' is first thing on line
2850 (let ((here (point)))
2851 (beginning-of-line)
2852 (c-forward-syntactic-ws)
2853 (if (looking-at c-switch-label-key)
2854 t
2855 (goto-char here)
2856 nil))
2857 (looking-at c-label-key))))
2858 ;; CASE 8: ObjC or Java method def
2859 ((and c-method-key
2860 (setq last-begin (c-in-method-def-p)))
2861 (setq donep t))
2862 ;; CASE 9: nothing special
2863 (t (setq last-begin (point)))
2864 ))))
2762 (goto-char last-begin) 2865 (goto-char last-begin)
2763 ;; we always do want to skip over non-whitespace modifier 2866 ;; we always do want to skip over non-whitespace modifier
2764 ;; characters that didn't get skipped above 2867 ;; characters that didn't get skipped above
2765 (skip-chars-backward "-+!*&:.~" (c-point 'boi)))) 2868 (skip-chars-backward "-+!*&:.~" (c-point 'boi))))
2766 2869
3033 (beginning-of-line) 3136 (beginning-of-line)
3034 (let (endmark) 3137 (let (endmark)
3035 (unwind-protect 3138 (unwind-protect
3036 (let ((c-tab-always-indent t) 3139 (let ((c-tab-always-indent t)
3037 ;; shut up any echo msgs on indiv lines 3140 ;; shut up any echo msgs on indiv lines
3038 (c-echo-syntactic-information-p nil)) 3141 (c-echo-syntactic-information-p nil)
3142 fence)
3039 (c-progress-init start end 'c-indent-region) 3143 (c-progress-init start end 'c-indent-region)
3040 (setq endmark (copy-marker end)) 3144 (setq endmark (copy-marker end))
3041 (while (and (bolp) 3145 (while (and (bolp)
3042 (not (eobp)) 3146 (not (eobp))
3043 (< (point) endmark)) 3147 (< (point) endmark))
3048 ;; skip blank lines 3152 ;; skip blank lines
3049 (skip-chars-forward " \t\n") 3153 (skip-chars-forward " \t\n")
3050 (beginning-of-line) 3154 (beginning-of-line)
3051 ;; indent the current line 3155 ;; indent the current line
3052 (c-indent-line) 3156 (c-indent-line)
3157 (setq fence (point))
3053 (if (save-excursion 3158 (if (save-excursion
3054 (beginning-of-line) 3159 (beginning-of-line)
3055 (looking-at "[ \t]*#")) 3160 (looking-at "[ \t]*#"))
3056 (forward-line 1) 3161 (forward-line 1)
3057 (save-excursion 3162 (save-excursion
3073 ;; make sure the sexp we found really starts on the 3178 ;; make sure the sexp we found really starts on the
3074 ;; current line and extends past it 3179 ;; current line and extends past it
3075 (goto-char sexpend) 3180 (goto-char sexpend)
3076 (setq sexpend (point-marker)) 3181 (setq sexpend (point-marker))
3077 (c-safe (backward-sexp 1)) 3182 (c-safe (backward-sexp 1))
3078 (setq sexpbeg (point))))) 3183 (setq sexpbeg (point))))
3184 (if (and sexpbeg (< sexpbeg fence))
3185 (setq sexpbeg fence)))
3079 ;; check to see if the next line starts a 3186 ;; check to see if the next line starts a
3080 ;; comment-only line 3187 ;; comment-only line
3081 (save-excursion 3188 (save-excursion
3082 (forward-line 1) 3189 (forward-line 1)
3083 (skip-chars-forward " \t") 3190 (skip-chars-forward " \t")
3099 (c-indent-line))) 3206 (c-indent-line)))
3100 ;; Move to following line and try again. 3207 ;; Move to following line and try again.
3101 (and sexpend 3208 (and sexpend
3102 (markerp sexpend) 3209 (markerp sexpend)
3103 (set-marker sexpend nil)) 3210 (set-marker sexpend nil))
3104 (forward-line 1))))) 3211 (forward-line 1)
3212 (setq fence (point))))))
3105 (set-marker endmark nil) 3213 (set-marker endmark nil)
3106 (c-progress-fini 'c-indent-region) 3214 (c-progress-fini 'c-indent-region)
3107 )))) 3215 ))))
3108 3216
3109 (defun c-mark-function () 3217 (defun c-mark-function ()
3815 (state fullstate) 3923 (state fullstate)
3816 (in-method-intro-p (and c-method-key 3924 (in-method-intro-p (and c-method-key
3817 (looking-at c-method-key))) 3925 (looking-at c-method-key)))
3818 literal containing-sexp char-before-ip char-after-ip lim 3926 literal containing-sexp char-before-ip char-after-ip lim
3819 syntax placeholder c-in-literal-cache inswitch-p 3927 syntax placeholder c-in-literal-cache inswitch-p
3928 injava-inher
3820 ;; narrow out any enclosing class or extern "C" block 3929 ;; narrow out any enclosing class or extern "C" block
3821 (inclass-p (c-narrow-out-enclosing-class state indent-point)) 3930 (inclass-p (c-narrow-out-enclosing-class state indent-point))
3822 (inextern-p (and inclass-p 3931 (inextern-p (and inclass-p
3823 (save-excursion 3932 (save-excursion
3824 (save-restriction 3933 (save-restriction
3878 ;; CASE 2: in a C or C++ style comment. 3987 ;; CASE 2: in a C or C++ style comment.
3879 ((memq literal '(c c++)) 3988 ((memq literal '(c c++))
3880 ;; we need to catch multi-paragraph C comments 3989 ;; we need to catch multi-paragraph C comments
3881 (while (and (zerop (forward-line -1)) 3990 (while (and (zerop (forward-line -1))
3882 (looking-at "^[ \t]*$"))) 3991 (looking-at "^[ \t]*$")))
3883 (c-add-syntax literal (c-point 'bol))) 3992 (c-add-syntax literal (c-point 'boi)))
3884 ;; CASE 3: in a cpp preprocessor 3993 ;; CASE 3: in a cpp preprocessor
3885 ((eq literal 'pound) 3994 ((eq literal 'pound)
3886 (c-beginning-of-macro lim) 3995 (c-beginning-of-macro lim)
3887 (c-add-syntax 'cpp-macro (c-point 'boi))) 3996 (c-add-syntax 'cpp-macro (c-point 'boi)))
3888 ;; CASE 4: in an objective-c method intro 3997 ;; CASE 4: in an objective-c method intro
3933 ((save-excursion 4042 ((save-excursion
3934 (c-beginning-of-statement-1 lim) 4043 (c-beginning-of-statement-1 lim)
3935 ;; c-b-o-s could have left us at point-min 4044 ;; c-b-o-s could have left us at point-min
3936 (and (bobp) 4045 (and (bobp)
3937 (c-forward-syntactic-ws indent-point)) 4046 (c-forward-syntactic-ws indent-point))
3938 (setq placeholder (point)) 4047 (if (looking-at "typedef[^_]")
4048 (progn (forward-sexp 1)
4049 (c-forward-syntactic-ws indent-point)))
4050 (setq placeholder (c-point 'bol))
3939 (and (or (looking-at "enum[ \t\n]+") 4051 (and (or (looking-at "enum[ \t\n]+")
3940 (= char-before-ip ?=)) 4052 (= char-before-ip ?=))
3941 (save-excursion 4053 (save-excursion
3942 (skip-chars-forward "^;(" indent-point) 4054 (skip-chars-forward "^;(" indent-point)
3943 (not (memq (following-char) '(?\; ?\())) 4055 (not (memq (following-char) '(?\; ?\()))
3969 (if (= (preceding-char) ?:) 4081 (if (= (preceding-char) ?:)
3970 (progn (forward-char -1) 4082 (progn (forward-char -1)
3971 (c-backward-syntactic-ws lim))) 4083 (c-backward-syntactic-ws lim)))
3972 (if (= (preceding-char) ?\)) 4084 (if (= (preceding-char) ?\))
3973 (backward-sexp 1)) 4085 (backward-sexp 1))
4086 (setq placeholder (point))
4087 (save-excursion
4088 (and (c-safe (backward-sexp 1) t)
4089 (looking-at "throw[^_]")
4090 (c-safe (backward-sexp 1) t)
4091 (setq placeholder (point))))
4092 (goto-char placeholder)
3974 (c-add-syntax 'member-init-intro (c-point 'boi)) 4093 (c-add-syntax 'member-init-intro (c-point 'boi))
3975 ;; we don't need to add any class offset since this 4094 ;; we don't need to add any class offset since this
3976 ;; should be relative to the ctor's indentation 4095 ;; should be relative to the ctor's indentation
3977 ) 4096 )
3978 ;; CASE 5B.2: K&R arg decl intro 4097 ;; CASE 5B.2: K&R arg decl intro
3979 (c-recognize-knr-p 4098 (c-recognize-knr-p
3980 (c-add-syntax 'knr-argdecl-intro (c-point 'boi)) 4099 (c-add-syntax 'knr-argdecl-intro (c-point 'boi))
3981 (and inclass-p (c-add-syntax 'inclass (aref inclass-p 0)))) 4100 (and inclass-p (c-add-syntax 'inclass (aref inclass-p 0))))
3982 ;; CASE 5B.3: Nether region after a C++ func decl, which 4101 ;; CASE 5B.3: Nether region after a C++ or Java func
3983 ;; could include a `throw' declaration. 4102 ;; decl, which could include a `throws' declaration.
3984 (t 4103 (t
3985 (c-beginning-of-statement-1 lim) 4104 (c-beginning-of-statement-1 lim)
3986 (c-add-syntax 'ansi-funcdecl-cont (c-point 'boi)) 4105 (c-add-syntax 'func-decl-cont (c-point 'boi))
3987 ))) 4106 )))
3988 ;; CASE 5C: inheritance line. could be first inheritance 4107 ;; CASE 5C: inheritance line. could be first inheritance
3989 ;; line, or continuation of a multiple inheritance 4108 ;; line, or continuation of a multiple inheritance
3990 ((or (and c-baseclass-key (looking-at c-baseclass-key)) 4109 ((or (and c-baseclass-key (looking-at c-baseclass-key))
3991 (and (or (= char-before-ip ?:) 4110 (and (or (= char-before-ip ?:)
3992 (= char-after-ip ?:)) 4111 ;; watch out for scope operator
4112 (save-excursion
4113 (and (= char-after-ip ?:)
4114 (c-safe (progn (forward-char 1) t))
4115 (/= (following-char) ?:)
4116 )))
3993 (save-excursion 4117 (save-excursion
3994 (c-backward-syntactic-ws lim) 4118 (c-backward-syntactic-ws lim)
3995 (if (= char-before-ip ?:) 4119 (if (= char-before-ip ?:)
3996 (progn 4120 (progn
3997 (forward-char -1) 4121 (forward-char -1)
3998 (c-backward-syntactic-ws lim))) 4122 (c-backward-syntactic-ws lim)))
3999 (back-to-indentation) 4123 (back-to-indentation)
4000 (looking-at c-class-key)))) 4124 (looking-at c-class-key)))
4125 ;; for Java
4126 (and (eq major-mode 'java-mode)
4127 (let ((fence (save-excursion
4128 (c-beginning-of-statement-1 lim)
4129 (point)))
4130 cont done)
4131 (save-excursion
4132 (while (not done)
4133 (cond ((looking-at c-Java-special-key)
4134 (setq injava-inher (cons cont (point))
4135 done t))
4136 ((or (not (c-safe (forward-sexp -1) t))
4137 (<= (point) fence))
4138 (setq done t))
4139 )
4140 (setq cont t)))
4141 injava-inher))
4142 )
4001 (cond 4143 (cond
4002 ;; CASE 5C.1: non-hanging colon on an inher intro 4144 ;; CASE 5C.1: non-hanging colon on an inher intro
4003 ((= char-after-ip ?:) 4145 ((= char-after-ip ?:)
4004 (c-backward-syntactic-ws lim) 4146 (c-backward-syntactic-ws lim)
4005 (c-add-syntax 'inher-intro (c-point 'boi)) 4147 (c-add-syntax 'inher-intro (c-point 'boi))
4008 ) 4150 )
4009 ;; CASE 5C.2: hanging colon on an inher intro 4151 ;; CASE 5C.2: hanging colon on an inher intro
4010 ((= char-before-ip ?:) 4152 ((= char-before-ip ?:)
4011 (c-add-syntax 'inher-intro (c-point 'boi)) 4153 (c-add-syntax 'inher-intro (c-point 'boi))
4012 (and inclass-p (c-add-syntax 'inclass (aref inclass-p 0)))) 4154 (and inclass-p (c-add-syntax 'inclass (aref inclass-p 0))))
4013 ;; CASE 5C.3: a continued inheritance line 4155 ;; CASE 5C.3: in a Java implements/extends
4156 (injava-inher
4157 (let ((where (cdr injava-inher))
4158 (cont (car injava-inher))
4159 (here (point)))
4160 (goto-char where)
4161 (cond ((looking-at "throws[^_]")
4162 (c-add-syntax 'func-decl-cont
4163 (progn (c-beginning-of-statement-1 lim)
4164 (c-point 'boi))))
4165 (cont (c-add-syntax 'inher-cont where))
4166 (t (c-add-syntax 'inher-intro
4167 (progn (goto-char (cdr injava-inher))
4168 (c-beginning-of-statement-1 lim)
4169 (point))))
4170 )))
4171 ;; CASE 5C.4: a continued inheritance line
4014 (t 4172 (t
4015 (c-beginning-of-inheritance-list lim) 4173 (c-beginning-of-inheritance-list lim)
4016 (c-add-syntax 'inher-cont (point)) 4174 (c-add-syntax 'inher-cont (point))
4017 ;; don't add inclass symbol since relative point already 4175 ;; don't add inclass symbol since relative point already
4018 ;; contains any class offset 4176 ;; contains any class offset
4114 (let ((limit (save-excursion 4272 (let ((limit (save-excursion
4115 (re-search-backward "^[^ \^L\t\n#]" nil 'move) 4273 (re-search-backward "^[^ \^L\t\n#]" nil 'move)
4116 (point)))) 4274 (point))))
4117 (save-excursion 4275 (save-excursion
4118 (c-backward-syntactic-ws limit) 4276 (c-backward-syntactic-ws limit)
4277 (setq placeholder (point))
4119 (while (and (memq (preceding-char) '(?\; ?,)) 4278 (while (and (memq (preceding-char) '(?\; ?,))
4120 (> (point) limit)) 4279 (> (point) limit))
4121 (beginning-of-line) 4280 (beginning-of-line)
4122 (setq placeholder (point)) 4281 (setq placeholder (point))
4123 (c-backward-syntactic-ws limit)) 4282 (c-backward-syntactic-ws limit))
4500 ;; watch out for scope operator 4659 ;; watch out for scope operator
4501 (not (looking-at "::"))))) 4660 (not (looking-at "::")))))
4502 (c-add-syntax 'statement-cont (c-point 'boi))) 4661 (c-add-syntax 'statement-cont (c-point 'boi)))
4503 ;; CASE 15D: any old statement 4662 ;; CASE 15D: any old statement
4504 ((< (point) indent-point) 4663 ((< (point) indent-point)
4505 (let ((safepos (c-most-enclosing-brace fullstate))) 4664 (let ((safepos (c-most-enclosing-brace fullstate))
4665 relpos done)
4506 (goto-char indent-point) 4666 (goto-char indent-point)
4507 (c-beginning-of-statement-1 safepos) 4667 (c-beginning-of-statement-1 safepos)
4508 ;; It is possible we're on the brace that opens a nested 4668 ;; It is possible we're on the brace that opens a nested
4509 ;; function. 4669 ;; function.
4510 (if (and (= (following-char) ?{) 4670 (if (and (= (following-char) ?{)
4511 (save-excursion 4671 (save-excursion
4512 (c-backward-syntactic-ws safepos) 4672 (c-backward-syntactic-ws safepos)
4513 (/= (preceding-char) ?\;))) 4673 (/= (preceding-char) ?\;)))
4514 (c-beginning-of-statement-1 safepos)) 4674 (c-beginning-of-statement-1 safepos))
4515 (c-add-syntax 'statement (c-point 'boi)) 4675 (if (and inswitch-p
4676 (looking-at c-switch-label-key))
4677 (progn
4678 (goto-char placeholder)
4679 (end-of-line)
4680 (forward-sexp -1)))
4681 (setq relpos (c-point 'boi))
4682 (while (and (not done)
4683 (<= safepos (point))
4684 (/= relpos (point)))
4685 (c-beginning-of-statement-1 safepos)
4686 (if (= relpos (c-point 'boi))
4687 (setq done t))
4688 (setq relpos (c-point 'boi)))
4689 (c-add-syntax 'statement relpos)
4516 (if (= char-after-ip ?{) 4690 (if (= char-after-ip ?{)
4517 (c-add-syntax 'block-open)))) 4691 (c-add-syntax 'block-open))))
4518 ;; CASE 15E: first statement in an inline, or first 4692 ;; CASE 15E: first statement in an inline, or first
4519 ;; statement in a top-level defun. we can tell this is it 4693 ;; statement in a top-level defun. we can tell this is it
4520 ;; if there are no enclosing braces that haven't been 4694 ;; if there are no enclosing braces that haven't been
4728 (looking-at c-comment-start-regexp)) 4902 (looking-at c-comment-start-regexp))
4729 (c-forward-syntactic-ws here)) 4903 (c-forward-syntactic-ws here))
4730 (- (current-column) cs-curcol) 4904 (- (current-column) cs-curcol)
4731 ))) 4905 )))
4732 4906
4907 (defun c-lineup-java-inher (langelem)
4908 ;; line up Java implements and extends continuations
4909 (save-excursion
4910 (let ((cs-curcol (progn (goto-char (cdr langelem))
4911 (current-column))))
4912 (forward-word 1)
4913 (if (looking-at "[ \t]*$")
4914 cs-curcol
4915 (c-forward-syntactic-ws)
4916 (- (current-column) cs-curcol)))))
4917
4733 (defun c-lineup-C-comments (langelem) 4918 (defun c-lineup-C-comments (langelem)
4734 ;; line up C block comment continuation lines 4919 ;; line up C block comment continuation lines
4735 (save-excursion 4920 (save-excursion
4736 (let ((stars (progn 4921 (let ((here (point))
4737 (beginning-of-line) 4922 (stars (progn (back-to-indentation)
4738 (skip-chars-forward " \t") 4923 (skip-chars-forward "*")))
4739 (if (looking-at "\\*\\*?")
4740 (- (match-end 0) (match-beginning 0))
4741 0)))
4742 (cs-curcol (progn (goto-char (cdr langelem)) 4924 (cs-curcol (progn (goto-char (cdr langelem))
4743 (current-column)))) 4925 (current-column))))
4744 (back-to-indentation) 4926 (back-to-indentation)
4745 (if (re-search-forward "/\\*[ \t]*" (c-point 'eol) t) 4927 (if (not (re-search-forward "/[*]+" (c-point 'eol) t))
4746 (goto-char (+ (match-beginning 0) 4928 (progn
4747 (cond 4929 (if (not (looking-at "[*]+"))
4748 (c-block-comments-indent-p 0) 4930 (progn
4749 ((= stars 1) 1) 4931 ;; we now have to figure out where this comment begins.
4750 ((= stars 2) 0) 4932 (goto-char here)
4751 (t (- (match-end 0) (match-beginning 0))))))) 4933 (back-to-indentation)
4752 (- (current-column) cs-curcol)))) 4934 (if (re-search-forward "[*]+/" (c-point 'eol) t)
4935 (forward-comment -1)
4936 (goto-char (cdr langelem))
4937 (back-to-indentation))))
4938 (- (current-column) cs-curcol))
4939 (if (zerop stars)
4940 (skip-chars-forward " \t"))
4941 (- (current-column) stars cs-curcol))
4942 )))
4753 4943
4754 (defun c-lineup-comment (langelem) 4944 (defun c-lineup-comment (langelem)
4755 ;; support old behavior for comment indentation. we look at 4945 ;; support old behavior for comment indentation. we look at
4756 ;; c-comment-only-line-offset to decide how to indent comment 4946 ;; c-comment-only-line-offset to decide how to indent comment
4757 ;; only-lines 4947 ;; only-lines
4908 (looking-at "\\<do\\>[^_]"))) 5098 (looking-at "\\<do\\>[^_]")))
4909 '(before) 5099 '(before)
4910 '(before after))))) 5100 '(before after)))))
4911 5101
4912 (defun c-gnu-impose-minimum () 5102 (defun c-gnu-impose-minimum ()
4913 "Imposes a minimum indentation for labels and case tags. 5103 "Imposes a minimum indentation for lines inside a top-level construct.
4914 The variable `c-label-minimum-indentation' specifies the minimum 5104 The variable `c-label-minimum-indentation' specifies the minimum
4915 indentation amount." 5105 indentation amount."
4916 (let ((non-top-levels '(defun-block-intro statement statement-cont 5106 (let ((non-top-levels '(defun-block-intro statement statement-cont
4917 statement-block-intro statement-case-intro 5107 statement-block-intro statement-case-intro
4918 statement-case-open substatement substatement-open 5108 statement-case-open substatement substatement-open
5007 (progn (skip-chars-backward " \t") (point))))))) 5197 (progn (skip-chars-backward " \t") (point)))))))
5008 5198
5009 5199
5010 ;; defuns for submitting bug reports 5200 ;; defuns for submitting bug reports
5011 5201
5012 (defconst c-version "4.322" 5202 (defconst c-version "4.379"
5013 "cc-mode version number.") 5203 "CC Mode version number.")
5014 (defconst c-mode-help-address 5204 (defconst c-mode-help-address
5015 "bug-gnu-emacs@prep.ai.mit.edu, cc-mode-help@python.org" 5205 "bug-gnu-emacs@prep.ai.mit.edu, cc-mode-help@python.org"
5016 "Address for cc-mode bug reports.") 5206 "Address for CC Mode bug reports.")
5017 5207
5018 (defun c-version () 5208 (defun c-version ()
5019 "Echo the current version of cc-mode in the minibuffer." 5209 "Echo the current version of CC Mode in the minibuffer."
5020 (interactive) 5210 (interactive)
5021 (message "Using cc-mode version %s" c-version) 5211 (message "Using CC Mode version %s" c-version)
5022 (c-keep-region-active)) 5212 (c-keep-region-active))
5023 5213
5024 ;; get reporter-submit-bug-report when byte-compiling 5214 ;; get reporter-submit-bug-report when byte-compiling
5025 (eval-when-compile 5215 (eval-when-compile
5026 (require 'reporter)) 5216 (require 'reporter))
5027 5217
5028 (defun c-submit-bug-report () 5218 (defun c-submit-bug-report ()
5029 "Submit via mail a bug report on cc-mode." 5219 "Submit via mail a bug report on CC Mode."
5030 (interactive) 5220 (interactive)
5031 ;; load in reporter 5221 ;; load in reporter
5032 (let ((reporter-prompt-for-summary-p t) 5222 (let ((reporter-prompt-for-summary-p t)
5033 (reporter-dont-compact-list '(c-offsets-alist))) 5223 (reporter-dont-compact-list '(c-offsets-alist)))
5034 (and 5224 (and
5035 (if (y-or-n-p "Do you want to submit a report on cc-mode? ") 5225 (if (y-or-n-p "Do you want to submit a report on CC Mode? ")
5036 t (message "") nil) 5226 t (message "") nil)
5037 (require 'reporter) 5227 (require 'reporter)
5038 (reporter-submit-bug-report 5228 (reporter-submit-bug-report
5039 c-mode-help-address 5229 c-mode-help-address
5040 (concat "cc-mode " c-version " (" 5230 (concat "CC Mode " c-version " ("
5041 (cond ((eq major-mode 'c++-mode) "C++") 5231 (cond ((eq major-mode 'c++-mode) "C++")
5042 ((eq major-mode 'c-mode) "C") 5232 ((eq major-mode 'c-mode) "C")
5043 ((eq major-mode 'objc-mode) "ObjC") 5233 ((eq major-mode 'objc-mode) "ObjC")
5044 ((eq major-mode 'java-mode) "Java") 5234 ((eq major-mode 'java-mode) "Java")
5045 ) 5235 )
5046 ")") 5236 ")")
5047 (let ((vars (list 5237 (let ((vars (list
5048 ;; report only the vars that affect indentation 5238 ;; report only the vars that affect indentation
5049 'c-basic-offset 5239 'c-basic-offset
5050 'c-offsets-alist 5240 'c-offsets-alist
5051 'c-block-comments-indent-p
5052 'c-cleanup-list 5241 'c-cleanup-list
5053 'c-comment-only-line-offset 5242 'c-comment-only-line-offset
5054 'c-backslash-column 5243 'c-backslash-column
5055 'c-delete-function 5244 'c-delete-function
5056 'c-electric-pound-behavior 5245 'c-electric-pound-behavior
5057 'c-hanging-braces-alist 5246 'c-hanging-braces-alist
5058 'c-hanging-colons-alist 5247 'c-hanging-colons-alist
5248 'c-hanging-comment-starter-p
5059 'c-hanging-comment-ender-p 5249 'c-hanging-comment-ender-p
5060 'c-tab-always-indent 5250 'c-tab-always-indent
5061 'c-recognize-knr-p 5251 'c-recognize-knr-p
5062 'c-label-minimum-indentation 5252 'c-label-minimum-indentation
5063 'defun-prompt-regexp 5253 'defun-prompt-regexp
5067 (delq 'defun-prompt-regexp vars) 5257 (delq 'defun-prompt-regexp vars)
5068 vars)) 5258 vars))
5069 (function 5259 (function
5070 (lambda () 5260 (lambda ()
5071 (insert 5261 (insert
5262 "Buffer Style: " c-indentation-style "\n\n"
5072 (if c-special-indent-hook 5263 (if c-special-indent-hook
5073 (concat "\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n" 5264 (concat "\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"
5074 "c-special-indent-hook is set to '" 5265 "c-special-indent-hook is set to '"
5075 (format "%s" c-special-indent-hook) 5266 (format "%s" c-special-indent-hook)
5076 ".\nPerhaps this is your problem?\n" 5267 ".\nPerhaps this is your problem?\n"
5082 "Dear Barry," 5273 "Dear Barry,"
5083 )))) 5274 ))))
5084 5275
5085 5276
5086 ;; menus for XEmacs 19 5277 ;; menus for XEmacs 19
5278 (defun c-mode-menu ()
5279 (cons (concat mode-name " Mode Commands") c-mode-menu))
5280
5087 (defun c-popup-menu (e) 5281 (defun c-popup-menu (e)
5088 "Pops up the C/C++/ObjC menu." 5282 "Pops up the C/C++/ObjC menu."
5089 (interactive "@e") 5283 (interactive "@e")
5090 (popup-menu (cons (concat mode-name " Mode Commands") c-mode-menu)) 5284 (popup-menu (c-mode-menu))
5091 (c-keep-region-active)) 5285 (c-keep-region-active))
5092 5286
5093 5287
5094 ;; Emacs/XEmacs Compatibility 5288 ;; Emacs/XEmacs Compatibility
5095 ;; XEmacs has these, Emacs (even 19.31) does not 5289 ;; XEmacs has these, Emacs does not
5096 5290
5097 ;; Lift XEmacs 19.13's functionp from subr.el 5291 (if (fboundp 'functionp)
5098 (defun c-functionp (obj) 5292 (defalias 'c-functionp 'functionp)
5099 "Returns t if OBJ is a function, nil otherwise." 5293 ;; Lift XEmacs 19.13's functionp from subr.el
5100 (cond 5294 (defun c-functionp (obj)
5101 ((symbolp obj) (fboundp obj)) 5295 "Returns t if OBJ is a function, nil otherwise."
5102 ((subrp obj)) 5296 (cond
5103 ((compiled-function-p obj)) 5297 ((symbolp obj) (fboundp obj))
5104 ((consp obj) 5298 ((subrp obj))
5105 (if (eq (car obj) 'lambda) (listp (car (cdr obj))))) 5299 ((compiled-function-p obj))
5106 (t nil))) 5300 ((consp obj)
5107 5301 (if (eq (car obj) 'lambda) (listp (car (cdr obj)))))
5108 (defun c-copy-tree (tree) 5302 (t nil))))
5303
5304 (if (fboundp 'copy-tree)
5305 (defalias 'c-copy-tree 'copy-tree)
5109 ;; Lift XEmacs 19.12's copy-tree 5306 ;; Lift XEmacs 19.12's copy-tree
5110 (if (consp tree) 5307 (defun c-copy-tree (tree)
5111 (cons (c-copy-tree (car tree)) 5308 (if (consp tree)
5112 (c-copy-tree (cdr tree))) 5309 (cons (c-copy-tree (car tree))
5113 (if (vectorp tree) 5310 (c-copy-tree (cdr tree)))
5114 (let* ((new (copy-sequence tree)) 5311 (if (vectorp tree)
5115 (i (1- (length new)))) 5312 (let* ((new (copy-sequence tree))
5116 (while (>= i 0) 5313 (i (1- (length new))))
5117 (aset new i (c-copy-tree (aref new i))) 5314 (while (>= i 0)
5118 (setq i (1- i))) 5315 (aset new i (c-copy-tree (aref new i)))
5119 new) 5316 (setq i (1- i)))
5120 tree))) 5317 new)
5121 5318 tree))))
5122 (defun c-mapcar-defun (var)
5123 (let ((val (symbol-value var)))
5124 (cons var (if (atom val) val
5125 ;; XEmacs 19.12 and Emacs 19 + lucid.el have this
5126 (if (fboundp 'copy-tree)
5127 (copy-tree val)
5128 ;; Emacs 19 and Emacs 18
5129 (c-copy-tree val)
5130 )))
5131 ))
5132
5133 5319
5134 5320
5135 ;; Dynamically append the default value of most variables. This is 5321 ;; Dynamically append the default value of most variables. This is
5136 ;; crucial because future c-set-style calls will always reset the 5322 ;; crucial because future c-set-style calls will always reset the
5137 ;; variables first to the `cc-mode' style before instituting the new 5323 ;; variables first to the `cc-mode' style before instituting the new
5138 ;; style. Only do this once! 5324 ;; style. Only do this once!
5139 (or (assoc "cc-mode" c-style-alist) 5325 (or (assoc "cc-mode" c-style-alist)
5140 (progn 5326 (progn
5141 (c-add-style "cc-mode" 5327 (c-add-style "cc-mode"
5142 (mapcar 'c-mapcar-defun 5328 (mapcar
5143 '(c-backslash-column 5329 (function
5144 c-basic-offset 5330 (lambda (var)
5145 c-block-comments-indent-p 5331 (let ((val (symbol-value var)))
5146 c-cleanup-list 5332 (cons var (if (atom val) val
5147 c-comment-only-line-offset 5333 (c-copy-tree val)
5148 c-electric-pound-behavior 5334 ))
5149 c-hanging-braces-alist 5335 )))
5150 c-hanging-colons-alist 5336 '(c-backslash-column
5151 c-hanging-comment-ender-p 5337 c-basic-offset
5152 c-offsets-alist 5338 c-cleanup-list
5153 ))) 5339 c-comment-only-line-offset
5340 c-electric-pound-behavior
5341 c-hanging-braces-alist
5342 c-hanging-colons-alist
5343 c-hanging-comment-starter-p
5344 c-hanging-comment-ender-p
5345 c-offsets-alist
5346 )))
5154 ;; the default style is now GNU. This can be overridden in 5347 ;; the default style is now GNU. This can be overridden in
5155 ;; c-mode-common-hook or {c,c++,objc,java}-mode-hook. 5348 ;; c-mode-common-hook or {c,c++,objc,java}-mode-hook.
5156 (c-set-style c-site-default-style))) 5349 (c-set-style c-site-default-style)))
5157 5350
5158 ;; style variables 5351 (if c-style-variables-are-local-p
5159 (make-variable-buffer-local 'c-offsets-alist) 5352 (progn
5160 (make-variable-buffer-local 'c-basic-offset) 5353 ;; style variables
5161 (make-variable-buffer-local 'c-file-style) 5354 (make-variable-buffer-local 'c-offsets-alist)
5162 (make-variable-buffer-local 'c-file-offsets) 5355 (make-variable-buffer-local 'c-basic-offset)
5163 (make-variable-buffer-local 'c-comment-only-line-offset) 5356 (make-variable-buffer-local 'c-file-style)
5164 (make-variable-buffer-local 'c-block-comments-indent-p) 5357 (make-variable-buffer-local 'c-file-offsets)
5165 (make-variable-buffer-local 'c-cleanup-list) 5358 (make-variable-buffer-local 'c-comment-only-line-offset)
5166 (make-variable-buffer-local 'c-hanging-braces-alist) 5359 (make-variable-buffer-local 'c-cleanup-list)
5167 (make-variable-buffer-local 'c-hanging-colons-alist) 5360 (make-variable-buffer-local 'c-hanging-braces-alist)
5168 (make-variable-buffer-local 'c-hanging-comment-ender-p) 5361 (make-variable-buffer-local 'c-hanging-colons-alist)
5169 (make-variable-buffer-local 'c-backslash-column) 5362 (make-variable-buffer-local 'c-hanging-comment-starter-p)
5170 (make-variable-buffer-local 'c-label-minimum-indentation) 5363 (make-variable-buffer-local 'c-hanging-comment-ender-p)
5171 (make-variable-buffer-local 'c-special-indent-hook) 5364 (make-variable-buffer-local 'c-backslash-column)
5365 (make-variable-buffer-local 'c-label-minimum-indentation)
5366 (make-variable-buffer-local 'c-special-indent-hook)
5367 (make-variable-buffer-local 'c-indentation-style)))
5172 5368
5173 5369
5174 ;; fsets for compatibility with BOCM 5370 ;; fsets for compatibility with BOCM
5175 (fset 'electric-c-brace 'c-electric-brace) 5371 (fset 'electric-c-brace 'c-electric-brace)
5176 (fset 'electric-c-semi 'c-electric-semi&comma) 5372 (fset 'electric-c-semi 'c-electric-semi&comma)
5177 (fset 'electric-c-sharp-sign 'c-electric-pound) 5373 (fset 'electric-c-sharp-sign 'c-electric-pound)
5178 ;; there is no cc-mode equivalent for electric-c-terminator 5374 ;; there is no CC Mode equivalent for electric-c-terminator
5179 (fset 'mark-c-function 'c-mark-function) 5375 (fset 'mark-c-function 'c-mark-function)
5180 (fset 'indent-c-exp 'c-indent-exp) 5376 (fset 'indent-c-exp 'c-indent-exp)
5181 ;;;###autoload (fset 'set-c-style 'c-set-style) 5377 ;;;###autoload (fset 'set-c-style 'c-set-style)
5182 ;; Lucid Emacs 19.9 + font-lock + cc-mode - c++-mode lossage 5378 ;; Lucid Emacs 19.9 + font-lock + CC Mode - c++-mode lossage
5183 (fset 'c++-beginning-of-defun 'beginning-of-defun) 5379 (fset 'c++-beginning-of-defun 'beginning-of-defun)
5184 (fset 'c++-end-of-defun 'end-of-defun) 5380 (fset 'c++-end-of-defun 'end-of-defun)
5185 5381
5186 ;; set up bc warnings for obsolete variables, but for now lets not 5382 ;; set up bc warnings for obsolete variables, but for now lets not
5187 ;; worry about obsolete functions. maybe later some will be important 5383 ;; worry about obsolete functions. maybe later some will be important
5199 (cons 'c++-member-init-indent 'c-offsets-alist) 5395 (cons 'c++-member-init-indent 'c-offsets-alist)
5200 (cons 'c++-friend-offset na) 5396 (cons 'c++-friend-offset na)
5201 (cons 'c++-access-specifier-offset 'c-offsets-alist) 5397 (cons 'c++-access-specifier-offset 'c-offsets-alist)
5202 (cons 'c++-empty-arglist-indent 'c-offsets-alist) 5398 (cons 'c++-empty-arglist-indent 'c-offsets-alist)
5203 (cons 'c++-comment-only-line-offset 'c-comment-only-line-offset) 5399 (cons 'c++-comment-only-line-offset 'c-comment-only-line-offset)
5204 (cons 'c++-C-block-comments-indent-p 'c-block-comments-indent-p) 5400 (cons 'c++-C-block-comments-indent-p na)
5205 (cons 'c++-cleanup-list 'c-cleanup-list) 5401 (cons 'c++-cleanup-list 'c-cleanup-list)
5206 (cons 'c++-hanging-braces 'c-hanging-braces-alist) 5402 (cons 'c++-hanging-braces 'c-hanging-braces-alist)
5207 (cons 'c++-hanging-member-init-colon 'c-hanging-colons-alist) 5403 (cons 'c++-hanging-member-init-colon 'c-hanging-colons-alist)
5208 (cons 'c++-auto-hungry-initial-state 5404 (cons 'c++-auto-hungry-initial-state
5209 "Use `c-auto-newline' and `c-hungry-delete-key' instead.") 5405 "Use `c-auto-newline' and `c-hungry-delete-key' instead.")
5225 (cons 'c-label-offset 'c-offsets-alist) 5421 (cons 'c-label-offset 'c-offsets-alist)
5226 (cons 'c-continued-statement-offset 'c-offsets-alist) 5422 (cons 'c-continued-statement-offset 'c-offsets-alist)
5227 (cons 'c-continued-brace-offset 'c-offsets-alist) 5423 (cons 'c-continued-brace-offset 'c-offsets-alist)
5228 (cons 'c-default-macroize-column 'c-backslash-column) 5424 (cons 'c-default-macroize-column 'c-backslash-column)
5229 (cons 'c++-default-macroize-column 'c-backslash-column) 5425 (cons 'c++-default-macroize-column 'c-backslash-column)
5426 (cons 'c-block-comments-indent-p na)
5230 ))) 5427 )))
5231 (mapcar 5428 (mapcar
5232 (function 5429 (function
5233 (lambda (elt) 5430 (lambda (elt)
5234 (make-obsolete-variable (car elt) (cdr elt)))) 5431 (make-obsolete-variable (car elt) (cdr elt))))