jed-users mailing list

[2004 Date Index] [2004 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

This diff allows C++ namespace blocks to have their own indentation value.


Hi,
 
This diff has come about as my current work place uses an indentation level of 0 for namespace blocks; which is possible in Emacs but not in jed.  This allows the user to specify C_Namespace_Offset to be the offset within the namespace block.  It is a copy of the code used to control indentation within class declarations.  I did not understand why the preprocessor(?) was used in the existing code, and I commented this portion which I think probably needs to be cleaned up by someone more knowledgeable.
 

I have tried to ensure the indentation was consistent by running indent buffer with the style set to "jed".  This appears to have had the unfortunate side effect of picking up some miscellaneous whitespace elsewhere in "cmode.sl".
 
While I commented the variable in "site.sl" with what appears to be special formatting (for automatic documentation I assume) the comment does not appear in the online help when I build jed.  I'm pretty sure there is a step I'm missing; can anyone point me to instructions on what I need to do?
 
The diff was created using "cvs diff -u -R " (I am working in a local CVS repo.) against a pristine jed-0.99.16 source tree.
 
I apologize in advance if I have broken any rules of etiquette for this list.
 
Marc


Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
Index: lib/cmode.sl
===================================================================
RCS file: /sandbox/marc/CVSREPO/jed/lib/cmode.sl,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 cmode.sl
--- lib/cmode.sl	18 Mar 2004 04:28:46 -0000	1.1.1.1
+++ lib/cmode.sl	18 Mar 2004 04:51:42 -0000
@@ -58,17 +58,17 @@
 {
    variable is_slang = cmode_is_slang_mode ();
 
-   forever 
+   forever
      {
 	skip_all_whitespace ();
 	if (eobp ())
 	  return;
-	
+
 	if (is_slang)
 	  {
 	     !if (looking_at ("%"))
 	       return;
-	     
+
 	     eol ();
 	     continue;
 	  }
@@ -80,13 +80,13 @@
 	     go_right(2);
 	     continue;
 	  }
-	
+
 	if (looking_at ("//"))
 	  {
-	     eol (); 
+	     eol ();
 	     continue;
 	  }
-	    
+
 	return;
      }
 }
@@ -392,6 +392,35 @@
 }
 #endif
 
+% This is a rip off of inside_class() .
+static define inside_namespace (bra)
+{
+   push_spot ();
+   EXIT_BLOCK
+     {
+	pop_spot ();
+     }
+
+   goto_user_mark (bra);
+
+   while (re_bsearch ("\\c\\<namespace\\>"))
+     {
+	bskip_white ();
+	if (bolp and (0 == parse_to_point ()))
+	  {
+	     if (0 == c_fsearch ("{"))
+	       return 0;
+
+	     return bra == create_user_mark ();
+	  }
+
+	!if (left (1))
+	  break;
+     }
+
+   return 0;
+}
+
 define c_indent_line ()
 {
    variable val, col, extra_indent = 0;
@@ -603,11 +632,16 @@
 	     pop_spot ();
 	     col = match_indent;
 
+	     % If C_Class_Offset is defined, assume C_Namespace_Offset
+	     % is also defined.  This may not be valid.
+
 #ifexists C_Class_Offset
 	     if (this_char == '}')
 	       col += C_INDENT;
 	     else if (inside_class (match_mark))
 	       col += C_Class_Offset;
+	     else if (inside_namespace (match_mark))
+	       col += C_Namespace_Offset;
 	     else
 	       col += C_INDENT;
 #else
@@ -1247,23 +1281,23 @@
    switch (strlow(name))
      {
       case "gnu":
-	(2,2,1,2,0,2);
+	(2,2,1,2,0,2,2);
      }
      {
       case "k&r":
-	(5,0,0,5,0,5);
+	(5,0,0,5,0,5,5);
      }
      {
       case "bsd":
-	(4,0,0,4,0,4);
+	(4,0,0,4,0,4,4);
      }
      {
       case "linux":
-	(8,0,0,8,0,8);
+	(8,0,0,8,0,8,8);
      }
      {
       case "jed":
-	(3,2,1,2,1,3);
+	(3,2,1,2,1,3,3);
      }
      {
 	if (is_defined ("c_set_style_hook") > 0)
@@ -1271,7 +1305,7 @@
      }
 
    (C_INDENT, C_BRACE, C_BRA_NEWLINE, C_CONTINUED_OFFSET,
-    C_Colon_Offset, C_Class_Offset)=();
+    C_Colon_Offset, C_Class_Offset, C_Namespace_Offset)=();
 }
 
 if (_C_Indentation_Style != NULL)
Index: lib/site.sl
===================================================================
RCS file: /sandbox/marc/CVSREPO/jed/lib/site.sl,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 site.sl
--- lib/site.sl	18 Mar 2004 04:28:46 -0000	1.1.1.1
+++ lib/site.sl	18 Mar 2004 04:36:15 -0000
@@ -185,9 +185,21 @@
 % This variable may be changed to adjust the indentation of members
 % inside of a class declaration block.
 %\seealso{c_mode}
-%\seealso{C_BRA_NEWLINE, C_BRACE, C_INDENT}
+%\seealso{C_BRA_NEWLINE, C_BRACE, C_INDENT, C_Namespace_Offset}
 %!%-
 variable C_Class_Offset = 3;
+
+%!%+
+%\variable{C_Namespace_Offset}
+%\synopsis{C_Namespace_Offset}
+%\description
+% Integer C_Namespace_Offset = 3;
+% This variable may be changed to adjust the indentation of members
+% inside of a class declaration block.
+%\seealso{c_mode}
+%\seealso{C_BRA_NEWLINE, C_BRACE, C_Class_Offset, C_INDENT}
+%!%-
+variable C_Namespace_Offset = 3;
 
 variable compile_parse_error_function = "gcc";
 

[2004 date index] [2004 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]