On Tuesday, March 5, 2013 8:16:48 AM UTC-8, Lech Lorens wrote:
> Wouldn't it be better to use the existing 'cinoptions' entry jN? It's
> 
> related to Java...
> 

This is also what I am hesitating at. But people who need the original 'j' 
option may not need this option (and vice versa) for the use of their languages 
(Javascript?), so I finally splitted them.
> 
> 
> BTW, in the past I made a number of modifications to the indenting
> 
> code. It was like treading on a mine field (lots of things I could
> 
> break). Would you, please, also include a test case for your
> 
> functionality so that the next person that modifies get_c_indent()
> 
> does not break what you've achieved?
> 
> 

Thanks for the reminder. I have included the test case in the new attached 
patch.

Thanks,
Hong

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


diff -r ad7bbe9ea65b runtime/doc/indent.txt
--- a/runtime/doc/indent.txt	Tue Feb 26 22:54:11 2013 +0100
+++ b/runtime/doc/indent.txt	Tue Mar 05 10:00:02 2013 -0800
@@ -513,6 +513,19 @@
 		    }
 		});
 <
+								    *cino-E*
+	EN    Indent Java enumerations correctly. Also works well for C#. The
+	      value 'N' is currently unused but must be non-zero (e.g. 'E1').
+	      'E1' will indent for example the following code snippet
+	      correctly: >
+
+	        public enum {
+		    MON,
+		    TUE,
+		    WED
+		};
+<
+
 			*javascript-cinoptions* *javascript-indenting* *cino-J*
 	JN    Indent JavaScript object declarations correctly by not confusing
 	      them with labels.  The value 'N' is currently unused but must be 
diff -r ad7bbe9ea65b src/misc1.c
--- a/src/misc1.c	Tue Feb 26 22:54:11 2013 +0100
+++ b/src/misc1.c	Tue Mar 05 10:00:02 2013 -0800
@@ -5263,7 +5263,7 @@
 static int	cin_iscomment __ARGS((char_u *));
 static int	cin_islinecomment __ARGS((char_u *));
 static int	cin_isterminated __ARGS((char_u *, int, int));
-static int	cin_isinit __ARGS((void));
+static int	cin_isinit __ARGS((int));
 static int	cin_isfuncdecl __ARGS((char_u **, linenr_T, linenr_T, int, int));
 static int	cin_isif __ARGS((char_u *));
 static int	cin_iselse __ARGS((char_u *));
@@ -5451,7 +5451,8 @@
  * check for "=" at end or "[typedef] enum" at beginning of line.
  */
     static int
-cin_isinit(void)
+cin_isinit(ind_javaenum)
+    int     ind_javaenum;
 {
     char_u	*s;
 
@@ -5463,6 +5464,38 @@
     if (STRNCMP(s, "static", 6) == 0 && !vim_isIDc(s[6]))
 	s = cin_skipcomment(s + 6);
 
+    if (ind_javaenum)
+    {
+	for (;;)
+	{
+	    if (STRNCMP(s, "static", 6) == 0 && !vim_isIDc(s[6]))
+	    {
+		s = cin_skipcomment(s + 6);
+		continue;
+	    }
+
+	    if (STRNCMP(s, "public", 6) == 0 && !vim_isIDc(s[6]))
+	    {
+		s = cin_skipcomment(s + 6);
+		continue;
+	    }
+
+	    if (STRNCMP(s, "protected", 9) == 0 && !vim_isIDc(s[9]))
+	    {
+		s = cin_skipcomment(s + 9);
+		continue;
+	    }
+
+	    if (STRNCMP(s, "private", 7) == 0 && !vim_isIDc(s[7]))
+	    {
+		s = cin_skipcomment(s + 7);
+		continue;
+	    }
+
+	    break;
+	}
+    }
+
     if (STRNCMP(s, "enum", 4) == 0 && !vim_isIDc(s[4]))
 	return TRUE;
 
@@ -6726,6 +6759,11 @@
     int	ind_java = 0;
 
     /*
+     * handle enums for java code
+     */
+    int ind_javaenum = 0;
+
+    /*
      * not to confuse JS object properties with labels
      */
     int ind_js = 0;
@@ -6860,6 +6898,7 @@
 	    case 'g': ind_scopedecl = n; break;
 	    case 'h': ind_scopedecl_code = n; break;
 	    case 'j': ind_java = n; break;
+	    case 'E': ind_javaenum = n; break;
 	    case 'J': ind_js = n; break;
 	    case 'l': ind_keep_case_label = n; break;
 	    case '#': ind_hash_comment = n; break;
@@ -7607,7 +7646,7 @@
 			    /* if it es a enum declaration or an assignment,
 			     * we are done.
 			     */
-			    if (terminated != ';' && cin_isinit())
+			    if (terminated != ';' && cin_isinit(ind_javaenum))
 				break;
 
 			    /* nothing useful found */
diff -r ad7bbe9ea65b src/testdir/test3.in
--- a/src/testdir/test3.in	Tue Feb 26 22:54:11 2013 +0100
+++ b/src/testdir/test3.in	Tue Mar 05 10:00:02 2013 -0800
@@ -1875,6 +1875,19 @@
 }
 NAMESPACEEND
 
+STARTTEST
+:set cino=E1
+/^JAVAESTART
+=/^JAVAEEND
+ENDTEST
+
+JAVAESTART
+public static enum {
+foo1,
+foo2,
+bar
+}
+JAVAEEND
 
 STARTTEST
 :set cino=j1,J1
diff -r ad7bbe9ea65b src/testdir/test3.ok
--- a/src/testdir/test3.ok	Tue Feb 26 22:54:11 2013 +0100
+++ b/src/testdir/test3.ok	Tue Mar 05 10:00:02 2013 -0800
@@ -1674,6 +1674,14 @@
 NAMESPACEEND
 
 
+JAVAESTART
+public static enum {
+	foo1,
+	foo2,
+	bar
+}
+JAVAEEND
+
 
 JSSTART
 var bar = {

Raspunde prin e-mail lui