X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/15279e74553902573d19d1219d733c8625373bae..cdf71ff2ef86e20d8892da4a938a93e1a0c5377b:/lisp/progmodes/cc-cmds.el diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index e142dcb06d..48fa7d99f5 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el @@ -18,7 +18,7 @@ ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) +;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, @@ -856,8 +856,8 @@ is inhibited." (narrow-to-region (point-min) (point)) (back-to-indentation) (looking-at (concat c-current-comment-prefix "[ \t]*$"))))) - (kill-region (progn (forward-line 0) (point)) - (progn (end-of-line) (point))) + (delete-region (progn (forward-line 0) (point)) + (progn (end-of-line) (point))) (insert-char ?* 1)) ; the / comes later. ; Do I need a t (retain sticky properties) here? (setq indentp (and (not arg) @@ -1262,11 +1262,11 @@ newline cleanups are done if appropriate; see the variable `c-cleanup-list'." (backward-char) (skip-chars-backward " \t") (setq beg (point)) - (c-save-buffer-state () (c-on-identifier)) - ;; Don't add a space into #define FOO().... - (not (and (c-beginning-of-macro) - (c-forward-over-cpp-define-id) - (eq (point) beg))))) + (and (c-save-buffer-state () (c-on-identifier)) + ;; Don't add a space into #define FOO().... + (not (and (c-beginning-of-macro) + (c-forward-over-cpp-define-id) + (eq (point) beg)))))) (save-excursion (delete-region beg end) (goto-char beg) @@ -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 @@ -1511,7 +1525,8 @@ defun." (or arg (setq arg 1)) (c-save-buffer-state - ((start (point)) + (beginning-of-defun-function end-of-defun-function + (start (point)) where paren-state pos) ;; Move back out of any macro/comment/string we happen to be in. @@ -1530,7 +1545,7 @@ defun." (setq arg (c-forward-to-nth-EOF-} (- arg) where))) ;; Move forward to the next opening brace.... (when (and (= arg 0) - (c-syntactic-re-search-forward "{" nil t)) + (c-syntactic-re-search-forward "{" nil 'eob)) (backward-char) ;; ... and backward to the function header. (c-beginning-of-decl-1) @@ -1613,7 +1628,8 @@ the open-parenthesis that starts a defun; see `beginning-of-defun'." (or arg (setq arg 1)) (c-save-buffer-state - ((start (point)) + (beginning-of-defun-function end-of-defun-function + (start (point)) where paren-state pos) ;; Move back out of any macro/comment/string we happen to be in. @@ -1630,10 +1646,8 @@ the open-parenthesis that starts a defun; see `beginning-of-defun'." (setq arg (1+ arg))) (if (< arg 0) (setq arg (c-backward-to-nth-BOF-{ (- arg) where))) - (when (and (= arg 0) - (c-syntactic-skip-backward "^}") - (eq (char-before) ?\})) - t)) + (if (= arg 0) + (c-syntactic-skip-backward "^}"))) ;; Move forward to the } of a function (if (> arg 0)