From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#19134: 24.4.51; Error using mark-defun in c++-mode Date: 22 Nov 2014 22:04:13 -0000 Organization: muc.de e.V. Message-ID: <20141122220413.75395.qmail@mail.muc.de> References: <93B6FD75-1B53-4D57-BE97-7F1EA0FC3CED@gmail.com> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1416693930 16859 80.91.229.3 (22 Nov 2014 22:05:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 22 Nov 2014 22:05:30 +0000 (UTC) Cc: 19134@debbugs.gnu.org To: Ivan Andrus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Nov 22 23:05:22 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 1XsInx-0007zT-V4 for geb-bug-gnu-emacs@m.gmane.org; Sat, 22 Nov 2014 23:05:22 +0100 Original-Received: from localhost ([::1]:46902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XsInx-00016V-CC for geb-bug-gnu-emacs@m.gmane.org; Sat, 22 Nov 2014 17:05:21 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XsInp-00016N-3Y for bug-gnu-emacs@gnu.org; Sat, 22 Nov 2014 17:05:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XsInk-0003uw-75 for bug-gnu-emacs@gnu.org; Sat, 22 Nov 2014 17:05:12 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44819) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XsIne-0003dF-I9; Sat, 22 Nov 2014 17:05:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XsIne-0006yV-6G; Sat, 22 Nov 2014 17:05:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sat, 22 Nov 2014 22:05:02 +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.141669385826756 (code B ref 19134); Sat, 22 Nov 2014 22:05:02 +0000 Original-Received: (at 19134) by debbugs.gnu.org; 22 Nov 2014 22:04:18 +0000 Original-Received: from localhost ([127.0.0.1]:42032 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XsImv-0006xU-QO for submit@debbugs.gnu.org; Sat, 22 Nov 2014 17:04:18 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:62505 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XsIms-0006xL-Ul for 19134@debbugs.gnu.org; Sat, 22 Nov 2014 17:04:16 -0500 Original-Received: (qmail 75396 invoked by uid 3782); 22 Nov 2014 22:04:13 -0000 In-Reply-To: X-Newsgroups: gnu.emacs.bug User-Agent: tin/2.2.0-20131224 ("Lochindaal") (UNIX) (FreeBSD/8.4-RELEASE (amd64)) 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:96436 Archived-At: Hello again, Ivan. In article you wrote: > Starting from emacs -Q, create a buffer in `c++-mode' with contents below. > class Bob > { > protected: > void fun() > { > } > }; > Placing point on the line after "protected:" and running mark-defun gives > the error: > c-where-wrt-brace-construct: c-where-wrt-brace-construct: c-beginning-of-decl-1 returned label Yes. I've just pushed the following patch to the git repository: 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))))) ;; 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))))))) (cond - ((= (point) kluge-start) ; might be BOB or unbalanced parens. + ((or (eq decl-result 'label) ; e.g. "private:" or invalid syntax. + (= (point) kluge-start)) ; might be BOB or unbalanced parens. 'outwith-function) ((eq decl-result 'same) (if brace-decl-p I think this should fix the problem. Would you please test it with `mark-defun' and confirm it works properly. Thanks! 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. > Ideally it would give no error, and IMO, it should mark fun(), though > marking the class would be fine as well. 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. 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. > -Ivan -- Alan Mackenzie (Nuremberg, Germany).