emacs-wiki-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [emacs-wiki-discuss] Re: Autoloads


From: drkm
Subject: RE: [emacs-wiki-discuss] Re: Autoloads
Date: Wed, 23 Nov 2005 22:54:34 +0100 (CET)

Michael Olson wrote:

> I'm not familiar with ;;;###autoload cookies, but I'd
> gladly accept a patch to add them to Muse.

  The idea is very simple (I'll simplify in this explanation, but the
idea is almost that).  An autoload is a special kind of function.  You
can create an autoload with the 'autoload' function:

    (autoload 'func "file" "Doc string" t)

  The first argument is the function to define (whose define an
autoload).  The second one is the file name where this function is
effectively define (the real function).  the third, optional argument
is the doc string associated.  If nil, no doc string is available until
effectively loaded the library.  And the last one is a boolean, to say
if 'func' is interactive or not.

  This creates an autoload.  Fine.  But what's an autoload?  As said,
it's a kind of function.  You can call it.  for example by 'M-x' if
it's a command, or in any Lisp code.  All that does this function is to
load the library whose the file name was given as second argument to
'autoload', that is, the library where is effectively defined the
function.

  So you call the function (just an autoload at this time).  Then the
library is loaded.  The effective function must be defined while
loading the library.  At the end, the effective function (freshly
loaded) is called.

  What's the intrest?  As a library writer, you can maintain a file,
consisting only of several 'autoloads', definind autoloads for the main
entry points of the file of your library.

  This file says: func-1 is defined in file-1, func-a too, func-2 in
file-2, etc.  This file is typically far shorter than the whole
library.

  In your INSTALL file, you just say to the user: "All you need to do
is put the library somewhere in your 'load-path', and loading the
autoloads file" (for example by name, or better via the features
system, that is, by 'require').  This is simple to do, small to load,
and we can safelly use the main functions, they will be loaded when
needed.

  But wait.  Mainting such a file is not so hard, but, mmh, yes, it's
hard (at least boring).  As a library writer, you can use the
";;;###autoload" cookie.  Just put it on the first column, on lines
just preceding each 'defun' you want generate an autoload for.  Command
exists that scan all ELisp files in a directory and write for you the
autoloads file, based on these cookie.

  Personaly, I use a CEDET library to do that, wrapped in a shell
script, but Emacs has all you need out of the box.

  Adding the cookies themself is not a hard coding task.  But the one
that do that have to know very well the library.  It's the very hard
part of autoloads: selecting the function (often commands) to generate
an autoload for.

  I hope it's a little more clear.  Sorry for my bad English if all is
not very clear.

  Regards,

--drkm






















        

        
                
___________________________________________________________________________ 
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger 
Téléchargez cette version sur http://fr.messenger.yahoo.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]