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

  1. %
  2. %  This function executes a query-replace across all buffers attached to
  3. %  a file.
  4. %
  5. define replace_across_buffer_files ()
  6. {
  7.    variable cbuf = whatbuf ();
  8.    variable n = buffer_list ();
  9.    variable buf, file, flags;
  10.    variable pat, rep;
  11.    
  12.    pat = read_mini ("Replace:", Null_String, Null_String);
  13.    !if (strlen (pat)) return;
  14.    rep = read_mini ("Replace with:", Null_String, Null_String);
  15.    
  16.    push_spot ();               %  save our location
  17.    ERROR_BLOCK 
  18.      {
  19.     sw2buf (cbuf);
  20.     pop_spot ();
  21.     loop (n) pop ();               %  remove buffers from stack
  22.      }
  23.    
  24.    while (n)
  25.      {
  26.     buf = ();  n--;
  27.     
  28.     % skip special buffers
  29.     if ((buf[0] == '*') or (buf[0] == ' ')) continue;
  30.  
  31.     sw2buf (buf);
  32.     
  33.     (file,,,flags) = getbuf_info ();
  34.     
  35.     % skip if no file associated with buffer, or is read only
  36.     !if (strlen (file) or (flags & 8)) continue;  
  37.     
  38.     % ok, this buffer is what we want.
  39.     
  40.     push_spot ();
  41.     ERROR_BLOCK
  42.       {
  43.          pop_spot ();
  44.       }
  45.     
  46.     bob ();
  47.     replace_maybe_query (pat, rep, 1);
  48.     pop_spot ();
  49.      }
  50.    
  51.    EXECUTE_ERROR_BLOCK;
  52.    message ("Done.");
  53. }
  54.  
  55.     
  56.     
  57.     
  58.    
  59.