From 0d48fc0afc0ec1016b678cd6ad63927727751eb8 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Thu, 19 Oct 1995 22:04:18 +0000 Subject: [PATCH] (calculate-c++-indent): Skip over paren-group when looking back to determine context of a top-level line. Don't treat a line starting with } as a continuation. --- lisp/progmodes/cplus-md.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/cplus-md.el b/lisp/progmodes/cplus-md.el index e02a8068d1d..14f85d2205a 100644 --- a/lisp/progmodes/cplus-md.el +++ b/lisp/progmodes/cplus-md.el @@ -563,6 +563,8 @@ Returns nil if line starts inside a string, t if in a comment." (backward-char 1)) (if (= (preceding-char) ?}) 0 + (if (= (preceding-char) ?\)) + (forward-list -1)) (beginning-of-line) ; continued arg decls or member inits (skip-chars-forward " \t") (if (= (following-char) ?:) @@ -608,7 +610,14 @@ Returns nil if line starts inside a string, t if in a comment." ;; Statement. Find previous non-comment character. (goto-char indent-point) (c++-backward-to-noncomment containing-sexp) - (if (not (memq (preceding-char) '(nil ?\, ?\; ?} ?: ?\{))) + (if (and (not (memq (preceding-char) '(0 ?\, ?\; ?\} ?\{))) + ;; But don't treat a line with a close-brace + ;; as a continuation. It is probably the + ;; end of an enum type declaration. + (save-excursion + (goto-char indent-point) + (skip-chars-forward " \t") + (not (= (following-char) ?})))) ;; This line is continuation of preceding line's statement; ;; indent c-continued-statement-offset more than the ;; previous line of the statement. -- 2.39.2