C++ Mode: Fix some indentation bugs. FIxes bug#19867
1. Fix closing paren aligning with trailing comment on line with matching open paren. 2. Fix indentation of first identifier inside a comma separated list aligning with the type rather than the subsequent identifiers. 3. Fix lambda expressions inside a brace list aligning like a single statement. * lisp/progmodes/cc-align.el (c-lineup-arglist): Take into account any preceding comments when lining up the arguments in the arglist. (c-lineup-arglist-intro-after-paren): Handle comments properly, and don't line up the closing parenthesis with a trailing comment on the first line. (c-lineup-item-after-paren-at-boi): Also allow a paren to count as being at BOI when it is preceded only by open parens on that line. (c-lineup-runin-statements, c-lineup-ObjC-method-call): Hanle comments better. * lisp/progmodes/cc-engine.el (c-forward-comments) Introduce an optional limit parameter. Use this limit in calls from cc-align.el and cc-mode.el. (c-just-after-func-arglist-p): Handle the presence of a protection keyword such as "public". (c-at-bracelist-p): Renamed from c-inside-bracelist-p, after dropping the accept-in-paren parameter, having removed its functionality. (c-looking-at-statement-block-1): New function, based on the old c-looking-at-statement-block. Enhanced to handle C++ lambda expressions, and to return the symbol `maybe' when the contents of a brace delimited block fail to determine whether it is a statement block. (c-looking-at-statement-block): Enhanced to examine the context of a brace delimited block when the contents are ambiguous. (c-looking-at-c++-lambda-expression): Check the character after point is a < before calling c-forward-<>-arglist. (c-add-stmt-syntax): Make the context more accurate by calling c-looking-at-statement-block. (c-guess-basic-syntax, CASE 5D.5): Replace the syntactic symbol topmost-intro-cont with the new symbol class-field-cont, additionally determining the position of the enclosing brace as an extra anchor point. (c-guess-basic-syntax, CASE 5V): New case for an identifier following a type inside class braces. (c-guess-basic-syntax, CASE 9): Use c-looking-at-statement-block to detect a brace list more accurately. * lisp/progmodes/cc-fonts.el (c-get-fontification-context): Rename the call to c-inside-bracelist-p to c-at-bracelist-p. * lisp/progmodes/cc-langs.el (c-protection-kwds): Add an entry for java-mode. (c-stmt-block-only-keywords-regexp): Prevent this regexp also matching a character preceding the keyword. * /lisp/progmodes/cc-mode.el (c-before-change-include-<>) (c-after-change-include-<>): Use the new limit argument to c-forward-comments. * lisp/progmodes/cc-styles.el (c-style-alist, "gnu" and "java" styles): Change the offset for arglist-close to c-lineup-arglist-close-under-paren. * lisp/progmodes/cc-vars.el (c-offsets-alist): Introduce the new syntactic symbol class-field-cont, giving it default offset +. * doc/misc/cc-mode.texi (Syntactic Symbols, Class Symbols): Document the new syntactic symbol class-field-cont.
This commit is contained in:
parent
27c41d026f
commit
555ec43a32
8 changed files with 302 additions and 94 deletions
|
@ -4316,6 +4316,9 @@ annotations. @ref{Java Symbols}.
|
|||
First line in a member initialization list. @ref{Class Symbols}.
|
||||
@item member-init-cont
|
||||
Subsequent member initialization list lines. @ref{Class Symbols}.
|
||||
@item class-field-cont
|
||||
Lines continuing the first line inside a class/struct etc. definition.
|
||||
@ref{Class Symbols}.
|
||||
@item inher-intro
|
||||
First line of a multiple inheritance list. @ref{Class Symbols}.
|
||||
@item inher-cont
|
||||
|
@ -4669,6 +4672,25 @@ elements:
|
|||
The @code{friend} and @code{inline-open} syntactic symbols are
|
||||
modifiers that do not have anchor positions.
|
||||
|
||||
@ssindex class-field-cont
|
||||
In the following example, line 1 gets the syntax @code{topmost-intro},
|
||||
and line 2 @code{((inclass 1) (topmost-intro 1))} as expected. Lines
|
||||
3, 4, and 5 are given the syntax @code{(class-field-cont 18 12)}
|
||||
rather than @code{topmost-intro-cont}. This makes it easier to indent
|
||||
several comma separated fields with respect to their defining type,
|
||||
when @code{topmost-intro-cont} would tend to leave elements directly
|
||||
underneath their type. @xref{Function Symbols}. The anchor points are
|
||||
the positions of the type and the enclosing class's brace.
|
||||
|
||||
@example
|
||||
1. struct foo @{
|
||||
2. long
|
||||
3. a,
|
||||
4. b,
|
||||
5. c;
|
||||
6. @};
|
||||
@end example
|
||||
|
||||
@ssindex template-args-cont
|
||||
Template definitions introduce yet another syntactic symbol:
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ Works with: topmost-intro-cont."
|
|||
;; in-expression constructs. This can both save the work that we
|
||||
;; have to do below, and it also detect the brace list constructs
|
||||
;; that `c-looking-at-inexpr-block' currently misses (they are
|
||||
;; recognized by `c-inside-bracelist-p' instead).
|
||||
;; recognized by `c-at-bracelist-p' instead).
|
||||
(assq 'inexpr-class c-syntactic-context)
|
||||
(assq 'inexpr-statement c-syntactic-context)
|
||||
(assq 'inlambda c-syntactic-context)
|
||||
|
@ -188,7 +188,12 @@ indent such cases this way.
|
|||
|
||||
Works with: arglist-cont-nonempty, arglist-close."
|
||||
(save-excursion
|
||||
(let ((indent-pos (point)))
|
||||
(let ((indent-pos (point))
|
||||
(ws-length (save-excursion
|
||||
(back-to-indentation)
|
||||
(let ((ind-col (current-column)))
|
||||
(c-forward-comments (c-point 'eol))
|
||||
(- (current-column) ind-col)))))
|
||||
|
||||
(if (c-block-in-arglist-dwim (c-langelem-2nd-pos c-syntactic-element))
|
||||
c-basic-offset ; DWIM case.
|
||||
|
@ -205,8 +210,10 @@ Works with: arglist-cont-nonempty, arglist-close."
|
|||
(c-forward-syntactic-ws)
|
||||
(when (< (point) indent-pos)
|
||||
(goto-char arglist-content-start)
|
||||
(skip-chars-forward " \t"))
|
||||
(vector (current-column)))))))
|
||||
(c-forward-comments (c-point 'eol))
|
||||
(if (eolp)
|
||||
(goto-char arglist-content-start)))
|
||||
(vector (- (current-column) ws-length)))))))
|
||||
|
||||
(defun c-lineup-argcont-1 (elem)
|
||||
;; Move to the start of the current arg and return non-nil, otherwise
|
||||
|
@ -307,19 +314,27 @@ or brace block.
|
|||
Works with: defun-block-intro, brace-list-intro, enum-intro
|
||||
statement-block-intro, statement-case-intro, arglist-intro."
|
||||
(save-excursion
|
||||
(let ((ws-length (save-excursion
|
||||
(back-to-indentation)
|
||||
(let ((ind-col (current-column)))
|
||||
(c-forward-comments (c-point 'eol))
|
||||
(- (current-column) ind-col)))))
|
||||
(beginning-of-line)
|
||||
(backward-up-list 1)
|
||||
(forward-char)
|
||||
(skip-chars-forward " \t" (c-point 'eol))
|
||||
(if (eolp) (skip-chars-backward " \t"))
|
||||
(vector (current-column))))
|
||||
(let ((after-paren-pos (point)))
|
||||
(c-forward-comments (c-point 'eol))
|
||||
(if (eolp)
|
||||
(goto-char after-paren-pos)))
|
||||
(vector (- (current-column) ws-length)))))
|
||||
|
||||
(defun c-lineup-item-after-paren-at-boi (_langelem)
|
||||
"Line up a *-cont line to just after the surrounding open paren at boi.
|
||||
\"paren\" here can also mean \"brace\", etc. We line up under the first
|
||||
non-whitespace text after the paren. If there is no such paren, or no
|
||||
such text, return nil, allowing another function to handle the
|
||||
construct.
|
||||
"Line up to just after the surrounding open paren at boi.
|
||||
This also works when there are only open parens between the surrounding
|
||||
paren and boi. \"paren\" here can also mean \"brace\", etc. We line up
|
||||
under the first non-whitespace text after the paren. If there is no
|
||||
such paren, or no such text, return nil, allowing another function to
|
||||
handle the construct.
|
||||
|
||||
Works with: brace-list-intro, enum-intro, constraint-cont."
|
||||
(save-excursion
|
||||
|
@ -331,8 +346,10 @@ Works with: brace-list-intro, enum-intro, constraint-cont."
|
|||
t)
|
||||
;; constraint-cont.
|
||||
(c-go-up-list-backward nil (c-langelem-pos c-syntactic-element)))
|
||||
(eq (point) (c-point 'boi))
|
||||
(looking-at "\\s(")
|
||||
(save-excursion
|
||||
(skip-syntax-backward " \t([{" (c-point 'boi))
|
||||
(eq (point) (c-point 'boi)))
|
||||
(progn (forward-char)
|
||||
(c-forward-syntactic-ws (c-point 'eol))
|
||||
(unless (eolp)
|
||||
|
@ -487,11 +504,12 @@ Works with: inher-cont, member-init-cont."
|
|||
(c-backward-syntactic-ws))
|
||||
|
||||
(c-syntactic-re-search-forward ":" eol 'move)
|
||||
(if (looking-at c-syntactic-eol)
|
||||
(c-forward-syntactic-ws here)
|
||||
(if (eq char-after-ip ?,)
|
||||
(backward-char)
|
||||
(skip-chars-forward " \t" eol)))
|
||||
(cond
|
||||
((looking-at c-syntactic-eol)
|
||||
(c-forward-syntactic-ws here))
|
||||
((eq char-after-ip ?,)
|
||||
(backward-char))
|
||||
(t (c-forward-comments eol)))
|
||||
(if (< (point) here)
|
||||
(vector (current-column)))
|
||||
)))
|
||||
|
@ -771,7 +789,7 @@ Works with: The `statement' syntactic symbol."
|
|||
(if (c-langelem-pos langelem)
|
||||
(goto-char (c-langelem-pos langelem)))
|
||||
(forward-char 1)
|
||||
(skip-chars-forward " \t")
|
||||
(c-forward-comments (c-point 'eol))
|
||||
(unless (eolp)
|
||||
(vector (current-column))))))
|
||||
|
||||
|
@ -1001,11 +1019,10 @@ Works with: objc-method-call-cont."
|
|||
(target-col (progn
|
||||
(forward-char)
|
||||
(c-forward-sexp)
|
||||
(skip-chars-forward " \t")
|
||||
(c-forward-comments (c-point 'eol))
|
||||
(if (eolp)
|
||||
(+ open-bracket-col c-basic-offset)
|
||||
(current-column))))
|
||||
)
|
||||
(current-column)))))
|
||||
(- target-col open-bracket-col extra))))
|
||||
|
||||
(defun c-lineup-ObjC-method-call-colons (langelem)
|
||||
|
|
|
@ -1651,26 +1651,30 @@ This function does not do any hidden buffer changes."
|
|||
|
||||
t))))
|
||||
|
||||
(defsubst c-forward-comments ()
|
||||
(defsubst c-forward-comments (&optional lim)
|
||||
"Move forward past all following whitespace and comments.
|
||||
Line continuations, i.e. a backslashes followed by line breaks, are
|
||||
treated as whitespace.
|
||||
Line continuations, i.e. backslashes followed by line breaks, are
|
||||
treated as whitespace. LIM, if non-nil, is a forward search limit.
|
||||
If LIM is inside a comment, point may be left at LIM.
|
||||
|
||||
Note that this function might do hidden buffer changes. See the
|
||||
comment at the start of cc-engine.el for more info."
|
||||
|
||||
(while (or
|
||||
;; If forward-comment in at least XEmacs 21 is given a large
|
||||
;; positive value, it'll loop all the way through if it hits
|
||||
;; eob.
|
||||
(and (forward-comment 5)
|
||||
;; Some emacsen (e.g. XEmacs 21) return t when moving
|
||||
;; forwards at eob.
|
||||
(not (eobp)))
|
||||
(save-restriction
|
||||
(if lim
|
||||
(narrow-to-region (point-min) lim))
|
||||
(while (or
|
||||
;; If forward-comment in at least XEmacs 21 is given a large
|
||||
;; positive value, it'll loop all the way through if it hits
|
||||
;; eob.
|
||||
(and (forward-comment 5)
|
||||
;; Some emacsen (e.g. XEmacs 21) return t when moving
|
||||
;; forwards at eob.
|
||||
(not (eobp)))
|
||||
|
||||
(when (looking-at "\\\\[\n\r]")
|
||||
(forward-char 2)
|
||||
t))))
|
||||
(when (looking-at "\\\\[\n\r]")
|
||||
(forward-char 2)
|
||||
t)))))
|
||||
|
||||
(defmacro c-forward-comment-minus-1 ()
|
||||
"Call (forward-comment -1), taking care of escaped newlines.
|
||||
|
@ -12139,6 +12143,9 @@ comment at the start of cc-engine.el for more info."
|
|||
(save-restriction
|
||||
(widen)
|
||||
(c-beginning-of-macro lim)))))
|
||||
(progn (if (looking-at c-protection-key)
|
||||
(c-forward-token-2))
|
||||
t)
|
||||
(setq id-start
|
||||
(car-safe (c-forward-decl-or-cast-1 (c-point 'bosws) 'top nil)))
|
||||
(numberp id-start)
|
||||
|
@ -13380,18 +13387,18 @@ comment at the start of cc-engine.el for more info."
|
|||
(setq ptr (cdr ptr)))
|
||||
(nreverse new)))
|
||||
|
||||
(defun c-inside-bracelist-p (containing-sexp paren-state accept-in-paren)
|
||||
;; Return the buffer position of the beginning of the brace list statement
|
||||
;; if CONTAINING-SEXP is inside a brace list, otherwise return nil.
|
||||
(defun c-at-bracelist-p (containing-sexp paren-state)
|
||||
;; Try to return the buffer position of the beginning of the brace list
|
||||
;; statement whose brace block begins at CONTAINING-SEXP, otherwise return
|
||||
;; nil. If the code cannot determine whether we're at a brace block, return
|
||||
;; nil.
|
||||
;;
|
||||
;; CONTAINING-SEXP must be at an open brace, and is the buffer pos of the
|
||||
;; innermost containing brace. NO IT ISN'T!!! [This function is badly
|
||||
;; CONTAINING-SEXP must be at an open brace. [This function is badly
|
||||
;; designed, and probably needs reformulating without its first argument,
|
||||
;; and the critical position being at point.]
|
||||
;;
|
||||
;; PAREN-STATE is the remainder of the state of enclosing braces.
|
||||
;; ACCEPT-IN-PAREN is non-nil iff we will accept as a brace list a brace
|
||||
;; directly enclosed in a parenthesis.
|
||||
;; PAREN-STATE is the state of enclosing braces at CONTAINING-SEXP (see
|
||||
;; `c-parse-state').
|
||||
;;
|
||||
;; The "brace list" here is recognized solely by its context, not by
|
||||
;; its contents.
|
||||
|
@ -13429,7 +13436,7 @@ comment at the start of cc-engine.el for more info."
|
|||
(setq current-brace next-containing))))
|
||||
(cond
|
||||
((consp bufpos)
|
||||
(and (or accept-in-paren (not (eq (cdr bufpos) 'in-paren)))
|
||||
(and (not (eq (cdr bufpos) 'in-paren))
|
||||
(car bufpos)))
|
||||
(non-brace-pos
|
||||
;; We've encountered a ( or a [. Remove the "middle part" of
|
||||
|
@ -13514,11 +13521,17 @@ comment at the start of cc-engine.el for more info."
|
|||
(cons (list beg) type)))))
|
||||
(error nil))))
|
||||
|
||||
(defun c-looking-at-statement-block ()
|
||||
;; Point is at an opening brace. If this is a statement block (i.e. the
|
||||
;; elements in the block are terminated by semicolons, or the block is
|
||||
;; empty, or the block contains a characteristic keyword, or there is a
|
||||
;; nested statement block) return non-nil. Otherwise, return nil.
|
||||
(defun c-looking-at-statement-block-1 ()
|
||||
;; Point is at an opening brace. Try to determine whether it starts a
|
||||
;; statement block. For example, if there are elements in the block
|
||||
;; terminated by semicolons, or the block contains a characteristic keyword,
|
||||
;; or a nested brace block is a statement block, return t. If we determine
|
||||
;; the block cannot be a statement block, return nil. Otherwise return the
|
||||
;; symbol `maybe'.
|
||||
;;
|
||||
;; The calculations are based solely on the contents of the block, not on
|
||||
;; its context. There is special handling for C++ lambda expressions, which
|
||||
;; sometimes occur in brace blocks.
|
||||
(let ((here (point)))
|
||||
(prog1
|
||||
(if (c-go-list-forward)
|
||||
|
@ -13528,26 +13541,142 @@ comment at the start of cc-engine.el for more info."
|
|||
(cond
|
||||
((eq (char-before) ?\;))
|
||||
((progn (c-forward-syntactic-ws)
|
||||
(eq (point) (1- there))))
|
||||
(eq (point) (1- there)))
|
||||
'maybe)
|
||||
((c-syntactic-re-search-forward
|
||||
c-stmt-block-only-keywords-regexp there t))
|
||||
((c-syntactic-re-search-forward "{" there t t)
|
||||
(backward-char)
|
||||
(c-looking-at-statement-block))
|
||||
(t nil)))
|
||||
c-stmt-block-only-keywords-regexp there t t)
|
||||
t)
|
||||
((c-major-mode-is 'c++-mode)
|
||||
(catch 'statement
|
||||
(while
|
||||
(and (c-syntactic-re-search-forward "[[{]" there 'bound t)
|
||||
(progn
|
||||
(backward-char)
|
||||
(cond
|
||||
((eq (char-after) ?\[)
|
||||
(let ((bb (c-looking-at-c++-lambda-expression)))
|
||||
(if bb
|
||||
(c-go-list-forward bb there)
|
||||
(forward-char)
|
||||
t)))
|
||||
((eq (c-looking-at-statement-block-1) t)
|
||||
(throw 'statement t))
|
||||
(t (c-go-list-forward)
|
||||
t)))))
|
||||
'maybe))
|
||||
(t (catch 'statement2
|
||||
(while
|
||||
(and (c-syntactic-re-search-forward "{" there t t)
|
||||
(progn
|
||||
(backward-char)
|
||||
(if (eq (c-looking-at-statement-block-1) t)
|
||||
(throw 'statement2 t)
|
||||
(c-go-list-forward)))))
|
||||
'maybe))))
|
||||
(forward-char)
|
||||
(cond
|
||||
((c-syntactic-re-search-forward ";" nil t t))
|
||||
((progn (c-forward-syntactic-ws)
|
||||
(eobp)))
|
||||
(eobp))
|
||||
'maybe)
|
||||
((c-syntactic-re-search-forward c-stmt-block-only-keywords-regexp
|
||||
nil t t))
|
||||
((c-syntactic-re-search-forward "{" nil t t)
|
||||
(backward-char)
|
||||
(c-looking-at-statement-block))
|
||||
(t nil)))
|
||||
nil t t)
|
||||
t)
|
||||
((c-major-mode-is 'c++-mode)
|
||||
(catch 'statement1
|
||||
(while
|
||||
(and (c-syntactic-re-search-forward "[[}]" nil 'bound t)
|
||||
(progn
|
||||
(backward-char)
|
||||
(cond
|
||||
((eq (char-after) ?\[)
|
||||
(let ((bb (c-looking-at-c++-lambda-expression)))
|
||||
(cond ((and bb (c-go-list-forward bb)))
|
||||
(bb (throw 'statement1 'maybe))
|
||||
(t (forward-char) t))))
|
||||
((eq (c-looking-at-statement-block-1) t)
|
||||
(throw 'statement1 t))
|
||||
((c-go-list-forward))
|
||||
(t (throw 'statement1 'maybe))))))
|
||||
nil))
|
||||
(t (catch 'statement3
|
||||
(while
|
||||
(and (c-syntactic-re-search-forward "{" nil t t)
|
||||
(progn
|
||||
(backward-char)
|
||||
(if (eq (c-looking-at-statement-block-1) t)
|
||||
(throw 'statement3 t)
|
||||
(c-go-list-forward)))))
|
||||
'maybe))))
|
||||
(goto-char here))))
|
||||
|
||||
(defun c-looking-at-statement-block ()
|
||||
;; Point is at an opening brace. If this brace starts a statement block,
|
||||
;; return t. Otherwise return nil.
|
||||
;;
|
||||
;; This function first examines the contents of the block beginning at the
|
||||
;; brace, and if this fails to give a definite result, it examines the
|
||||
;; context of the block.
|
||||
(save-excursion
|
||||
(let ((res (c-looking-at-statement-block-1))
|
||||
prev-tok)
|
||||
(cond
|
||||
((memq res '(nil t))
|
||||
res)
|
||||
((zerop (c-backward-token-2))
|
||||
(setq prev-tok (point))
|
||||
(cond
|
||||
((looking-at "={]")
|
||||
nil)
|
||||
((progn
|
||||
(if (looking-at c-type-decl-suffix-ws-ids-key) ; e.g. C++'s "final".
|
||||
(c-backward-token-2))
|
||||
(if (and c-recognize-<>-arglists ; Skip back over template parens.
|
||||
(eq (char-after) ?>)
|
||||
(c-go-up-list-backward))
|
||||
(c-backward-token-2))
|
||||
(and c-opt-block-decls-with-vars-key ; E.g. "enum", "class".
|
||||
(or (looking-at c-opt-block-decls-with-vars-key)
|
||||
(save-excursion
|
||||
(and (c-on-identifier)
|
||||
(zerop (c-backward-token-2))
|
||||
(looking-at c-opt-block-decls-with-vars-key)))))))
|
||||
((eq (char-after) ?})) ; Statement block following another one.
|
||||
((eq (char-after) ?:) ; Case label or ordinary label.
|
||||
(save-excursion
|
||||
(forward-char)
|
||||
(eq (c-beginning-of-statement-1 nil nil t) 'label)))
|
||||
((save-excursion ; Between function arglist and block.
|
||||
(c-just-after-func-arglist-p))
|
||||
t)
|
||||
((save-excursion ; Just after C++ class member initializations.
|
||||
(and (eq (char-after) ?\))
|
||||
(progn (forward-char)
|
||||
(c-back-over-member-initializer-braces)))))
|
||||
((and (eq (char-after) ?\))
|
||||
(c-go-up-list-backward))
|
||||
(prog1
|
||||
(cond
|
||||
((save-excursion
|
||||
(and (zerop (c-backward-token-2)) ; Parens of an `if', etc.?
|
||||
(looking-at c-block-stmt-2-key))))
|
||||
((save-excursion ; Between function arglist and block.
|
||||
(c-just-after-func-arglist-p))
|
||||
t)
|
||||
((progn ; A function call or declaration.
|
||||
(c-backward-syntactic-ws)
|
||||
(c-on-identifier))
|
||||
t))
|
||||
(goto-char prev-tok)))
|
||||
((eq (char-after) ?\;)) ; Bare statement block.
|
||||
((looking-at c-block-stmt-1-key)) ; E.g. "do", "else".
|
||||
((eq (char-after) ?\()
|
||||
(and (zerop (c-backward-token-2))
|
||||
(or (looking-at c-operator-re) ; Statement expression.
|
||||
(looking-at c-block-stmt-2-key)))) ; E.g. "if", "catch".
|
||||
(t nil)))
|
||||
(t nil)))))
|
||||
|
||||
(defun c-forward-concept-fragment (&optional limit stop-at-end)
|
||||
;; Are we currently at the "concept" keyword in a concept construct? If so
|
||||
;; we return the position of the first constraint expression following the
|
||||
|
@ -13869,7 +13998,8 @@ comment at the start of cc-engine.el for more info."
|
|||
(when (and (c-looking-at-c++-lambda-capture-list)
|
||||
(c-go-list-forward nil lim))
|
||||
(c-forward-syntactic-ws lim)
|
||||
(when (c-forward-<>-arglist t)
|
||||
(when (and (eq (char-after) ?<)
|
||||
(c-forward-<>-arglist t))
|
||||
(c-forward-syntactic-ws lim)
|
||||
(when (looking-at c-requires-clause-key)
|
||||
(c-forward-c++-requires-clause lim nil)))
|
||||
|
@ -14240,7 +14370,9 @@ comment at the start of cc-engine.el for more info."
|
|||
((or (not (eq step-type 'same))
|
||||
(eq paren-pos (point)))
|
||||
(if (and (eq paren-pos (point))
|
||||
(c-inside-bracelist-p paren-pos paren-state nil))
|
||||
(or
|
||||
(c-at-bracelist-p paren-pos paren-state)
|
||||
(not (c-looking-at-statement-block))))
|
||||
(c-add-syntax 'brace-list-intro nil anchor-point-2)
|
||||
(c-add-syntax 'statement-block-intro nil)))
|
||||
((save-excursion
|
||||
|
@ -14259,7 +14391,7 @@ comment at the start of cc-engine.el for more info."
|
|||
(max (c-point 'boi paren-pos) (point))))
|
||||
((c-at-enum-brace paren-pos)
|
||||
(c-add-syntax 'enum-intro nil anchor-point-2))
|
||||
((c-inside-bracelist-p paren-pos paren-state nil)
|
||||
((c-at-bracelist-p paren-pos paren-state)
|
||||
(if (save-excursion
|
||||
(goto-char paren-pos)
|
||||
(c-looking-at-statement-block))
|
||||
|
@ -14269,9 +14401,11 @@ comment at the start of cc-engine.el for more info."
|
|||
(goto-char paren-pos)
|
||||
(setq bspec (c-looking-at-or-maybe-in-bracelist
|
||||
containing-sexp containing-sexp))
|
||||
(and (consp bspec)
|
||||
(eq (cdr bspec) 'in-paren)))
|
||||
(c-add-syntax 'brace-list-intro (car bspec)
|
||||
(or (and (eq bspec t)
|
||||
(not (c-looking-at-statement-block)))
|
||||
(and (consp bspec)
|
||||
(eq (cdr bspec) 'in-paren))))
|
||||
(c-add-syntax 'brace-list-intro (car-safe bspec)
|
||||
anchor-point-2))
|
||||
(t (c-add-syntax 'defun-block-intro nil))))
|
||||
|
||||
|
@ -14364,9 +14498,8 @@ comment at the start of cc-engine.el for more info."
|
|||
|
||||
;; CASE B.2: brace-list-open
|
||||
((or (consp special-brace-list)
|
||||
(c-inside-bracelist-p (point)
|
||||
(cons containing-sexp paren-state)
|
||||
nil))
|
||||
(c-at-bracelist-p (point)
|
||||
(cons containing-sexp paren-state)))
|
||||
;; The most semantically accurate symbol here is
|
||||
;; brace-list-open, but we normally report it simply as a
|
||||
;; statement-cont. The reason is that one normally adjusts
|
||||
|
@ -15287,15 +15420,33 @@ comment at the start of cc-engine.el for more info."
|
|||
(< (point) placeholder)))
|
||||
(c-add-stmt-syntax
|
||||
(cond
|
||||
((eq (point) placeholder) 'statement) ; unrecognized construct
|
||||
((eq (point) placeholder)
|
||||
(setq placeholder nil)
|
||||
'statement) ; unrecognized construct
|
||||
;; A preceding comma at the top level means that a
|
||||
;; new variable declaration starts here. Use
|
||||
;; topmost-intro-cont for it, for consistency with
|
||||
;; the first variable declaration. C.f. case 5N.
|
||||
((eq char-before-ip ?,) 'topmost-intro-cont)
|
||||
(t 'statement-cont))
|
||||
nil nil containing-sexp paren-state))
|
||||
))
|
||||
((eq char-before-ip ?,)
|
||||
(if (save-excursion
|
||||
(and
|
||||
containing-sexp
|
||||
(progn (goto-char containing-sexp) t)
|
||||
(eq (char-after) ?{)
|
||||
(setq placeholder (point))
|
||||
(eq (c-beginning-of-statement-1
|
||||
(or (c-most-enclosing-brace paren-state)
|
||||
(c-determine-limit 500)))
|
||||
'same)
|
||||
(looking-at c-class-key)))
|
||||
'class-field-cont
|
||||
(setq placeholder nil)
|
||||
'topmost-intro-cont))
|
||||
(t
|
||||
(setq placeholder nil)
|
||||
'statement-cont))
|
||||
(and placeholder (list placeholder))
|
||||
nil containing-sexp paren-state))))
|
||||
|
||||
;; CASE 5G: we are looking at the brace which closes the
|
||||
;; enclosing nested class decl
|
||||
|
@ -15507,6 +15658,23 @@ comment at the start of cc-engine.el for more info."
|
|||
(goto-char placeholder)))
|
||||
(c-add-syntax 'annotation-top-cont (c-point 'boi tmp-pos2)))
|
||||
|
||||
;; CASE 5V: Identifier following type inside class braces.
|
||||
((save-excursion
|
||||
(and
|
||||
containing-sexp
|
||||
(eq (c-beginning-of-statement-1 containing-sexp nil nil t) 'same)
|
||||
(setq placeholder (point))
|
||||
(progn (goto-char containing-sexp) t)
|
||||
(eq (c-beginning-of-statement-1
|
||||
(or (c-most-enclosing-brace paren-state)
|
||||
(c-determine-limit 500)))
|
||||
'same)
|
||||
(looking-at c-class-key)
|
||||
(progn (goto-char placeholder) t)
|
||||
(eq (car (c-forward-decl-or-cast-1 (1+ containing-sexp) 'top nil))
|
||||
(c-point 'boi indent-point))))
|
||||
(c-add-syntax 'class-field-cont placeholder containing-sexp))
|
||||
|
||||
;; CASE 5M: we are at a topmost continuation line
|
||||
(t
|
||||
(c-beginning-of-statement-1
|
||||
|
@ -15617,9 +15785,8 @@ comment at the start of cc-engine.el for more info."
|
|||
(progn
|
||||
(setq placeholder
|
||||
(or (setq enum-pos (c-at-enum-brace))
|
||||
(c-inside-bracelist-p (point)
|
||||
paren-state
|
||||
nil)))
|
||||
(c-at-bracelist-p (point)
|
||||
paren-state)))
|
||||
(if placeholder
|
||||
(setq tmpsymbol
|
||||
`(,(if enum-pos 'enum-open 'brace-list-open)
|
||||
|
@ -15747,7 +15914,10 @@ comment at the start of cc-engine.el for more info."
|
|||
(goto-char containing-sexp)
|
||||
(c-looking-at-special-brace-list)))
|
||||
(setq enum-pos (c-at-enum-brace containing-sexp))
|
||||
(c-inside-bracelist-p containing-sexp paren-state t))))
|
||||
(c-at-bracelist-p containing-sexp paren-state)
|
||||
(save-excursion
|
||||
(goto-char containing-sexp)
|
||||
(not (c-looking-at-statement-block))))))
|
||||
(cond
|
||||
;; CASE 9A: In the middle of a special brace list opener.
|
||||
((and (consp special-brace-list)
|
||||
|
|
|
@ -1273,9 +1273,8 @@ casts and declarations are fontified. Used on level 2 and higher."
|
|||
;; We're inside a brace list/enum list.
|
||||
((and (eq (char-before match-pos) ?{)
|
||||
(or (c-at-enum-brace (1- match-pos))
|
||||
(c-inside-bracelist-p (1- match-pos)
|
||||
(cdr (c-parse-state))
|
||||
nil)))
|
||||
(c-at-bracelist-p (1- match-pos)
|
||||
(cdr (c-parse-state)))))
|
||||
(c-put-char-property (1- match-pos) 'c-type
|
||||
'c-not-decl)
|
||||
(cons 'not-decl nil))
|
||||
|
|
|
@ -2907,12 +2907,12 @@ one of `c-type-list-kwds', `c-ref-list-kwds',
|
|||
(c-lang-defconst c-protection-kwds
|
||||
"Access protection label keywords in classes."
|
||||
t nil
|
||||
c++ '("private" "protected" "public")
|
||||
(c++ java) '("private" "protected" "public")
|
||||
objc '("@private" "@protected" "@package" "@public"
|
||||
"@required" "@optional"))
|
||||
|
||||
(c-lang-defconst c-protection-key
|
||||
;; A regexp match an element of `c-protection-kwds' cleanly.
|
||||
;; A regexp matching an element of `c-protection-kwds' cleanly.
|
||||
t (c-make-keywords-re t (c-lang-const c-protection-kwds)))
|
||||
(c-lang-defvar c-protection-key (c-lang-const c-protection-key))
|
||||
|
||||
|
@ -3547,7 +3547,7 @@ Note that Java specific rules are currently applied to tell this from
|
|||
(c-lang-defconst c-stmt-block-only-keywords-regexp
|
||||
;; A regexp matching a keyword in `c-stmt-block-only-keywords'. Such a
|
||||
;; match can start and end only at token boundaries.
|
||||
t (concat "\\(^\\|\\=\\|[^" (c-lang-const c-symbol-chars) "]\\)"
|
||||
t (concat "\\(\\<\\|\\=\\)"
|
||||
(c-make-keywords-re t (c-lang-const c-stmt-block-only-keywords))))
|
||||
(c-lang-defvar c-stmt-block-only-keywords-regexp
|
||||
(c-lang-const c-stmt-block-only-keywords-regexp))
|
||||
|
|
|
@ -2047,9 +2047,7 @@ This function is used solely as a member of
|
|||
(while (and (< (point) search-end)
|
||||
(search-forward-regexp c-cpp-include-key search-end 'bound)
|
||||
(setq hash-pos (match-beginning 0)))
|
||||
(save-restriction
|
||||
(narrow-to-region (point-min) (c-point 'eoll))
|
||||
(c-forward-comments))
|
||||
(c-forward-comments (c-point 'eoll))
|
||||
(when (and (< (point) search-end)
|
||||
(looking-at "\\s(")
|
||||
(looking-at "\\(<\\)[^>\n\r]*\\(>\\)?")
|
||||
|
@ -2081,9 +2079,7 @@ This function is used solely as a member of
|
|||
(while (and (< (point) search-end)
|
||||
(search-forward-regexp c-cpp-include-key search-end 'bound)
|
||||
(setq hash-pos (match-beginning 0)))
|
||||
(save-restriction
|
||||
(narrow-to-region (point-min) (c-point 'eoll))
|
||||
(c-forward-comments))
|
||||
(c-forward-comments (c-point 'eoll))
|
||||
(when (and (< (point) search-end)
|
||||
(looking-at "\\(<\\)[^>\n\r]*\\(>\\)")
|
||||
(not (cdr (c-semi-pp-to-literal (match-beginning 0)))))
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
(statement-case-open . +)
|
||||
(statement-cont . +)
|
||||
(arglist-intro . c-lineup-arglist-intro-after-paren)
|
||||
(arglist-close . c-lineup-arglist)
|
||||
(arglist-close . c-lineup-arglist-close-under-paren)
|
||||
(inline-open . 0)
|
||||
(brace-list-open . +)
|
||||
(brace-list-intro . (first
|
||||
|
@ -230,7 +230,7 @@
|
|||
(statement-case-open . +)
|
||||
(statement-cont . +)
|
||||
(arglist-intro . c-lineup-arglist-intro-after-paren)
|
||||
(arglist-close . c-lineup-arglist)
|
||||
(arglist-close . c-lineup-arglist-close-under-paren)
|
||||
(brace-list-intro . (first
|
||||
c-lineup-2nd-brace-entry-in-arglist
|
||||
c-lineup-class-decl-init-+ +))
|
||||
|
|
|
@ -292,6 +292,7 @@ Here is the current list of valid syntactic element symbols:
|
|||
defun-block-intro -- The first line in a top-level defun.
|
||||
class-open -- Brace that opens a class definition.
|
||||
class-close -- Brace that closes a class definition.
|
||||
class-field-cont -- Continuation of first line inside a class.
|
||||
inline-open -- Brace that opens an in-class inline method.
|
||||
inline-close -- Brace that closes an in-class inline method.
|
||||
func-decl-cont -- The region between a function definition's
|
||||
|
@ -1301,6 +1302,9 @@ can always override the use of `c-default-style' by making calls to
|
|||
;; Anchor pos: Boi at the func decl arglist open.
|
||||
(member-init-cont . c-lineup-multi-inher)
|
||||
;; Anchor pos: Beg of the first member init.
|
||||
(class-field-cont . +)
|
||||
;; Anchor pos: BOI of the line containing the class keyword.
|
||||
;; 2nd pos: At the open brace.
|
||||
(inher-intro . +)
|
||||
;; Anchor pos: Boi at the class decl start.
|
||||
(inher-cont . c-lineup-multi-inher)
|
||||
|
|
Loading…
Add table
Reference in a new issue