From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: CC Mode 5.31.4 (C/l); c-end-of-defun broken Date: 18 Apr 2007 23:27:55 +0200 Message-ID: <20070418224804.GF2100@muc.de> References: <87zm55sgea.fsf@stupidchicken.com> <20070418213146.GC2100@muc.de> <87bqhlct24.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1176931697 16873 80.91.229.12 (18 Apr 2007 21:28:17 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 18 Apr 2007 21:28:17 +0000 (UTC) Cc: bug-cc-mode@gnu.org, A Soare , emacs-devel@gnu.org, Andreas Schwab To: Chong Yidong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Apr 18 23:28:09 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HeHhA-0006Us-QR for ged-emacs-devel@m.gmane.org; Wed, 18 Apr 2007 23:28:09 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HeHm2-0005N6-S3 for ged-emacs-devel@m.gmane.org; Wed, 18 Apr 2007 17:33:10 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HeHly-0005N1-9h for emacs-devel@gnu.org; Wed, 18 Apr 2007 17:33:06 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HeHlu-0005Mp-OR for emacs-devel@gnu.org; Wed, 18 Apr 2007 17:33:05 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HeHlu-0005Mm-FP for emacs-devel@gnu.org; Wed, 18 Apr 2007 17:33:02 -0400 Original-Received: from colin.muc.de ([193.149.48.1] helo=mail.muc.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HeHh0-0005vp-Js for emacs-devel@gnu.org; Wed, 18 Apr 2007 17:27:59 -0400 Original-Received: (qmail 63636 invoked by uid 3782); 18 Apr 2007 21:27:55 -0000 Original-Received: from acm.muc.de (p54a3f879.dip.t-dialin.net [84.163.248.121]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Wed, 18 Apr 2007 23:27:52 +0200 Original-Received: (qmail 4867 invoked by uid 1000); 18 Apr 2007 22:48:04 -0000 Original-Date: Wed, 18 Apr 2007 23:48:04 +0100 Content-Disposition: inline In-Reply-To: <87bqhlct24.fsf@stupidchicken.com> User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) X-Primary-Address: acm@muc.de X-detected-kernel: FreeBSD 4.6-4.9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:69584 Archived-At: Hi, Chong, On Wed, Apr 18, 2007 at 04:43:15PM -0400, Chong Yidong wrote: > Hi Alan, > The behavior seems to be correct, as far as I can tell. However: > > ! ;; 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) > Do you really want to use `lim' here? That argument, if non-nil, is > supposed to give a lower bound for the search, starting from point. I > think the correct limit you are looking for is the original point > where we started. You're right. I did some careless copying and yanking from somewhere else in the code. Sorry. > (In fact, c-in-function-trailer-p is not called with a non-nil > argument anywhere in Emacs, so this bug wouldn't show up, but it's > better to be safe than sorry.) Code should (i.e. must) do what its comments say. ;-) > Similarly here: > > ! (c-syntactic-re-search-forward "[;=\(\[{]" lim t t t) Yes. This should be better: 2007-04-18 acm * 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 21:23:26 -0000 *************** *** 1360,1369 **** (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 --- 1360,1383 ---- (and c-opt-block-decls-with-vars-key (save-excursion (c-syntactic-skip-backward "^;}" lim) ! (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 I'm off to bed, now. If everything's OK, I'll commit the patch tomorrow. Thanks for checking my patch. -- Alan.