Replace last-command-char with last-command-event.
[bpt/emacs.git] / lisp / progmodes / cc-align.el
1 ;;; cc-align.el --- custom indentation functions for CC Mode
2
3 ;; Copyright (C) 1985, 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
4 ;; 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
5 ;; Free Software Foundation, Inc.
6
7 ;; Authors: 2004- Alan Mackenzie
8 ;; 1998- Martin Stjernholm
9 ;; 1992-1999 Barry A. Warsaw
10 ;; 1987 Dave Detlefs and Stewart Clamen
11 ;; 1985 Richard M. Stallman
12 ;; Maintainer: bug-cc-mode@gnu.org
13 ;; Created: 22-Apr-1997 (split from cc-mode.el)
14 ;; Version: See cc-mode.el
15 ;; Keywords: c languages oop
16
17 ;; This file is part of GNU Emacs.
18
19 ;; GNU Emacs is free software: you can redistribute it and/or modify
20 ;; it under the terms of the GNU General Public License as published by
21 ;; the Free Software Foundation, either version 3 of the License, or
22 ;; (at your option) any later version.
23
24 ;; GNU Emacs is distributed in the hope that it will be useful,
25 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
26 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 ;; GNU General Public License for more details.
28
29 ;; You should have received a copy of the GNU General Public License
30 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
31
32 ;;; Commentary:
33
34 ;;; Code:
35
36 (eval-when-compile
37 (let ((load-path
38 (if (and (boundp 'byte-compile-dest-file)
39 (stringp byte-compile-dest-file))
40 (cons (file-name-directory byte-compile-dest-file) load-path)
41 load-path)))
42 (load "cc-bytecomp" nil t)))
43
44 (cc-require 'cc-defs)
45 (cc-require 'cc-vars)
46 (cc-require 'cc-engine)
47
48 \f
49 ;; Standard line-up functions
50 ;;
51 ;; See the section "Custom Indentation Functions" in the manual for
52 ;; details on the calling convention.
53
54 (defun c-lineup-topmost-intro-cont (langelem)
55 "Line up declaration continuation lines zero or one indentation step.
56 For lines in the \"header\" of a definition, zero is used. For other
57 lines, `c-basic-offset' is added to the indentation. E.g:
58
59 int
60 neg (int i) <- c-lineup-topmost-intro-cont
61 {
62 return -i;
63 }
64
65 struct
66 larch <- c-lineup-topmost-intro-cont
67 {
68 double height;
69 }
70 the_larch, <- c-lineup-topmost-intro-cont
71 another_larch; <- c-lineup-topmost-intro-cont
72 <--> c-basic-offset
73
74 struct larch
75 the_larch, <- c-lineup-topmost-intro-cont
76 another_larch; <- c-lineup-topmost-intro-cont
77
78 \(This function is mainly provided to mimic the behavior of CC Mode
79 5.28 and earlier where this case wasn't handled consistently so that
80 these lines could be analyzed as either topmost-intro-cont or
81 statement-cont.)
82
83 Works with: topmost-intro-cont."
84 (save-excursion
85 (beginning-of-line)
86 (c-backward-syntactic-ws (c-langelem-pos langelem))
87 (if (and (memq (char-before) '(?} ?,))
88 (not (and c-overloadable-operators-regexp
89 (c-after-special-operator-id))))
90 c-basic-offset)))
91
92 (defun c-lineup-gnu-DEFUN-intro-cont (langelem)
93 "Line up the continuation lines of a DEFUN macro in the Emacs C source.
94 These lines are indented as though they were `knr-argdecl-intro' lines.
95 Return nil when we're not in such a construct.
96
97 This function is for historical compatibility with how previous CC Modes (5.28
98 and earlier) indented such lines.
99
100 Here is an example:
101
102 DEFUN (\"forward-char\", Fforward_char, Sforward_char, 0, 1, \"p\",
103 doc: /* Move point right N characters (left if N is negative).
104 On reaching end of buffer, stop and signal error. */)
105 (n) <- c-lineup-gnu-DEFUN-into-cont
106 Lisp_Object n; <- c-lineup-gnu-DEFUN-into-cont
107
108 Works with: topmost-intro-cont."
109 (save-excursion
110 (let (case-fold-search)
111 (goto-char (c-langelem-pos langelem))
112 (if (looking-at "\\<DEFUN\\>")
113 (c-calc-offset '(knr-argdecl-intro))))))
114
115 (defun c-block-in-arglist-dwim (arglist-start)
116 ;; This function implements the DWIM to avoid far indentation of
117 ;; brace block constructs in arguments in `c-lineup-arglist' etc.
118 ;; Return non-nil if a brace block construct is detected within the
119 ;; arglist starting at ARGLIST-START.
120
121 (or
122 ;; Check if the syntactic context contains any of the symbols for
123 ;; in-expression constructs. This can both save the work that we
124 ;; have to do below, and it also detect the brace list constructs
125 ;; that `c-looking-at-inexpr-block' currently misses (they are
126 ;; recognized by `c-inside-bracelist-p' instead).
127 (assq 'inexpr-class c-syntactic-context)
128 (assq 'inexpr-statement c-syntactic-context)
129 (assq 'inlambda c-syntactic-context)
130
131 (save-restriction
132 ;; Search for open braces from the arglist start to the end of the
133 ;; line.
134 (narrow-to-region arglist-start (c-point 'eol arglist-start))
135
136 (goto-char arglist-start)
137 (while (and (c-syntactic-re-search-forward "{" nil t)
138 (progn
139 (backward-char)
140 (or
141 ;; Ignore starts of special brace lists.
142 (and c-special-brace-lists
143 (save-restriction
144 (widen)
145 (c-looking-at-special-brace-list)))
146 ;; Ignore complete blocks.
147 (c-safe (c-forward-sexp) t))))
148 (forward-char))
149
150 (looking-at "{"))
151
152 (let (containing-sexp)
153 (goto-char arglist-start)
154 ;; `c-syntactic-eol' always matches somewhere on the line.
155 (re-search-forward c-syntactic-eol)
156 (goto-char (match-beginning 0))
157 (c-forward-syntactic-ws)
158 (setq containing-sexp (c-most-enclosing-brace (c-parse-state)))
159 (c-looking-at-inexpr-block
160 (c-safe-position (or containing-sexp (point)) c-state-cache)
161 containing-sexp))))
162
163 (defun c-lineup-arglist (langelem)
164 "Line up the current argument line under the first argument.
165
166 As a special case, if the indented line is inside a brace block
167 construct, the indentation is `c-basic-offset' only. This is intended
168 as a \"DWIM\" measure in cases like macros that contains statement
169 blocks, e.g:
170
171 A_VERY_LONG_MACRO_NAME ({
172 some (code, with + long, lines * in[it]);
173 });
174 <--> c-basic-offset
175
176 This is motivated partly because it's more in line with how code
177 blocks are handled, and partly since it approximates the behavior of
178 earlier CC Mode versions, which due to inaccurate analysis tended to
179 indent such cases this way.
180
181 Works with: arglist-cont-nonempty, arglist-close."
182 (save-excursion
183 (let ((indent-pos (point)))
184
185 (if (c-block-in-arglist-dwim (c-langelem-2nd-pos c-syntactic-element))
186 c-basic-offset ; DWIM case.
187
188 ;; Normal case. Indent to the token after the arglist open paren.
189 (goto-char (c-langelem-2nd-pos c-syntactic-element))
190 (if (and c-special-brace-lists
191 (c-looking-at-special-brace-list))
192 ;; Skip a special brace list opener like "({".
193 (progn (c-forward-token-2)
194 (forward-char))
195 (forward-char))
196 (let ((arglist-content-start (point)))
197 (c-forward-syntactic-ws)
198 (when (< (point) indent-pos)
199 (goto-char arglist-content-start)
200 (skip-chars-forward " \t"))
201 (vector (current-column)))))))
202
203 ;; Contributed by Kevin Ryde <user42@zip.com.au>.
204 (defun c-lineup-argcont (elem)
205 "Line up a continued argument.
206
207 foo (xyz, aaa + bbb + ccc
208 + ddd + eee + fff); <- c-lineup-argcont
209
210 Only continuation lines like this are touched, nil is returned on lines
211 which are the start of an argument.
212
213 Within a gcc asm block, \":\" is recognized as an argument separator,
214 but of course only between operand specifications, not in the expressions
215 for the operands.
216
217 Works with: arglist-cont, arglist-cont-nonempty."
218
219 (save-excursion
220 (beginning-of-line)
221
222 (when (eq (car elem) 'arglist-cont-nonempty)
223 ;; Our argument list might not be the innermost one. If it
224 ;; isn't, go back to the last position in it. We do this by
225 ;; stepping back over open parens until we get to the open paren
226 ;; of our argument list.
227 (let ((open-paren (c-langelem-2nd-pos c-syntactic-element))
228 (paren-state (c-parse-state)))
229 (while (not (eq (car paren-state) open-paren))
230 (unless (consp (car paren-state)) ;; ignore matched braces
231 (goto-char (car paren-state)))
232 (setq paren-state (cdr paren-state)))))
233
234 (let ((start (point)) c)
235
236 (when (bolp)
237 ;; Previous line ending in a comma means we're the start of an
238 ;; argument. This should quickly catch most cases not for us.
239 ;; This case is only applicable if we're the innermost arglist.
240 (c-backward-syntactic-ws)
241 (setq c (char-before)))
242
243 (unless (eq c ?,)
244 ;; In a gcc asm, ":" on the previous line means the start of an
245 ;; argument. And lines starting with ":" are not for us, don't
246 ;; want them to indent to the preceding operand.
247 (let ((gcc-asm (save-excursion
248 (goto-char start)
249 (c-in-gcc-asm-p))))
250 (unless (and gcc-asm
251 (or (eq c ?:)
252 (save-excursion
253 (goto-char start)
254 (looking-at "[ \t]*:"))))
255
256 (c-lineup-argcont-scan (if gcc-asm ?:))
257 (vector (current-column))))))))
258
259 (defun c-lineup-argcont-scan (&optional other-match)
260 ;; Find the start of an argument, for `c-lineup-argcont'.
261 (when (zerop (c-backward-token-2 1 t))
262 (let ((c (char-after)))
263 (if (or (eq c ?,) (eq c other-match))
264 (progn
265 (forward-char)
266 (c-forward-syntactic-ws))
267 (c-lineup-argcont-scan other-match)))))
268
269 (defun c-lineup-arglist-intro-after-paren (langelem)
270 "Line up a line to just after the open paren of the surrounding paren
271 or brace block.
272
273 Works with: defun-block-intro, brace-list-intro,
274 statement-block-intro, statement-case-intro, arglist-intro."
275 (save-excursion
276 (beginning-of-line)
277 (backward-up-list 1)
278 (skip-chars-forward " \t" (c-point 'eol))
279 (vector (1+ (current-column)))))
280
281 (defun c-lineup-arglist-close-under-paren (langelem)
282 "Line up a line under the enclosing open paren.
283 Normally used to line up a closing paren in the same column as its
284 corresponding open paren, but can also be used with arglist-cont and
285 arglist-cont-nonempty to line up all lines inside a parenthesis under
286 the open paren.
287
288 As a special case, if a brace block construct starts at the same line
289 as the open parenthesis of the argument list, the indentation is
290 `c-basic-offset' only. See `c-lineup-arglist' for further discussion
291 of this \"DWIM\" measure.
292
293 Works with: Almost all symbols, but are typically most useful on
294 arglist-close, brace-list-close, arglist-cont and arglist-cont-nonempty."
295 (save-excursion
296 (if (memq (c-langelem-sym langelem)
297 '(arglist-cont-nonempty arglist-close))
298 (goto-char (c-langelem-2nd-pos c-syntactic-element))
299 (beginning-of-line)
300 (c-go-up-list-backward))
301
302 (if (save-excursion (c-block-in-arglist-dwim (point)))
303 c-basic-offset ; DWIM case.
304
305 ;; Normal case. Indent to the arglist open paren.
306 (let (special-list)
307 (if (and c-special-brace-lists
308 (setq special-list (c-looking-at-special-brace-list)))
309 ;; Cope if we're in the middle of a special brace list
310 ;; opener like "({".
311 (goto-char (car (car special-list))))
312 (vector (current-column))))))
313
314 (defun c-lineup-arglist-operators (langelem)
315 "Line up lines starting with an infix operator under the open paren.
316 Return nil on lines that don't start with an operator, to leave those
317 cases to other line-up functions. Example:
318
319 if ( x < 10
320 || at_limit (x, <- c-lineup-arglist-operators
321 list) <- c-lineup-arglist-operators returns nil
322 )
323
324 Since this function doesn't do anything for lines without an infix
325 operator you typically want to use it together with some other line-up
326 settings, e.g. as follows \(the arglist-close setting is just a
327 suggestion to get a consistent style):
328
329 \(c-set-offset 'arglist-cont '(c-lineup-arglist-operators 0))
330 \(c-set-offset 'arglist-cont-nonempty '(c-lineup-arglist-operators
331 c-lineup-arglist))
332 \(c-set-offset 'arglist-close '(c-lineup-arglist-close-under-paren))
333
334 Works with: arglist-cont, arglist-cont-nonempty."
335 (save-excursion
336 (back-to-indentation)
337 (when (looking-at "[-+|&*%<>=]\\|\\(/[^/*]\\)")
338 ;; '-' can be both an infix and a prefix operator, but I'm lazy now..
339 (c-lineup-arglist-close-under-paren langelem))))
340
341 (defun c-lineup-close-paren (langelem)
342 "Line up the closing paren under its corresponding open paren if the
343 open paren is followed by code. If the open paren ends its line, no
344 indentation is added. E.g:
345
346 main (int, main (
347 char ** int, char **
348 ) <-> ) <- c-lineup-close-paren
349
350 As a special case, if a brace block construct starts at the same line
351 as the open parenthesis of the argument list, the indentation is
352 `c-basic-offset' instead of the open paren column. See
353 `c-lineup-arglist' for further discussion of this \"DWIM\" measure.
354
355 Works with: All *-close symbols."
356 (save-excursion
357 (if (memq (c-langelem-sym langelem)
358 '(arglist-cont-nonempty arglist-close))
359 (goto-char (c-langelem-2nd-pos c-syntactic-element))
360 (beginning-of-line)
361 (c-go-up-list-backward))
362
363 (let (special-list arglist-start)
364 (if (and c-special-brace-lists
365 (setq special-list (c-looking-at-special-brace-list)))
366 ;; Cope if we're in the middle of a special brace list
367 ;; opener like "({".
368 (progn
369 (goto-char (setq arglist-start (car (car special-list))))
370 (c-forward-token-2)
371 (forward-char))
372 (setq arglist-start (point))
373 (forward-char))
374
375 (cond ((looking-at c-syntactic-eol)
376 0) ; The arglist is "empty".
377
378 ((c-block-in-arglist-dwim (point))
379 c-basic-offset) ; DWIM case.
380
381 (t
382 ;; Normal case. Indent to the arglist open paren.
383 (goto-char arglist-start)
384 (vector (current-column)))))))
385
386 (defun c-lineup-streamop (langelem)
387 "Line up C++ stream operators under each other.
388
389 Works with: stream-op."
390 (save-excursion
391 (goto-char (c-langelem-pos langelem))
392 (re-search-forward "<<\\|>>" (c-point 'eol) 'move)
393 (goto-char (match-beginning 0))
394 (vector (current-column))))
395
396 (defun c-lineup-multi-inher (langelem)
397 "Line up the classes in C++ multiple inheritance clauses and member
398 initializers under each other. E.g:
399
400 class Foo: Foo::Foo (int a, int b):
401 public Cyphr, Cyphr (a),
402 public Bar <-> Bar (b) <- c-lineup-multi-inher
403
404 class Foo Foo::Foo (int a, int b)
405 : public Cyphr, : Cyphr (a),
406 public Bar <-> Bar (b) <- c-lineup-multi-inher
407
408 class Foo Foo::Foo (int a, int b)
409 : public Cyphr : Cyphr (a)
410 , public Bar <-> , Bar (b) <- c-lineup-multi-inher
411
412 Works with: inher-cont, member-init-cont."
413 (save-excursion
414 (back-to-indentation)
415 (let* ((eol (c-point 'eol))
416 (here (point))
417 (char-after-ip (char-after)))
418 (if (c-langelem-pos langelem)
419 (goto-char (c-langelem-pos langelem)))
420
421 ;; This kludge is necessary to support both inher-cont and
422 ;; member-init-cont, since they have different anchor positions.
423 (c-backward-syntactic-ws)
424 (when (eq (char-before) ?:)
425 (backward-char)
426 (c-backward-syntactic-ws))
427
428 (c-syntactic-re-search-forward ":" eol 'move)
429 (if (looking-at c-syntactic-eol)
430 (c-forward-syntactic-ws here)
431 (if (eq char-after-ip ?,)
432 (backward-char)
433 (skip-chars-forward " \t" eol)))
434 (if (< (point) here)
435 (vector (current-column)))
436 )))
437
438 (defun c-lineup-java-inher (langelem)
439 "Line up Java implements and extends declarations.
440 If class names follow on the same line as the implements/extends
441 keyword, they are lined up under each other. Otherwise, they are
442 indented by adding `c-basic-offset' to the column of the keyword.
443 E.g:
444
445 class Foo class Foo
446 extends extends Cyphr,
447 Bar <-> Bar <- c-lineup-java-inher
448 <--> c-basic-offset
449
450 Works with: inher-cont."
451 (save-excursion
452 (goto-char (c-langelem-pos langelem))
453 (forward-word 1)
454 (if (looking-at "[ \t]*$")
455 c-basic-offset
456 (c-forward-syntactic-ws)
457 (vector (current-column)))))
458
459 (defun c-lineup-java-throws (langelem)
460 "Line up Java throws declarations.
461 If exception names follow on the same line as the throws keyword,
462 they are lined up under each other. Otherwise, they are indented by
463 adding `c-basic-offset' to the column of the throws keyword. The
464 throws keyword itself is also indented by `c-basic-offset' from the
465 function declaration start if it doesn't hang. E.g:
466
467 int foo() int foo() throws Cyphr,
468 throws <-> Bar, <- c-lineup-java-throws
469 Bar <-> Vlod <- c-lineup-java-throws
470 <--><--> c-basic-offset
471
472 Works with: func-decl-cont."
473 (save-excursion
474 (let* ((lim (1- (c-point 'bol)))
475 (throws (catch 'done
476 (goto-char (c-langelem-pos langelem))
477 (while (zerop (c-forward-token-2 1 t lim))
478 (if (looking-at "throws\\>[^_]")
479 (throw 'done t))))))
480 (if throws
481 (if (zerop (c-forward-token-2 1 nil (c-point 'eol)))
482 (vector (current-column))
483 (back-to-indentation)
484 (vector (+ (current-column) c-basic-offset)))
485 c-basic-offset))))
486
487 (defun c-indent-one-line-block (langelem)
488 "Indent a one line block `c-basic-offset' extra.
489 E.g:
490
491 if (n > 0) if (n > 0)
492 {m+=n; n=0;} <-> { <- c-indent-one-line-block
493 <--> c-basic-offset m+=n; n=0;
494 }
495
496 The block may use any kind of parenthesis character. nil is returned
497 if the line doesn't start with a one line block, which makes the
498 function usable in list expressions.
499
500 Work with: Almost all syntactic symbols, but most useful on *-open."
501 (save-excursion
502 (let ((eol (c-point 'eol)))
503 (back-to-indentation)
504 (if (and (eq (char-syntax (char-after)) ?\()
505 (c-safe (progn (c-forward-sexp) t))
506 (<= (point) eol))
507 c-basic-offset
508 nil))))
509
510 (defun c-indent-multi-line-block (langelem)
511 "Indent a multi line block `c-basic-offset' extra.
512 E.g:
513
514 int *foo[] = { int *foo[] = {
515 NULL, NULL,
516 {17}, <-> { <- c-indent-multi-line-block
517 17
518 }
519 <--> c-basic-offset
520
521 The block may use any kind of parenthesis character. nil is returned
522 if the line doesn't start with a multi line block, which makes the
523 function usable in list expressions.
524
525 Work with: Almost all syntactic symbols, but most useful on *-open."
526 (save-excursion
527 (let ((eol (c-point 'eol)))
528 (back-to-indentation)
529 (if (and (eq (char-syntax (char-after)) ?\()
530 (or (not (c-safe (progn (c-forward-sexp) t)))
531 (> (point) eol)))
532 c-basic-offset
533 nil))))
534
535 (defun c-lineup-C-comments (langelem)
536 "Line up C block comment continuation lines.
537 Various heuristics are used to handle many of the common comment
538 styles. Some examples:
539
540 /* /** /* /* text /* /**
541 * text * text text text ** text ** text
542 */ */ */ */ */ */
543
544 /*********************************************************************
545 * text
546 ********************************************************************/
547
548 /*********************************************************************
549 Free form text comments:
550 In comments with a long delimiter line at the start, the indentation
551 is kept unchanged for lines that start with an empty comment line
552 prefix. The delimiter line is whatever matches the
553 `comment-start-skip' regexp.
554 *********************************************************************/
555
556 The variable `c-comment-prefix-regexp' is used to recognize the
557 comment line prefix, e.g. the `*' that usually starts every line
558 inside a comment.
559
560 Works with: The `c' syntactic symbol."
561 (save-excursion
562 (let* ((here (point))
563 (prefixlen (progn (back-to-indentation)
564 (if (looking-at c-current-comment-prefix)
565 (- (match-end 0) (point))
566 0)))
567 (starterlen
568 ;; Get the length of the comment starter, not including
569 ;; the first '/'. We check if the comment prefix matched
570 ;; on the current line matches the starter or if it
571 ;; matches comment-start-skip, and choose whichever is
572 ;; longest.
573 (max (save-excursion
574 (goto-char (1+ (c-langelem-pos langelem)))
575 (if (and (match-string 0)
576 (looking-at (regexp-quote (match-string 0))))
577 (- (match-end 0) (match-beginning 0))
578 0))
579 (save-excursion
580 (goto-char (c-langelem-pos langelem))
581 (looking-at comment-start-skip)
582 (- (or (match-end 1)
583 (save-excursion
584 (goto-char (match-end 0))
585 (skip-chars-backward " \t")
586 (point)))
587 (point)
588 1)))))
589 (if (and (> starterlen 10) (zerop prefixlen))
590 ;; The comment has a long starter and the line doesn't have
591 ;; a nonempty comment prefix. Treat it as free form text
592 ;; and don't change the indentation.
593 (vector (current-column))
594 ;; Go back to the previous non-blank line, if any.
595 (while
596 (progn
597 (forward-line -1)
598 (back-to-indentation)
599 (and (> (point) (c-langelem-pos langelem))
600 (looking-at "[ \t]*$"))))
601 ;; Is the starting line the first continuation line with content?
602 (if (>= (c-langelem-pos langelem) (point))
603 (if (zerop prefixlen)
604 ;; No nonempty comment prefix. Align after comment
605 ;; starter.
606 (progn
607 (looking-at comment-start-skip)
608 (goto-char (match-end 0))
609 ;; The following should not be necessary, since
610 ;; comment-start-skip should match everything (i.e.
611 ;; typically whitespace) that leads up to the text.
612 ;;(if (looking-at "\\([ \t]+\\).+$")
613 ;; ;; Align with the text that hangs after the
614 ;; ;; comment starter.
615 ;; (goto-char (match-end 1)))
616 (vector (current-column)))
617 ;; How long is the comment starter? if greater than the
618 ;; length of the comment prefix, align left. if less
619 ;; than or equal, align right. this should also pick up
620 ;; Javadoc style comments.
621 (if (> starterlen prefixlen)
622 (progn
623 (goto-char (c-langelem-pos langelem))
624 (vector (1+ (current-column))))
625 (goto-char (+ (c-langelem-pos langelem) starterlen 1))
626 (vector (- (current-column) prefixlen))))
627 ;; We didn't start on the first non-blank continuation line. If the
628 ;; previous line has a nonempty comment prefix, align with it.
629 ;; Otherwise, align with the previous nonempty line, but align the
630 ;; comment ender with the starter.
631 (when (or (not (looking-at c-current-comment-prefix))
632 (eq (match-beginning 0) (match-end 0)))
633 (goto-char here)
634 (back-to-indentation)
635 (if (looking-at (concat "\\(" c-current-comment-prefix "\\)\\*/"))
636 (goto-char (c-langelem-pos langelem))
637 (while (and (zerop (forward-line -1))
638 (looking-at "^[ \t]*$")))
639 (back-to-indentation)
640 (if (< (point) (c-langelem-pos langelem))
641 ;; Align with the comment starter rather than
642 ;; with the code before it.
643 (goto-char (c-langelem-pos langelem)))))
644 (vector (current-column)))))))
645
646 (defun c-lineup-comment (langelem)
647 "Line up a comment start according to `c-comment-only-line-offset'.
648 If the comment is lined up with a comment starter on the previous
649 line, that alignment is preserved.
650
651 Works with: comment-intro."
652 (save-excursion
653 (back-to-indentation)
654 (let ((col (current-column)))
655 (cond
656 ;; CASE 1: preserve aligned comments
657 ((save-excursion
658 (and (c-backward-single-comment)
659 (= col (current-column))))
660 (vector col)) ; Return an absolute column.
661 ;; indent as specified by c-comment-only-line-offset
662 ((not (bolp))
663 (or (car-safe c-comment-only-line-offset)
664 c-comment-only-line-offset))
665 (t
666 (or (cdr-safe c-comment-only-line-offset)
667 (car-safe c-comment-only-line-offset)
668 -1000)) ;jam it against the left side
669 ))))
670
671 (defun c-lineup-knr-region-comment (langelem)
672 "Line up a comment in the \"K&R region\" with the declaration.
673 That is the region between the function or class header and the
674 beginning of the block. E.g:
675
676 int main()
677 /* This is the main function. */ <- c-lineup-knr-region-comment
678 {
679 return 0;
680 }
681
682 Return nil if called in any other situation, to be useful in list
683 expressions.
684
685 Works with: comment-intro."
686 (when (or (assq 'topmost-intro-cont c-syntactic-context)
687 (assq 'func-decl-cont c-syntactic-context)
688 (assq 'knr-argdecl-intro c-syntactic-context)
689 (assq 'lambda-intro-cont c-syntactic-context))
690 (save-excursion
691 (beginning-of-line)
692 (c-beginning-of-statement-1)
693 (vector (current-column)))))
694
695 (defun c-lineup-runin-statements (langelem)
696 "Line up statements when the first statement is on the same line as
697 the block opening brace. E.g:
698
699 int main()
700 { puts (\"Hello world!\");
701 return 0; <- c-lineup-runin-statements
702 }
703
704 If there is no statement after the opening brace to align with, nil is
705 returned. This makes the function usable in list expressions.
706
707 Works with: The `statement' syntactic symbol."
708 (if (eq (char-after (c-langelem-pos langelem)) ?{)
709 (save-excursion
710 (if (c-langelem-pos langelem)
711 (goto-char (c-langelem-pos langelem)))
712 (forward-char 1)
713 (skip-chars-forward " \t")
714 (unless (eolp)
715 (vector (current-column))))))
716
717 (defun c-lineup-assignments (langelem)
718 "Line up the current line after the assignment operator on the first
719 line in the statement. If there isn't any, return nil to allow
720 stacking with other line-up functions. If the current line contains
721 an assignment operator too, try to align it with the first one.
722
723 Works with: topmost-intro-cont, statement-cont, arglist-cont,
724 arglist-cont-nonempty."
725 (let (startpos endpos equalp)
726
727 (if (eq (c-langelem-sym langelem) 'arglist-cont-nonempty)
728 ;; If it's an arglist-cont-nonempty then we're only interested
729 ;; in equal signs outside it. We don't search for a "=" on
730 ;; the current line since that'd have a different nesting
731 ;; compared to the one we should align with.
732 (save-excursion
733 (save-restriction
734 (setq endpos (c-langelem-2nd-pos c-syntactic-element))
735 (narrow-to-region (c-langelem-pos langelem) endpos)
736 (if (setq startpos (c-up-list-backward endpos))
737 (setq startpos (1+ startpos))
738 (setq startpos (c-langelem-pos langelem)))))
739
740 (setq startpos (c-langelem-pos langelem)
741 endpos (point))
742
743 ;; Find a syntactically relevant and unnested "=" token on the
744 ;; current line. equalp is in that case set to the number of
745 ;; columns to left shift the current line to align it with the
746 ;; goal column.
747 (save-excursion
748 (beginning-of-line)
749 (when (c-syntactic-re-search-forward
750 c-assignment-op-regexp
751 (c-point 'eol) t t t)
752 (setq equalp (- (or (match-beginning 1)
753 (match-end 0))
754 (c-point 'boi))))))
755
756 (save-excursion
757 (goto-char startpos)
758 (if (or (if (c-syntactic-re-search-forward
759 c-assignment-op-regexp
760 (min endpos (c-point 'eol)) t t t)
761 (progn
762 (goto-char (or (match-beginning 1)
763 (match-end 0)))
764 nil)
765 t)
766 (save-excursion
767 (c-forward-syntactic-ws (c-point 'eol))
768 (eolp)))
769 ;; There's no equal sign on the line, or there is one but
770 ;; nothing follows it.
771 nil
772
773 ;; calculate indentation column after equals and ws, unless
774 ;; our line contains an equals sign
775 (if (not equalp)
776 (progn
777 (skip-chars-forward " \t")
778 (setq equalp 0)))
779
780 (vector (- (current-column) equalp)))
781 )))
782
783 (defun c-lineup-math (langelem)
784 "Like `c-lineup-assignments' but indent with `c-basic-offset' if no
785 assignment operator was found on the first line. I.e. this function
786 is the same as specifying a list (c-lineup-assignments +). It's
787 provided for compatibility with old configurations.
788
789 Works with: topmost-intro-cont, statement-cont, arglist-cont,
790 arglist-cont-nonempty."
791 (or (c-lineup-assignments langelem)
792 c-basic-offset))
793
794 (defun c-lineup-cascaded-calls (langelem)
795 "Line up \"cascaded calls\" under each other.
796 If the line begins with \"->\" or \".\" and the preceding line ends
797 with one or more function calls preceded by the same token, then the
798 arrow is lined up with the first of those tokens. E.g:
799
800 result = proc->add(17)->add(18)
801 ->add(19) + <- c-lineup-cascaded-calls
802 offset; <- c-lineup-cascaded-calls (inactive)
803
804 In any other situation nil is returned to allow use in list
805 expressions.
806
807 Works with: topmost-intro-cont, statement-cont, arglist-cont,
808 arglist-cont-nonempty."
809
810 (if (and (eq (c-langelem-sym langelem) 'arglist-cont-nonempty)
811 (not (eq (c-langelem-2nd-pos c-syntactic-element)
812 (c-most-enclosing-brace (c-parse-state)))))
813 ;; The innermost open paren is not our one, so don't do
814 ;; anything. This can occur for arglist-cont-nonempty with
815 ;; nested arglist starts on the same line.
816 nil
817
818 (save-excursion
819 (back-to-indentation)
820 (let ((operator (and (looking-at "->\\|\\.")
821 (regexp-quote (match-string 0))))
822 (stmt-start (c-langelem-pos langelem)) col)
823
824 (when (and operator
825 (looking-at operator)
826 (zerop (c-backward-token-2 1 t stmt-start))
827 (eq (char-after) ?\()
828 (zerop (c-backward-token-2 2 t stmt-start))
829 (looking-at operator))
830 (setq col (current-column))
831
832 (while (and (zerop (c-backward-token-2 1 t stmt-start))
833 (eq (char-after) ?\()
834 (zerop (c-backward-token-2 2 t stmt-start))
835 (looking-at operator))
836 (setq col (current-column)))
837
838 (vector col))))))
839
840 (defun c-lineup-string-cont (langelem)
841 "Line up a continued string under the one it continues.
842 A continued string in this sense is where a string literal follows
843 directly after another one. E.g:
844
845 result = prefix + \"A message \"
846 \"string.\"; <- c-lineup-string-cont
847
848 In other situations, returns nil, to allow stacking with other
849 line-up functions.
850
851 Works with: topmost-intro-cont, statement-cont, arglist-cont,
852 arglist-cont-nonempty."
853 (save-excursion
854 (back-to-indentation)
855 (and (looking-at "\\s\"")
856 (let ((quote (char-after)) pos)
857 (while (and (progn (c-backward-syntactic-ws)
858 (eq (char-before) quote))
859 (c-safe (c-backward-sexp) t)
860 (/= (setq pos (point)) (c-point 'boi))))
861 (when pos
862 (goto-char pos)
863 (vector (current-column)))))))
864
865 (defun c-lineup-template-args (langelem)
866 "Line up template argument lines under the first argument.
867 To allow this function to be used in a list expression, nil is
868 returned if there's no template argument on the first line.
869
870 Works with: template-args-cont."
871 (save-excursion
872 (c-with-syntax-table c++-template-syntax-table
873 (beginning-of-line)
874 (backward-up-list 1)
875 (if (and (eq (char-after) ?<)
876 (zerop (c-forward-token-2 1 nil (c-point 'eol))))
877 (vector (current-column))))))
878
879 (defun c-lineup-ObjC-method-call (langelem)
880 "Line up selector args as Emacs Lisp mode does with function args:
881 Go to the position right after the message receiver, and if you are at
882 the end of the line, indent the current line c-basic-offset columns
883 from the opening bracket; otherwise you are looking at the first
884 character of the first method call argument, so line up the current
885 line with it.
886
887 Works with: objc-method-call-cont."
888 (save-excursion
889 (let* ((extra (save-excursion
890 (back-to-indentation)
891 (c-backward-syntactic-ws (c-langelem-pos langelem))
892 (if (eq (char-before) ?:)
893 (- c-basic-offset)
894 0)))
895 (open-bracket-pos (c-langelem-pos langelem))
896 (open-bracket-col (progn
897 (goto-char open-bracket-pos)
898 (current-column)))
899 (target-col (progn
900 (forward-char)
901 (c-forward-sexp)
902 (skip-chars-forward " \t")
903 (if (eolp)
904 (+ open-bracket-col c-basic-offset)
905 (current-column))))
906 )
907 (- target-col open-bracket-col extra))))
908
909 (defun c-lineup-ObjC-method-args (langelem)
910 "Line up the colons that separate args.
911 The colon on the current line is aligned with the one on the first
912 line.
913
914 Works with: objc-method-args-cont."
915 (save-excursion
916 (let* ((here (c-point 'boi))
917 (curcol (progn (goto-char here) (current-column)))
918 (eol (c-point 'eol))
919 (relpos (c-langelem-pos langelem))
920 (first-col-column (progn
921 (goto-char relpos)
922 (skip-chars-forward "^:" eol)
923 (and (eq (char-after) ?:)
924 (current-column)))))
925 (if (not first-col-column)
926 c-basic-offset
927 (goto-char here)
928 (skip-chars-forward "^:" eol)
929 (if (eq (char-after) ?:)
930 (+ curcol (- first-col-column (current-column)))
931 c-basic-offset)))))
932
933 (defun c-lineup-ObjC-method-args-2 (langelem)
934 "Line up the colons that separate args.
935 The colon on the current line is aligned with the one on the previous
936 line.
937
938 Works with: objc-method-args-cont."
939 (save-excursion
940 (let* ((here (c-point 'boi))
941 (curcol (progn (goto-char here) (current-column)))
942 (eol (c-point 'eol))
943 (relpos (c-langelem-pos langelem))
944 (prev-col-column (progn
945 (skip-chars-backward "^:" relpos)
946 (and (eq (char-before) ?:)
947 (- (current-column) 1)))))
948 (if (not prev-col-column)
949 c-basic-offset
950 (goto-char here)
951 (skip-chars-forward "^:" eol)
952 (if (eq (char-after) ?:)
953 (+ curcol (- prev-col-column (current-column)))
954 c-basic-offset)))))
955
956 (defun c-lineup-inexpr-block (langelem)
957 "Line up the block for constructs that use a block inside an expression,
958 e.g. anonymous classes in Java and lambda functions in Pike. The body
959 is aligned with the start of the header, e.g. with the \"new\" or
960 \"lambda\" keyword. Returns nil if the block isn't part of such a
961 construct.
962
963 Works with: inlambda, inexpr-statement, inexpr-class."
964 (save-excursion
965 (back-to-indentation)
966 (let* ((paren-state (c-parse-state))
967 (containing-sexp (c-most-enclosing-brace paren-state))
968 (res (or (c-looking-at-inexpr-block
969 (c-safe-position containing-sexp paren-state)
970 containing-sexp)
971 (and containing-sexp
972 (progn (goto-char containing-sexp)
973 (eq (char-after) ?{))
974 (progn (setq containing-sexp
975 (c-most-enclosing-brace paren-state
976 (point)))
977 (c-looking-at-inexpr-block
978 (c-safe-position containing-sexp paren-state)
979 containing-sexp))))))
980 (when res
981 (goto-char (cdr res))
982 (vector (current-column))))))
983
984 (defun c-lineup-whitesmith-in-block (langelem)
985 "Line up lines inside a block in Whitesmith style.
986 It's done in a way that works both when the opening brace hangs and
987 when it doesn't. E.g:
988
989 something
990 { something {
991 foo; <-> foo; <- c-lineup-whitesmith-in-block
992 } }
993 <--> c-basic-offset
994
995 In the first case the indentation is kept unchanged, in the
996 second `c-basic-offset' is added.
997
998 Works with: defun-close, defun-block-intro, inline-close, block-close,
999 brace-list-close, brace-list-intro, statement-block-intro,
1000 arglist-intro, arglist-cont-nonempty, arglist-close, and all in*
1001 symbols, e.g. inclass and inextern-lang."
1002 (save-excursion
1003 (if (and (c-go-up-list-backward)
1004 (= (point) (c-point 'boi)))
1005 nil
1006 c-basic-offset)))
1007
1008 (defun c-lineup-after-whitesmith-blocks (langelem)
1009 "Compensate for Whitesmith style indentation of blocks.
1010 Due to the way CC Mode calculates anchor positions for normal lines
1011 inside blocks, this function is necessary for those lines to get
1012 correct Whitesmith style indentation. Consider the following
1013 examples:
1014
1015 int foo()
1016 {
1017 int foo() {
1018 { a;
1019 a; }
1020 x; <-> x; <- c-lineup-after-whitesmith-blocks
1021
1022 The fact that the line with \"x\" is preceded by a Whitesmith style
1023 indented block in one case and not the other should not affect its
1024 indentation. But since CC Mode in cases like this uses the
1025 indentation of the preceding statement as anchor position, the \"x\"
1026 would in the rightmost case be indented too much if the offset for
1027 `statement' was set simply to zero.
1028
1029 This lineup function corrects for this situation by detecting if the
1030 anchor position is at an open paren character. In that case, it
1031 instead indents relative to the surrounding block just like
1032 `c-lineup-whitesmith-in-block'.
1033
1034 Works with: brace-list-entry, brace-entry-open, statement,
1035 arglist-cont."
1036 (save-excursion
1037 (goto-char (c-langelem-pos langelem))
1038 (when (looking-at "\\s\(")
1039 (if (c-go-up-list-backward)
1040 (let ((pos (point)))
1041 (back-to-indentation)
1042 (if (= pos (point))
1043 (vector (current-column))
1044 (vector (+ (current-column) c-basic-offset))))
1045 (vector 0)))))
1046
1047 (defun c-lineup-cpp-define (langelem)
1048 "Line up macro continuation lines according to the indentation of
1049 the construct preceding the macro. E.g:
1050
1051 v beg of preceding constr v beg of preceding constr
1052 int dribble() {
1053 const char msg[] = if (!running)
1054 \"Some text.\"; error(\"Not running!\");
1055
1056 #define X(A, B) \ #define X(A, B) \
1057 do { \ <-> do { \ <- c-lineup-cpp-define
1058 printf (A, B); \ printf (A, B); \
1059 } while (0) } while (0)
1060
1061 If `c-syntactic-indentation-in-macros' is non-nil, the function
1062 returns the relative indentation to the macro start line to allow
1063 accumulation with other offsets. E.g. in the following cases,
1064 cpp-define-intro is combined with the statement-block-intro that comes
1065 from the \"do {\" that hangs on the \"#define\" line:
1066
1067 int dribble() {
1068 const char msg[] = if (!running)
1069 \"Some text.\"; error(\"Not running!\");
1070
1071 #define X(A, B) do { \ #define X(A, B) do { \
1072 printf (A, B); \ <-> printf (A, B); \ <- c-lineup-cpp-define
1073 this->refs++; \ this->refs++; \
1074 } while (0) <-> } while (0) <- c-lineup-cpp-define
1075
1076 The relative indentation returned by `c-lineup-cpp-define' is zero and
1077 two, respectively, in these two examples. They are then added to the
1078 two column indentation that statement-block-intro gives in both cases
1079 here.
1080
1081 If the relative indentation is zero, then nil is returned instead.
1082 That is useful in a list expression to specify the default indentation
1083 on the top level.
1084
1085 If `c-syntactic-indentation-in-macros' is nil then this function keeps
1086 the current indentation, except for empty lines \(ignoring the ending
1087 backslash) where it takes the indentation from the closest preceding
1088 nonempty line in the macro. If there's no such line in the macro then
1089 the indentation is taken from the construct preceding it, as described
1090 above.
1091
1092 Works with: cpp-define-intro."
1093 (let (offset)
1094 (if c-syntactic-indentation-in-macros
1095 ;; Go to the macro start and do a syntactic analysis of it.
1096 ;; Then remove the cpp-macro element it should contain and
1097 ;; calculate the indentation it then would get.
1098 (save-excursion
1099 (c-beginning-of-macro)
1100 (setq offset (- (c-get-syntactic-indentation
1101 (delete '(cpp-macro) (c-guess-basic-syntax)))
1102 (save-excursion
1103 (back-to-indentation)
1104 (current-column))))
1105 (if (zerop offset)
1106 nil
1107 offset))
1108 ;; Do not indent syntactically inside the macro.
1109 (save-excursion
1110 (let ((macro-start-line (save-excursion
1111 (goto-char (c-query-macro-start))
1112 (beginning-of-line)
1113 (point))))
1114 (beginning-of-line)
1115 ;; Check every line while inside the macro.
1116 (while (and (> (point) macro-start-line)
1117 (looking-at "[ \t]*\\\\?$")
1118 (= (forward-line -1) 0)))
1119 (if (<= (point) macro-start-line)
1120 ;; If we've stepped out of the macro we take the
1121 ;; syntactic offset.
1122 (setq offset (c-get-syntactic-indentation
1123 (delete '(cpp-macro) (c-guess-basic-syntax))))
1124 (setq offset (current-indentation)))
1125 (if (zerop offset)
1126 nil
1127 (vector offset)))))))
1128
1129 ;; Contributed by Kevin Ryde <user42@zip.com.au>.
1130 (defun c-lineup-gcc-asm-reg (elem)
1131 "Line up a gcc asm register under one on a previous line.
1132
1133 asm (\"foo %1, %0\\n\"
1134 \"bar %0, %1\"
1135 : \"=r\" (w),
1136 \"=r\" (x)
1137 : \"0\" (y),
1138 \"1\" (z));
1139
1140 The \"x\" line is aligned to the text after the \":\" on the \"w\" line, and
1141 similarly \"z\" under \"y\".
1142
1143 This is done only in an \"asm\" or \"__asm__\" block, and only to
1144 those lines mentioned. Anywhere else nil is returned. The usual
1145 arrangement is to have this routine as an extra feature at the start
1146 of arglist line-ups, e.g.
1147
1148 (c-lineup-gcc-asm-reg c-lineup-arglist)
1149
1150 Works with: arglist-cont, arglist-cont-nonempty."
1151
1152 (let ((orig-pos (point))
1153 alignto)
1154 (save-excursion
1155 (and
1156 c-opt-asm-stmt-key
1157
1158 ;; Don't do anything if the innermost open paren isn't our one.
1159 ;; This can occur for arglist-cont-nonempty with nested arglist
1160 ;; starts on the same line.
1161 (or (not (eq (car elem) 'arglist-cont-nonempty))
1162 (eq (c-langelem-2nd-pos c-syntactic-element)
1163 (c-most-enclosing-brace (c-parse-state))))
1164
1165 ;; Find the ":" to align to. Look for this first so as to quickly
1166 ;; eliminate pretty much all cases which are not for us.
1167 (re-search-backward "^[ \t]*:[ \t]*\\(.\\)?" (cdr elem) t)
1168
1169 ;; Must have something after the ":".
1170 (setq alignto (match-beginning 1))
1171
1172 ;; Don't touch ":" lines themselves.
1173 (progn (goto-char orig-pos)
1174 (beginning-of-line)
1175 (not (looking-at "^[ \t]*:")))
1176
1177 ;; Only operate in an asm statement.
1178 (progn (goto-char orig-pos)
1179 (c-in-gcc-asm-p))
1180
1181 (vector (progn (goto-char alignto) (current-column)))))))
1182
1183 (defun c-lineup-dont-change (langelem)
1184 "Do not change the indentation of the current line.
1185
1186 Works with: Any syntactic symbol."
1187 (save-excursion
1188 (back-to-indentation)
1189 (vector (current-column))))
1190
1191 \f
1192 (defun c-snug-do-while (syntax pos)
1193 "Dynamically calculate brace hanginess for do-while statements.
1194 Using this function, `while' clauses that end a `do-while' block will
1195 remain on the same line as the brace that closes that block.
1196
1197 See `c-hanging-braces-alist' for how to utilize this function as an
1198 ACTION associated with `block-close' syntax."
1199 (save-excursion
1200 (let (langelem)
1201 (if (and (eq syntax 'block-close)
1202 (setq langelem (assq 'block-close c-syntactic-context))
1203 (progn (goto-char (c-langelem-pos langelem))
1204 (if (eq (char-after) ?{)
1205 (c-safe (c-forward-sexp -1)))
1206 (looking-at "\\<do\\>[^_]")))
1207 '(before)
1208 '(before after)))))
1209
1210 (defun c-snug-1line-defun-close (syntax pos)
1211 "Determine the brace hanginess for an AWK defun-close.
1212 If the action/function being closed is a one-liner, keep it so. Otherwise put
1213 the closing brace on its own line."
1214 (save-excursion
1215 (goto-char pos)
1216 (if (> (c-point 'bol)
1217 (progn (up-list -1) (point)))
1218 '(before after)
1219 '(after))))
1220
1221 (defun c-gnu-impose-minimum ()
1222 "Imposes a minimum indentation for lines inside code blocks.
1223 The variable `c-label-minimum-indentation' specifies the minimum
1224 indentation amount."
1225
1226 (when (and (not
1227 ;; Don't adjust macro or comment-only lines.
1228 (or (assq 'cpp-macro c-syntactic-context)
1229 (assq 'comment-intro c-syntactic-context)))
1230 (c-intersect-lists c-inside-block-syms c-syntactic-context)
1231 (save-excursion
1232 (back-to-indentation)
1233 (< (current-column) c-label-minimum-indentation)))
1234 (c-shift-line-indentation (- c-label-minimum-indentation
1235 (current-indentation)))))
1236
1237 \f
1238 ;; Useful for c-hanging-semi&comma-criteria
1239
1240 (defun c-semi&comma-inside-parenlist ()
1241 "Controls newline insertion after semicolons in parenthesis lists.
1242 If a comma was inserted, no determination is made. If a semicolon was
1243 inserted inside a parenthesis list, no newline is added otherwise a
1244 newline is added. In either case, checking is stopped. This supports
1245 exactly the old newline insertion behavior."
1246 ;; newline only after semicolon, but only if that semicolon is not
1247 ;; inside a parenthesis list (e.g. a for loop statement)
1248 (if (not (eq last-command-event ?\;))
1249 nil ; continue checking
1250 (if (condition-case nil
1251 (save-excursion
1252 (up-list -1)
1253 (not (eq (char-after) ?\()))
1254 (error t))
1255 t
1256 'stop)))
1257
1258 ;; Suppresses newlines before non-blank lines
1259 (defun c-semi&comma-no-newlines-before-nonblanks ()
1260 "Controls newline insertion after semicolons.
1261 If a comma was inserted, no determination is made. If a semicolon was
1262 inserted, and the following line is not blank, no newline is inserted.
1263 Otherwise, no determination is made."
1264 (save-excursion
1265 (if (and (= last-command-event ?\;)
1266 ;;(/= (point-max)
1267 ;; (save-excursion (skip-syntax-forward " ") (point))
1268 (zerop (forward-line 1))
1269 (bolp) ; forward-line has funny behavior at eob.
1270 (not (looking-at "^[ \t]*$")))
1271 'stop
1272 nil)))
1273
1274 ;; Suppresses new lines after semicolons in one-liners methods
1275 (defun c-semi&comma-no-newlines-for-oneline-inliners ()
1276 "Controls newline insertion after semicolons for some one-line methods.
1277 If a comma was inserted, no determination is made. Newlines are
1278 suppressed in one-liners, if the line is an in-class inline function.
1279 For other semicolon contexts, no determination is made."
1280 (let ((syntax (c-guess-basic-syntax))
1281 (bol (save-excursion
1282 (if (c-safe (up-list -1) t)
1283 (c-point 'bol)
1284 -1))))
1285 (if (and (eq last-command-event ?\;)
1286 (eq (car (car syntax)) 'inclass)
1287 (eq (car (car (cdr syntax))) 'topmost-intro)
1288 (= (c-point 'bol) bol))
1289 'stop
1290 nil)))
1291
1292 \f
1293 (cc-provide 'cc-align)
1294
1295 ;; arch-tag: 4d71ed28-bf51-4509-a148-f39669669a2e
1296 ;;; cc-align.el ends here