jed-users mailing list

[2002 Date Index] [2002 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: RE: Ignore_Beep doesn't


ks <klaus.schmid@xxxxxx> wrote:
>Maybe it could be improved further by using an extended autoload function:
>
>  autoload( "/etc/jed.init.d", "*");
>
>which should mean: if any function is not yet defined, and not included in a
>specific autoload, all files in the indicated folder will be evaluated to
>get the

I think that it is better to use a script such as the one attached
below to create a file of autoload statements.  If a function is given
the public attribute, an autoload statement will be generated for it.

#! /usr/bin/env slsh

% This script creates the autoload.sl file.

_debug_info = 1;

variable Src_Files = "*.sl";

define process_file (file, list)
{
   variable fp = fopen (file, "r");
   if (fp == NULL)
     {
	vmessage ("Cannot open %s -- skipping\n", file);
	return NULL;
     }
   
   variable lines = fgetslines (fp);
   variable i = where (0 == array_map (Int_Type, &strncmp, lines, "public define ", 14));
   lines = lines[i];
   
   foreach (lines)
     {
	variable l = ();
	l = strtok (l, " \t(");
	if (length (l) < 3)
	  continue;
	
	list[l[2]] = file;
     }
}

define main ()
{
   variable list = Assoc_Type[String_Type];
   
   foreach (listdir ("."))
     {
	variable file = ();
	
	if ((".sl" != path_extname (file))
	    or (file == "jdl.sl") or (file == "autoload.sl"))
	  continue;
	process_file (file, list);
     }
   
   variable fp = fopen ("autoload.sl", "w");
   if (fp == NULL)
     {
	vmessage ("Unable to open autoload.sl for writing");
	exit (1);
     }
   
   () = fprintf (fp, "%% This file is automatically generated\n");
   variable funs = assoc_get_keys (list);
   
   foreach (funs[array_sort (funs)])
     {
	variable f = ();
	
	if (-1 == fprintf (fp, ". \"%s\" \"%s\" autoload\n", f, list[f]))
	  {
	     vmessage ("Write to autoload.sl failed");
	     exit (1);
	  }
     }
   
   if (-1 == fclose (fp))
     {
	vmessage ("Write to autoload.sl failed");
	exit (1);
     }
   
   exit (0);
}

main ();
   
   

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2002 date index] [2002 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]