From: Alan Mackenzie Date: Mon, 27 Aug 2018 20:37:49 +0000 (+0000) Subject: CC Mode: Fix syntactic context of BOD sometimes being 'topmost-intro-cont X-Git-Tag: emacs-27.0.90~4505 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=66bf12b6a1777d8dd09f8ddcefe96314555d0134;p=emacs.git CC Mode: Fix syntactic context of BOD sometimes being 'topmost-intro-cont This happened when the type of the previous function was a struct, etc., declaration. * lisp/progmodes/cc-mode (c-guess-basic-syntax CASE 5N): Check here (for 'topmost-intro-cont) that the first opening brace after BOD is the opening brace preceding the starting point. --- diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index d1eb3c3d06f..278ade0560c 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -12280,7 +12280,18 @@ comment at the start of cc-engine.el for more info." ;; The '}' is unbalanced. nil (c-end-of-decl-1) - (>= (point) indent-point)))))) + (>= (point) indent-point)))) + ;; Check that we only have one brace block here, i.e. that we + ;; don't have something like a function with a struct + ;; declaration as its type. + (save-excursion + (or (not (and state-cache (consp (car state-cache)))) + ;; The above probably can't happen. + (progn + (goto-char placeholder) + (and (c-syntactic-re-search-forward + "{" indent-point t) + (eq (1- (point)) (caar state-cache)))))))) (goto-char placeholder) (c-add-stmt-syntax 'topmost-intro-cont nil nil containing-sexp paren-state))