jed-users mailing list

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

Re: General questions about using 3rd party jed modes


On 14 Nov 2002 11:36:31 -0500 wrote Duncan Mak <duncan@xxxxxxxxxx>:

> About modes in jed, I have a few questions:
> 
> a) How do I install a mode? 

  1. Put it somewhere in your library path. (if you have just 1 or 2 more
     modes, it might be easiest to put them in jeds "standard-library" 
     (where all the *.sl files are). (Especially for window or DOS users,
    or course this will not work for non-root user on Unix-type systems.)
     
  2. Read the leading part of the mode file -- it will normally give you 
     instructions on how to make jed aware of it's presence.
     
     Normally you should put in your .jedrc one or some 
            autoload("<fun>", "<mode>");
     commands and eventually also a
            add_mode_for_extension("<mode>", "<ext>");. 
     If the mode is to be read in at startup, use
            require("<mode>");
     or 
            !if (BATCH)
               require("<mode>");
     instead.
     
  3. Customize it: Look at the source and search for 
         custom_variable("<name>", <value>);
     definitions and if you want to set them to another value do
         variable <name> = <value>;
     in your .jedrc.
     Also, most modes offer a mode-hook: if you define a <mode>_hook
     function, this will be run every time the mode the mode is called.
     E.g. to define some additional keybindings in <mode>, write in your
     .jedrc
        define <mode>_hook()
        {
           local_setkey("<cmd>", Key_Foo);
           ...
           message("foo is not bar");
        }

> How do I set where my "mode" path is?

     In the .jedrc use the function

        set_jed_library_path("<mode-dir>" + ","+ get_jed_library_path());
  
     to have the privat mode-dir read in first. (Then you can also copy
     standard modes there, if you want/need to modify them.)


> Once that is set, do I just put require(<mode name>) in my .jedrc? 

     In general, yes. 
     
     Exception: if the filename is not <modename>.sl, it must be given as
     second argument. This allowes also the use of require for files that
     are not in the library path: 
        
         require("<modename>", "<path-to-mode-file>"); 
         
     works for both, absolute paths as well as paths relative to one of the
     jed_library_path directories.


> I realized home-lib.sl [The script "home-lib.sl" at
> http://jedmodes.sf.net] does what I want, but how do I install home-lib.sl
> itself?
  

   * I symlinked it to $JED_ROOT/lib/defaults.sl, so it is read 
     automatically at startup.
     This allowes me to move .jedrc into the .jed/ directory.
     
   * Another option would be to have a 
        require("home-lib", "FULL_PATH_TO_HOME-LIB/home-lib.sl") 
     in your .jedrc. 
     
   * If you put home-lib.sl in the standard library,
        require("home-lib") 
     suffices.


Remark: On Unix, home-lib.sl sets up also a site-wide library, defaulting to
        path_concat(JED_ROOT, "/site-lib") or the environment variable
        JED_SITE_LIB. I am still looking for a better default.

The 2. step (making jed aware of your modes) can be automatized with
the script "make-ini.sl" [at http://jedmodes.sf.net]

   make_ini.sl is a tool to set up non-standard extensions (modes and tools)
   for jed. It creates a buffer/file ini.sl that declares all (public)
   functions in the current directory. Also bytecompiles the files if set to
   do so. In combination with the Home-lib mode, this provides a nice way to
   maintain your user library of non-standard jed extensions.
   
   USAGE:
   M-x make_ini   to get a buffer with the autoload commands (and helpfull
                  comments) for viewing/editing and subsequent saving.
   M-x update_ini to update the ini.sl file in the current buffers working
                  dir without user interaction.
   jed -batch -l make_ini.sl   to update the ini.sl file in the current
                               directory in a batch process.
                               
   The following convention facilitates the work of make_ini:
   
     +------------------------------------------------------------+
     | MODE-DESIGNERS CONVENTION (proposal by GM)                  |
     | Functions that should be accessible from outside the mode  |
     |  are defined using the keywords                                         |
     |        public define <fun>()                                  |
     | (Nonregarding of whether a namespace is declared or not.)  |
     +------------------------------------------------------------+
   
   With Make_ini_Scope == 1, make_ini will create autoload statemente for
   just these functions.
   
   (Remark: on jmr, the make-ini code is marked alpha. 
    However, it runs stable on my Linux box for more than half a year.
    I'd like to hear about Windoof or other systems.)
                       
                               
I run update_ini every time I wrote or downloaded a new mode and I use
the following snippet in my .jedrc to evaluate the produced ini.sl file:

       % initialize the functions in privat library
       variable home_ini = path_concat(Jed_Home_Library, "ini.sl");
       if (andelse {1 == file_status(home_ini)} { evalfile(home_ini)} )
           message(home_ini + " loaded");

              
have fun                               

Günter Milde

--
Milde at ife.et.tu-dresden.de


--------------------------
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]