From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ivan Andrus Newsgroups: gmane.emacs.bugs Subject: bug#19134: 24.4.51; Error using mark-defun in c++-mode Date: Mon, 24 Nov 2014 20:00:36 -0700 Message-ID: <9D48252F-D43B-44BA-A698-6C6C14E373BC@gmail.com> References: <20141122220413.75395.qmail@mail.muc.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1416884489 14057 80.91.229.3 (25 Nov 2014 03:01:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 25 Nov 2014 03:01:29 +0000 (UTC) Cc: 19134@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 25 04:01:21 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Xt6NV-0007Q4-Dy for geb-bug-gnu-emacs@m.gmane.org; Tue, 25 Nov 2014 04:01:21 +0100 Original-Received: from localhost ([::1]:55265 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xt6NV-0003C4-2m for geb-bug-gnu-emacs@m.gmane.org; Mon, 24 Nov 2014 22:01:21 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60047) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xt6NN-0003By-5K for bug-gnu-emacs@gnu.org; Mon, 24 Nov 2014 22:01:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xt6NI-0004L2-2u for bug-gnu-emacs@gnu.org; Mon, 24 Nov 2014 22:01:13 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47226) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xt6NC-0004Kg-Hk; Mon, 24 Nov 2014 22:01:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Xt6NC-0000On-0x; Mon, 24 Nov 2014 22:01:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ivan Andrus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Tue, 25 Nov 2014 03:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19134 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 19134-submit@debbugs.gnu.org id=B19134.14168844461477 (code B ref 19134); Tue, 25 Nov 2014 03:01:01 +0000 Original-Received: (at 19134) by debbugs.gnu.org; 25 Nov 2014 03:00:46 +0000 Original-Received: from localhost ([127.0.0.1]:44439 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xt6Mv-0000Ni-Pg for submit@debbugs.gnu.org; Mon, 24 Nov 2014 22:00:46 -0500 Original-Received: from mail-ig0-f178.google.com ([209.85.213.178]:51186) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xt6Mt-0000NU-0r for 19134@debbugs.gnu.org; Mon, 24 Nov 2014 22:00:43 -0500 Original-Received: by mail-ig0-f178.google.com with SMTP id hl2so4313852igb.11 for <19134@debbugs.gnu.org>; Mon, 24 Nov 2014 19:00:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=WEHSLdT9sSBn+Vo3MYMsgdFlsPhOEt4wos/nq4C+mFU=; b=z+IulAaWCV3Ep/K7P5N0UcaimmoWvunfB7mH0pA4WFMrNF3Cbedqasx4ftgSd5GObZ vE1t3JSi9DNNf3jC4zy8hMkiF2ETtO3xgRcodavONDNlMrRL5A2YHQJ7H0tLiFIgPcWt abAdL7+MZRydssjaVTsAdTZlTcUxgSDjywzJVSQh/7fwrW30D6DJywZYkAOMUWb6pFNy QtCHDLT/74NxexHsk4oo5k+mgd8ueZEk5VjmG7h3ppW6H7WWuzfd+7NuNj+2xH1bXAWD oWVYuavRw3yDBYlcv4BZy6AjD7krVhg4ynD5VGUfb0S/MOgFj3dXXfL6rK/0PsjwulLO NwMQ== X-Received: by 10.50.35.195 with SMTP id k3mr15424401igj.11.1416884442114; Mon, 24 Nov 2014 19:00:42 -0800 (PST) Original-Received: from [192.168.0.3] (75-162-204-71.slkc.qwest.net. [75.162.204.71]) by mx.google.com with ESMTPSA id qj3sm396680igc.17.2014.11.24.19.00.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Nov 2014 19:00:41 -0800 (PST) In-Reply-To: <20141122220413.75395.qmail@mail.muc.de> X-Mailer: Apple Mail (2.1878.6) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:96530 Archived-At: On Nov 22, 2014, at 3:04 PM, Alan Mackenzie wrote: > Hello again, Ivan. >=20 > In article you = wrote: >> Starting from emacs -Q, create a buffer in `c++-mode' with contents = below. >=20 >> class Bob >> { >> protected: >=20 >> void fun() >> { >> } >=20 >> }; >=20 >=20 >> Placing point on the line after "protected:" and running mark-defun = gives >> the error: >=20 >> c-where-wrt-brace-construct: c-where-wrt-brace-construct: = c-beginning-of-decl-1 returned label >=20 > Yes. I've just pushed the following patch to the git repository: >=20 >=20 > diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el > index 5fa3b25..50cdd78 100644 > --- a/lisp/progmodes/cc-cmds.el > +++ b/lisp/progmodes/cc-cmds.el > @@ -1417,12 +1417,15 @@ No indentation or other \"electric\" behavior = is performed." > (car (c-beginning-of-decl-1 > ;; NOTE: If we're in a K&R region, this might be = the start > ;; of a parameter declaration, not the actual = function. > + ;; It might also leave us at a label or "label" = like > + ;; "private:". > (and least-enclosing ; LIMIT for c-b-of-decl-1 > (c-safe-position least-enclosing = paren-state))))) >=20 > ;; Has the declaration we've gone back to got braces? > - (setq brace-decl-p > - (save-excursion > + (or (eq decl-result 'label) > + (setq brace-decl-p > + (save-excursion > (and (c-syntactic-re-search-forward "[;{]" nil t t) > (or (eq (char-before) ?\{) > (and c-recognize-knr-p > @@ -1430,10 +1433,11 @@ No indentation or other \"electric\" behavior = is performed." > ;; ';' in a K&R argdecl. In > ;; that case the declaration > ;; should contain a block. > - (c-in-knr-argdecl)))))) > + (c-in-knr-argdecl))))))) >=20 > (cond > - ((=3D (point) kluge-start) ; might be BOB or unbalanced = parens. > + ((or (eq decl-result 'label) ; e.g. "private:" or invalid = syntax. > + (=3D (point) kluge-start)) ; might be BOB or unbalanced = parens. > 'outwith-function) > ((eq decl-result 'same) > (if brace-decl-p >=20 >=20 > I think this should fix the problem. Would you please test it with > `mark-defun' and confirm it works properly. Thanks! Yes, I confirm that it works. =20 > Incidentally, `c-mark-function' (the default binding for C-M-h in CC = Mode) > doesn't do the right thing here. I'll be looking into this. I didn=92t notice that. I have C-M-h bound to a wrapper around = mark-defun in my .emacs, so I don=92t actually run c-mark-function. = Thanks for pointing me to it. >> Ideally it would give no error, and IMO, it should mark fun(), though >> marking the class would be fine as well. >=20 > It marks the class, since it gives priority to defuns point is in, = rather > than those which follow point. There might be scope for some = improvement > here. That=92s fine. It could probably be better but, hey, what couldn=92t? = :-) > Thanks for taking the trouble to distil the problem down to a nice, = very > short piece of code, and for describing the problem so helpfully. And thank you for the very fast fix. I should have taken the time a = while since I have run into it occasionally. -Ivan=