From 8007b73c143db55e1a40cb00bd9a9507bb154ad8 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Thu, 19 Apr 2007 17:35:16 +0000 Subject: [PATCH] (c-in-function-trailer-p): Fix this: when a function return type contains "struct", "union", etc. c-end-of-defun goes too far forward. --- lisp/progmodes/cc-cmds.el | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index 2bda3a174c..9ef4aaace7 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el @@ -1360,10 +1360,24 @@ No indentation or other \"electric\" behavior is performed." (and c-opt-block-decls-with-vars-key (save-excursion (c-syntactic-skip-backward "^;}" lim) - (and (eq (char-before) ?\}) - (eq (car (c-beginning-of-decl-1 lim)) 'previous) - (looking-at c-opt-block-decls-with-vars-key) - (point))))) + (let ((eo-block (point)) + bod) + (and (eq (char-before) ?\}) + (eq (car (c-beginning-of-decl-1 lim)) 'previous) + (setq bod (point)) + ;; Look for struct or union or ... If we find one, it might + ;; be the return type of a function, or the like. Exclude + ;; this case. + (c-syntactic-re-search-forward + (concat "[;=\(\[{]\\|\\(" + c-opt-block-decls-with-vars-key + "\\)") + eo-block t t t) + (match-beginning 1) ; Is there a "struct" etc., somewhere? + (not (eq (char-before) ?_)) + (c-syntactic-re-search-forward "[;=\(\[{]" eo-block t t t) + (eq (char-before) ?\{) + bod))))) (defun c-where-wrt-brace-construct () ;; Determine where we are with respect to functions (or other brace -- 2.39.2