Subject: Re: bug#15465: CC-mode misaligns enums that implement an interface in Java

From: Alan Mackenzie <[email-masked]>
Date: Sat, 28 Sep 2013 21:33:12 +0000

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 <Z>
> {
>     A,
>         B;
> }

OK!

I think the following enhancement should help out here:

diff -r d51d11733869 cc-engine.el
--- a/cc-engine.el	Sat Sep 28 16:39:26 2013 +0000
+++ b/cc-engine.el	Sat Sep 28 21:27:53 2013 +0000
@@ -8534,6 +8534,10 @@
 		 (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))))
 	 (looking-at c-brace-list-key))))
    ;; this will pick up array/aggregate init lists, even if they are nested.
diff -r d51d11733869 cc-fonts.el
--- a/cc-fonts.el	Sat Sep 28 16:39:26 2013 +0000
+++ b/cc-fonts.el	Sat Sep 28 21:27:53 2013 +0000
@@ -1452,6 +1452,10 @@
 				    (setq before-identifier nil)
 				    t)
 				   ((looking-at c-brace-list-key) nil) ; "enum"
+				   ((and c-recognize-<>-arglists
+					 (eq (char-after) ?<)
+					 (looking-at "\\s("))
+				    t)
 				   (t nil))))
 			    (looking-at c-brace-list-key)))))))
 	      (c-forward-token-2)
@@ -1556,6 +1560,10 @@
 			(setq before-identifier nil)
 			t)
 		       ((looking-at c-brace-list-key) nil) ; "enum"
+		       ((and c-recognize-<>-arglists
+			     (eq (char-after) ?<)
+			     (looking-at "\\s("))
+			t)
 		       (t nil))))
 		 (looking-at c-brace-list-key)))))
       (c-syntactic-skip-backward "^{," nil t)

> Paul

-- 
Alan Mackenzie (Nuremberg, Germany).