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#15465: CC-mode misaligns enums that implement an interface in Java Date: Sun, 29 Sep 2013 15:03:45 +0000 Message-ID: <20130929150345.GD3161@acm.acm> References: <20130928173323.GA11317@acm.acm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1380467182 30123 80.91.229.3 (29 Sep 2013 15:06:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 29 Sep 2013 15:06:22 +0000 (UTC) Cc: 15465@debbugs.gnu.org To: Paul Pogonyshev Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Sep 29 17:06:24 2013 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 1VQIZh-0006s9-1P for geb-bug-gnu-emacs@m.gmane.org; Sun, 29 Sep 2013 17:06:21 +0200 Original-Received: from localhost ([::1]:45018 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQIZg-00072A-CC for geb-bug-gnu-emacs@m.gmane.org; Sun, 29 Sep 2013 11:06:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQIZW-00071s-H0 for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2013 11:06:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VQIZP-0000Vf-5p for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2013 11:06:10 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:36634) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQIZP-0000VX-2k for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2013 11:06:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VQIZO-0000Va-Du for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2013 11:06:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 29 Sep 2013 15:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15465 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 15465-submit@debbugs.gnu.org id=B15465.13804671401922 (code B ref 15465); Sun, 29 Sep 2013 15:06:02 +0000 Original-Received: (at 15465) by debbugs.gnu.org; 29 Sep 2013 15:05:40 +0000 Original-Received: from localhost ([127.0.0.1]:44927 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VQIZ1-0000Uw-DO for submit@debbugs.gnu.org; Sun, 29 Sep 2013 11:05:39 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:10272 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VQIYw-0000Uj-Cf for 15465@debbugs.gnu.org; Sun, 29 Sep 2013 11:05:35 -0400 Original-Received: (qmail 27690 invoked by uid 3782); 29 Sep 2013 15:05:32 -0000 Original-Received: from acm.muc.de (p5492C855.dip0.t-ipconnect.de [84.146.200.85]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 29 Sep 2013 17:05:31 +0200 Original-Received: (qmail 4865 invoked by uid 1000); 29 Sep 2013 15:03:45 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de 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:78797 Archived-At: Hi, Paul. On Sat, Sep 28, 2013 at 09:15:52PM +0200, Paul Pogonyshev wrote: > > I've committed a fix, revision #114474, to the bzr trunk. Could you try > > out the change, please, and either confirm it fixes the bug properly, or > > tell me what hasn't yet been fixed. > Thank you. The case I initially mentioned works properly now, also with > multiple implemented interfaces. However, it seems to not know about > interfaces with generics: > public enum X implements Y > { > A, > B; > } Here's a better patch than the one from last night, which was demonstrably buggy. It should apply cleanly to the current trunk. Please let me know how thoroughly it works. diff -r d51d11733869 cc-engine.el --- a/cc-engine.el Sat Sep 28 16:39:26 2013 +0000 +++ b/cc-engine.el Sun Sep 29 14:57:33 2013 +0000 @@ -8506,6 +8506,32 @@ (not (looking-at "="))))) b-pos))) +(defun c-backward-over-enum-header () + ;; We're at a "{". Move back to the enum-like keyword that starts this + ;; declaration and return t, otherwise don't move and return nil. + (let ((here (point)) + up-sexp-pos before-identifier) + (while + (and + (eq (c-backward-token-2) 0) + (or (not (looking-at "\\s)")) + (c-go-up-list-backward)) + (cond + ((and (looking-at c-symbol-key) (c-on-identifier)) + (setq before-identifier t)) + ((and before-identifier + (looking-at c-postfix-decl-spec-key)) + (setq before-identifier nil) + t) + ((looking-at c-brace-list-key) nil) + ((and c-recognize-<>-arglists + (eq (char-after) ?<) + (looking-at "\\s(")) + t) + (t nil)))) + (or (looking-at c-brace-list-key) + (progn (goto-char here) nil)))) + (defun c-inside-bracelist-p (containing-sexp paren-state) ;; return the buffer position of the beginning of the brace list ;; statement if we're inside a brace list, otherwise return nil. @@ -8520,22 +8546,9 @@ ;; This function might do hidden buffer changes. (or ;; This will pick up brace list declarations. - (c-safe - (save-excursion - (goto-char containing-sexp) - (let (before-identifier) - (while - (progn - (c-forward-sexp -1) - (cond - ((c-on-identifier) (setq before-identifier t)) - ((and before-identifier - (looking-at c-postfix-decl-spec-key)) - (setq before-identifier nil) - t) - ((looking-at c-brace-list-key) nil) - (t nil)))) - (looking-at c-brace-list-key)))) + (save-excursion + (goto-char containing-sexp) + (c-backward-over-enum-header)) ;; this will pick up array/aggregate init lists, even if they are nested. (save-excursion (let ((class-key diff -r d51d11733869 cc-fonts.el --- a/cc-fonts.el Sat Sep 28 16:39:26 2013 +0000 +++ b/cc-fonts.el Sun Sep 29 14:57:33 2013 +0000 @@ -1438,22 +1438,9 @@ (let ((paren-state (c-parse-state))) (and (numberp (car paren-state)) - (c-safe - (save-excursion - (goto-char (car paren-state)) - (let (before-identifier) - (while - (progn - (c-forward-sexp -1) - (cond - ((c-on-identifier) (setq before-identifier t)) - ((and before-identifier - (looking-at c-postfix-decl-spec-key)) - (setq before-identifier nil) - t) - ((looking-at c-brace-list-key) nil) ; "enum" - (t nil)))) - (looking-at c-brace-list-key))))))) + (save-excursion + (goto-char (car paren-state)) + (c-backward-over-enum-header))))) (c-forward-token-2) nil) @@ -1542,22 +1529,9 @@ (when (and encl-pos (eq (char-after encl-pos) ?\{) - (c-safe - (save-excursion - (goto-char encl-pos) - (let (before-identifier) - (while - (progn - (c-forward-sexp -1) - (cond - ((c-on-identifier) (setq before-identifier t)) - ((and before-identifier - (looking-at c-postfix-decl-spec-key)) - (setq before-identifier nil) - t) - ((looking-at c-brace-list-key) nil) ; "enum" - (t nil)))) - (looking-at c-brace-list-key))))) + (save-excursion + (goto-char encl-pos) + (c-backward-over-enum-header))) (c-syntactic-skip-backward "^{," nil t) (c-put-char-property (1- (point)) 'c-type 'c-decl-id-start) > Paul -- Alan Mackenzie (Nuremberg, Germany).