File: filter.sl

package info (click to toggle)
jed 0.98.7-14
  • links: PTS
  • area: main
  • in suites: slink
  • size: 3,088 kB
  • ctags: 3,851
  • sloc: ansic: 29,315; makefile: 257; sh: 248
file content (36 lines) | stat: -rw-r--r-- 601 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
define filter_region ()
{
   variable cmd, file;

   check_region (1);		       %  spot pushed
   () = dupmark ();
   
   ERROR_BLOCK
     {
	pop_mark (0);
	pop_spot ();
     }
   
   do
     {
	cmd = read_mini ("Filter command:", Null_String, Null_String);
     }
   while (not (strlen (cmd)));

   file = make_tmp_file ("/tmp/jedfilter");

   ERROR_BLOCK
     {
	pop_spot ();
	() = delete_file (file);
     }
   () = pipe_region (sprintf ("%s > %s", cmd, file));
   
   if (-1 == insert_file (file))
     error ("Error encountered running filter.");

   del_region ();
   
   EXECUTE_ERROR_BLOCK;
}