emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CC Mode 5.31.4 (C/l); c-end-of-defun broken


From: Alan Mackenzie
Subject: Re: CC Mode 5.31.4 (C/l); c-end-of-defun broken
Date: 18 Apr 2007 22:11:38 +0200
Date: Wed, 18 Apr 2007 22:31:46 +0100
User-agent: Mutt/1.5.9i

Hi, everybody!

On Wed, Apr 18, 2007 at 02:10:05PM -0400, Chong Yidong wrote:
> Andreas Schwab <address@hidden> writes:

> > c-end-of-defun no longer always goes to the end of the function.  This
> > breaks add-log-current-defun, for example.  It doesn't always happen, but
> > you can reproduce it with
> > <http://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/src/gdb/symtab.c?rev=1.157&content-type=text/plain&cvsroot=src>.
> > Just load the file and type M-C-e.  You end up in the middle of
> > lookup_partial_symtab instead of at the end of lookup_symtab.

> Alan, can you come up with a quick fix?

Could people please test this fix (which I haven't yet committed):


2007-04-18  acm  <address@hidden>

        * progmodes/cc-cmds.el (c-in-function-trailer-p): Fix this: when a
        function type contains "struct", "union", etc. c-end-of-defun goes
        too far forward.


Index: cc-cmds.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-cmds.el,v
retrieving revision 1.59
diff -c -r1.59 cc-cmds.el
*** cc-cmds.el  17 Apr 2007 20:48:43 -0000      1.59
--- cc-cmds.el  18 Apr 2007 20:02:47 -0000
***************
*** 1358,1369 ****
    ;;
    ;; This function might do hidden buffer changes.
    (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)))))
  
  (defun c-where-wrt-brace-construct ()
    ;; Determine where we are with respect to functions (or other brace
--- 1358,1382 ----
    ;;
    ;; This function might do hidden buffer changes.
    (and c-opt-block-decls-with-vars-key
!        (let (bod)
!        (save-excursion
!          (c-syntactic-skip-backward "^;}" lim)
!          (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
!                        "\\)")
!                lim t t t)
!               (match-beginning 1)     ; Is there a "struct" etc., somewhere?
!               (not (eq (char-before) ?_))
!               (c-syntactic-re-search-forward "[;=\(\[{]" lim t t t)
!               (eq (char-before) ?\{)
!               bod)))))
  
  (defun c-where-wrt-brace-construct ()
    ;; Determine where we are with respect to functions (or other brace


-- 
Alan.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]