Go to the first, previous, next, last section, table of contents.


Autoloading

Obviously, not all the features of the editor are always used. Autoloading allows modules to be loaded when they are referenced. This speeds up the initialisation process and may save memory.

Functions which may be autoloaded have a special form in their symbol's function cell -- an autoload form. This is a list whose first element is the symbol autoload. When the function call dispatcher finds one of these forms it loads the program file specified in the form then re-evaluates the function call. The true function definition will have been loaded and therefore the call may proceed as normal.

The structure of an autoload form is:

(autoload program-file [is-command])

program-file is the argument to give to the load function when the function is to be loaded. It should be the program containing a definition of the autoloaded function.

The optional is-command object specifies whether or not the function may be called interactively (i.e. it is an editor command).

Function: autoload symbol &rest autoload-defn
Installs an autoload form into the function cell of the symbol symbol. The form is a cons cell whose car is autoload and whose cdr is the argument autoload-defn.

Returns the resulting autoload form.

(autoload 'foo "foos-file")
    => (autoload "foos-file")
(symbol-function 'foo)
    => (autoload "foos-file")

(autoload 'bar "bars-file" t)
    => (autoload "bars-file" t)
(commandp 'bar)
    => t

It is not necessary to call the autoload function manually. Simply prefix the definitions of all the functions which may be autoloaded (i.e. the entry points to your module; not all the internal functions!) with the magic comment ;;;###autoload. Then the add-autoloads command can be used to create the necessary calls to the autoload function in the `autoloads.jl' Lisp file (this file which lives in the Lisp library directory is loaded when the editor is initialised).

Meta-x add-autoloads
Scans the current buffer for any autoload definitions. Functions with the comment ;;;###autoload preceding them have autoload forms inserted into the `autoloads.jl' file. Simply save this file's buffer and the new autoloads will be used the next time Jade is initialised. It is also possible to mark arbitrary forms for inclusion in the `autoloads.jl' file: put them on a single line which starts with the comment ;;;###autoload call the command. The unsaved `autoloads.jl' buffer will become the current buffer.
;;;###autoload
(defun foo (bar)                ;foo is to be autoloaded
  ...

;;;###autoload (setq x y)       ;Form to eval on initialisation
Meta-x remove-autoloads
Remove all autoload forms from the `autoloads.jl' file which are marked by the ;;;###autoload comment in the current buffer. The unsaved `autoloads.jl' buffer will become the current buffer.


Go to the first, previous, next, last section, table of contents.