Function: c-guess-continued-construct
c-guess-continued-construct is a byte-compiled function defined in
cc-engine.el.gz.
Signature
(c-guess-continued-construct INDENT-POINT CHAR-AFTER-IP BEG-OF-SAME-OR-CONTAINING-STMT CONTAINING-SEXP PAREN-STATE)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
(defun c-guess-continued-construct (indent-point
char-after-ip
beg-of-same-or-containing-stmt
containing-sexp
paren-state)
;; This function contains the decision tree reached through both
;; cases 18 and 10. It's a continued statement or top level
;; construct of some kind.
;;
;; This function might do hidden buffer changes.
(let (special-brace-list placeholder)
(goto-char indent-point)
(skip-chars-forward " \t")
(cond
;; (CASE A removed.)
;; CASE B: open braces for class or brace-lists
((setq special-brace-list
(or (and c-special-brace-lists
(c-looking-at-special-brace-list))
(eq char-after-ip ?{)))
(cond
;; CASE B.1: class-open
((save-excursion
(and (eq (char-after) ?{)
(setq placeholder (c-looking-at-decl-block t))
(setq beg-of-same-or-containing-stmt (point))))
(c-add-syntax 'class-open beg-of-same-or-containing-stmt
(c-point 'boi placeholder)))
;; CASE B.2: brace-list-open
((or (consp special-brace-list)
(c-inside-bracelist-p (point)
(cons containing-sexp paren-state)
nil))
;; 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
;; brace-list-open for brace lists as top-level constructs,
;; and brace lists inside statements is a completely different
;; context. C.f. case 5A.3.
(c-beginning-of-statement-1 containing-sexp)
(c-add-stmt-syntax (if c-auto-newline-analysis
;; Turn off the dwim above when we're
;; analyzing the nature of the brace
;; for the auto newline feature.
'brace-list-open
'statement-cont)
nil nil
containing-sexp paren-state))
;; CASE B.3: The body of a function declared inside a normal
;; block. Can occur e.g. in Pike and when using gcc
;; extensions, but watch out for macros followed by blocks.
;; C.f. cases E, 16F and 17G.
((and (not (c-at-statement-start-p))
(eq (c-beginning-of-statement-1 containing-sexp nil nil t)
'same)
(save-excursion
(let ((c-recognize-typeless-decls nil))
;; Turn off recognition of constructs that lacks a
;; type in this case, since that's more likely to be
;; a macro followed by a block.
(c-forward-decl-or-cast-1 (c-point 'bosws) nil nil))))
(c-add-stmt-syntax 'defun-open nil t
containing-sexp paren-state))
;; CASE B.5: We have a C++11 "return \n { ..... }" Note that we're
;; not at the "{", currently.
((progn (goto-char indent-point)
(backward-sexp)
(looking-at c-return-key))
(c-add-stmt-syntax 'statement-cont nil t
containing-sexp paren-state))
;; CASE B.4: Continued statement with block open. The most
;; accurate analysis is perhaps `statement-cont' together with
;; `block-open' but we play DWIM and use `substatement-open'
;; instead. The rationale is that this typically is a macro
;; followed by a block which makes it very similar to a
;; statement with a substatement block.
(t
(c-add-stmt-syntax 'substatement-open nil nil
containing-sexp paren-state))
))
;; CASE C: iostream insertion or extraction operator
((and (looking-at "\\(<<\\|>>\\)\\([^=]\\|$\\)")
(save-excursion
(goto-char beg-of-same-or-containing-stmt)
;; If there is no preceding streamop in the statement
;; then indent this line as a normal statement-cont.
(when (c-syntactic-re-search-forward
"\\(<<\\|>>\\)\\([^=]\\|$\\)" indent-point 'move t t)
(c-add-syntax 'stream-op (c-point 'boi))
t))))
;; CASE E: In the "K&R region" of a function declared inside a
;; normal block. C.f. case B.3.
((and (save-excursion
;; Check that the next token is a '{'. This works as
;; long as no language that allows nested function
;; definitions allows stuff like member init lists, K&R
;; declarations or throws clauses there.
;;
;; Note that we do a forward search for something ahead
;; of the indentation line here. That's not good since
;; the user might not have typed it yet. Unfortunately
;; it's exceedingly tricky to recognize a function
;; prototype in a code block without resorting to this.
(c-forward-syntactic-ws)
(eq (char-after) ?{))
(not (c-at-statement-start-p))
(eq (c-beginning-of-statement-1 containing-sexp nil nil t)
'same)
(save-excursion
(let ((c-recognize-typeless-decls nil))
;; Turn off recognition of constructs that lacks a
;; type in this case, since that's more likely to be
;; a macro followed by a block.
(c-forward-decl-or-cast-1 (c-point 'bosws) nil nil))))
(c-add-stmt-syntax 'func-decl-cont nil t
containing-sexp paren-state))
;;CASE F: continued statement and the only preceding items are
;;annotations.
((and (c-major-mode-is 'java-mode)
(setq placeholder (point))
(c-beginning-of-statement-1)
(progn
(while (and (c-forward-annotation)
(< (point) placeholder))
(c-forward-syntactic-ws))
t)
(prog1
(>= (point) placeholder)
(goto-char placeholder)))
(c-beginning-of-statement-1 containing-sexp)
(c-add-syntax 'annotation-var-cont (point)))
;; CASE G: a template list continuation?
;; Mostly a duplication of case 5D.3 to fix templates-19:
((and (c-major-mode-is 'c++-mode)
(save-excursion
(goto-char indent-point)
(setq placeholder (c-up-list-backward))
(and placeholder
(eq (char-after placeholder) ?<)
(/= (char-before placeholder) ?<)
(progn
(goto-char (1+ placeholder))
(or (not (looking-at c-<-op-cont-regexp))
(looking-at c-<-pseudo-digraph-cont-regexp))))))
(goto-char placeholder)
(c-beginning-of-statement-1 containing-sexp t)
(if (save-excursion
(c-backward-syntactic-ws containing-sexp)
(eq (char-before) ?<))
;; In a nested template arglist.
(progn
(goto-char placeholder)
(c-syntactic-skip-backward "^,;" containing-sexp t)
(c-forward-syntactic-ws))
(back-to-indentation))
;; FIXME: Should use c-add-stmt-syntax, but it's not yet
;; template aware.
(c-add-syntax 'template-args-cont (point) placeholder))
;; CASE D: continued statement.
(t
(c-beginning-of-statement-1 containing-sexp)
(c-add-stmt-syntax 'statement-cont nil nil
containing-sexp paren-state))
)))