jed-users mailing list

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

Re: require or evalfile or autoload?


On Tue, Mar 09, 2004 at 01:55:08PM -0800, Dave Kuhlman wrote:
> Could someone explain the difference between using require(),
> evalfile(), or autoload() to load a .sl file for a mode. 


() = evalfile(file)
   Load and evaluate a file containing slang code. Return success

   The php-equivelent would be 'include(file)'

require(feature, file=feature)
   Load and evaluate a slang file, if this has not been done already.
   Returns nothing.

   It does something like   
      !if (_featurep (feature))
        () = evalfile (file);
   with _featurep being set by the 'provide(feature)' command in file.

   The php-equivelent would be 'include_once(file)'
   
autoload(fun, file)
    Declare `fun' to the interpreter.
    Indicate that it should be loaded from `file' when
    it is actually used.

    ==> The first call to fun will trigger an ()=evalfile(file), 
    i.e. all slang code in file will be executed at this point.

> I could not find anything on this in the documentation.

Well, autoload() and evalfile() are documented in the online-help. For
require(), you need to have a look at its definition in site.sl (line
1086).


> I ask because I was using require, but then I discovered that it wipes
> out the key bindings from my .jedrc.  When I switched to using
> autoload(), it leaves my key bindings from .jedrc intact.

Strange. Are the bindings in the *scratch* buffer (or any buffer in
no-mode) intact as well?  

This only way I can imagine this working is, that with autoload() you
will overwrite the 'Global' keymap after creation of a mode keymap
(text-mode or slang-mode, say). 
 

Generally:

  * do not load an emulation other than the one you want to use.
    (or if there is no other way, load it *before* the one you want to
    use)
    (BTW: this is why I 'outsourced' cuamisc.sl from cua.sl)
    
  * Remember, that jed will overwrite your keybindings with
    emacs-bindings if you did not load an "standards-complying" emulation
    (i.e. one that sets the undocumented variable _Jed_Emulation
     ==> let your homebrew-emulation set _Jed_Emulation)

  * Normal modes should never-ever change keybindings in the
    global map when "evalfiled". (Or at least provide a custom_variable
    to give you the chance to prevent that.)

    (Of course there are extemptions: wmark is one example where a mode
    is intended to add keybindings to global.)

    Complain about every mode that violates this rule.
    (The jed-wiki at http://www.jedsoft.org/wiki/wiki.pl?HomePage
     is a good point for that (as well as this list)).


Günter

-- 
G.Milde at web.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>.


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