"Fossies" - the Fresh Open Source Software Archive

Member "jed-0.99-19/lib/krconv.sl" (14 Dec 2009, 1916 Bytes) of package /linux/misc/jed-0.99-19.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 %enable_profiling ();
    2 private define fixup_line ()
    3 {
    4    variable col;
    5 
    6    !if (parse_to_point ())
    7      {
    8 	col = what_column ();
    9 	bol_skip_white ();
   10 	if (col != what_column ())
   11 	  {
   12 	     goto_column (col);
   13 	     indent_line ();
   14 	     if (C_BRA_NEWLINE) newline ();
   15 	  }
   16 	go_right_1 ();
   17 	trim ();
   18 	!if (eolp () or looking_at_char (',') or looking_at_char (';'))
   19 	  {
   20 	     indent_line ();
   21 	     newline ();
   22 	  }
   23      }
   24    go_right_1 ();
   25 }
   26 
   27 define c_indent_buffer ()
   28 {
   29    variable line = -50, max_line;
   30    push_spot ();
   31    eob ();
   32    max_line = what_line ();
   33    bob ();
   34    do
   35      {
   36 	bol_skip_white ();
   37 	if (looking_at ("/*"))
   38 	  {
   39 	     % skip the comment 
   40 	     () = fsearch ("*/");
   41 	     continue;
   42 	  }
   43 	
   44 	eol ();
   45 	if (blooking_at ("\\"))
   46 	  {
   47 	     indent_line ();
   48 	     % skip all continuation lines.
   49 	     while (down (1))
   50 	       {
   51 		  eol ();
   52 		  !if (blooking_at ("\\")) break;
   53 	       }
   54 	     continue;
   55 	  }
   56 	trim ();
   57 	bol_skip_white ();
   58 	!if (looking_at_char ('{'))
   59 	  {
   60 	     variable this_line = what_line ();
   61 	     % I do not want to touch constructs such as x = {1, 3};
   62 	     while (ffind_char ('{')
   63 		    and parse_to_point ())
   64 	       go_right_1 ();
   65 	     
   66 	     if (looking_at_char ('{'))
   67 	       {
   68 		  variable m = create_user_mark ();
   69 		  if (find_matching_delimiter ('{')
   70 		      and (this_line == what_line ()))
   71 		    {
   72 		       eol ();
   73 		       indent_line ();
   74 		       continue;
   75 		    }
   76 		  goto_user_mark (m);
   77 	       }
   78 	     bol ();
   79 	     while (ffind_char ('}'))
   80 	       fixup_line ();
   81 	     bol ();
   82 	     while (ffind_char ('{'))
   83 	       fixup_line ();
   84 	  }
   85 
   86 	indent_line ();
   87 	if (line + 50 < what_line ())
   88 	  {
   89 	     line = what_line ();
   90 	     flush (sprintf ("processed %d/%d lines.", line, max_line));
   91 	  }
   92 	
   93 	%update_sans_update_hook (1);
   94      }
   95    while (down_1 ());
   96    trim_buffer ();
   97    flush (sprintf ("processed %d/%d lines.", what_line (), max_line));
   98    pop_spot ();
   99 }
  100 
  101 	
  102