File: filter.sl

package info (click to toggle)
jed 0.99.16-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,312 kB
  • ctags: 4,736
  • sloc: ansic: 36,879; sh: 8,660; makefile: 379
file content (41 lines) | stat: -rw-r--r-- 658 bytes parent folder | download | duplicates (8)
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
37
38
39
40
41
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));
   
   push_spot ();
   if (-1 == insert_file (file))
     {
	pop_spot ();
	error ("Error encountered running filter.");
     }
   pop_spot ();

   del_region ();
   
   EXECUTE_ERROR_BLOCK;
}