home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / AP / JED / JED097-1.TAR / jed / lib / cmisc.sl < prev    next >
Encoding:
Text File  |  1994-12-12  |  964 b   |  63 lines

  1. %
  2. %  Miscellaneous functions for C mode
  3. %
  4.  
  5. % produce a comment for C---
  6. define c_make_comment ()
  7. {
  8.    variable d, cbeg, cend, file, mode;
  9.    cbeg = "/*";
  10.    cend = "*/";
  11.    
  12.    (, mode) = whatmode ();
  13.    !if (mode & 2) return;
  14.    
  15.    (file,,,) = getbuf_info();
  16.    
  17.    if (mode & 8) 
  18.      {
  19.     cbeg = "%";
  20.     cend = Null_String;
  21.      }
  22.    
  23.  
  24.    
  25.    %% search for a comment on the line
  26.    eol();
  27.    if (bfind(cbeg))
  28.      {
  29.     !if (bolp())
  30.       {
  31.          go_left(1);
  32.          trim(); 
  33.          ffind(cbeg); pop();
  34.       }
  35.     d = C_Comment_Column - what_column;
  36.     if (d > 0) whitespace(d);
  37.     !if (ffind(cend))
  38.       {
  39.          eol();
  40.          insert("  ");
  41.          insert (cend);
  42.       }
  43.     
  44.     bfind(cbeg); pop();
  45.     go_right(strlen(cbeg) + 1);
  46.      }
  47.    else                       %/* not found */
  48.      {
  49.     if (what_column() <= C_Comment_Column)
  50.       {
  51.          goto_column(C_Comment_Column);
  52.       }
  53.     else insert("   ");
  54.     insert(cbeg); insert("  "); 
  55.     if (strlen(cend))
  56.       {
  57.          insert (cend);
  58.          go_left(3);
  59.       }
  60.      } 
  61. }
  62.  
  63.