jed-users mailing list

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

__FILE__ and path_rel


Since 0.99.16 Jed has implemented a variable __FILE__, which I think
is very useful, but probably not very well known.

So hopefully my following remarks will make any sense. Any suggestions and
corrections are welcome.

To edit quickly my Jed configuration file, I found it useful to define
following function:

define jedrc(){ ()= find_file( __FILE__);}

Inserted in jed.rc (.jedrc on Unix-derivatives) I open now my
configuration file with "jedrc" at M-x or SLang-prompt.

As in this example, __FILE__ can avoid any pain with hard coded file
specifications, which otherwise have to be edited differently on
different systems.

Additionally I defined in my jed.rc a new function, which is similar
to path_concat:

define path_rel( b, r) %{{{
{
   variable i, a;
   
   a= strchop( r, '/', 0);
   for (i=0;i<length(a);i++)
     {
        if ( a[i] == "..")
          b= path_dirname( b);
        else
          b= path_concat( b, a[i]);
     }

   return b;
}
%}}}


Differently to path_concat, the second argument is expected to be a
relative path in Unix-notation.

As an example, I used that to implement my personal color scheme:

        Color_Scheme_Path+= ","+path_rel( __FILE__, "../colors");

And as well to implement painless some new modes:

        variable hsjmode_dir= path_rel( __FILE__, "../hsjmode/");
        autoload( "html_mode", hsjmode_dir+"htmlmode.sl");
        autoload( "css_mode", hsjmode_dir+"cssmode.sl");
        autoload( "js_mode", hsjmode_dir+"jsmode.sl");

Note that there is no need to modify jed_library_path or even backup
any files herein. By out-commenting these lines the original state and
mode-definitions will be recovered.
        
In the new htmlmode.sl I wrote:

        static variable M= "html";
        provide(__FILE__);
        require( path_rel(__FILE__, "../"+M+"gram.sl"));

With these constructions I think implementing and trying different
modes and scripts gets even more easier.

And maybe more people will actually try new modes and other Jed
enhancements, leading to even more enhancements. :)
        
        
Klaus

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