From: Sebastian Tennant <sebyte@smolny.plus.com>
To: help-gnu-emacs@gnu.org
Subject: Re: An alternative to a monolithic ~/.emacs init file
Date: Fri, 09 Nov 2007 16:18:17 +0200 [thread overview]
Message-ID: <873avf8pue.fsf@moley.moleskin.org> (raw)
In-Reply-To: 1194544126.425679.261670@e9g2000prf.googlegroups.com
Quoth rustom <rustompmody@gmail.com>:
> Thanks. I think I understand autoload. Also I dont want needless
> loading at emacs-startup -- its unlikely that in a given session I
> will do C and python and ruby and org and tramp and elisp and .....
> though I do use all these once in a while. What I dont understand are
> magic cookies and how emacs uses them; or more correctly *When* emacs
> uses them. The elisp manual says:
>
> "These comments do nothing on their own, but they serve as a guide for
> the command `update-file-autoloads', which constructs calls to
> 'autoload' and arranges to execute them when Emacs is built."
> Does this mean I have to rebuild emacs if I want to use this ?!
First of all, autoloads exist precisely for the reason you've stated;
avoiding needless loading of functions at startup. Consider the
function 'foo' defined in bar.el. If your ~/.emacs includes the line
(autoload 'foo "bar.el" "My function foo" t)
then Emacs knows where to find the function definition, if and when you
type the command 'M-x foo'. The function itself is not loaded until you
call it, (the autoload call means Emacs is simply aware of the name of
the function, and the file where it is found), thus saving memory
resources and reducing startup time. A better name than 'autoload'
might be:
'load-later'
or,
'dont-load-until-needed-but-heres-where-to-find-it-anyway'
I agree the explanation in the manual is unclear/inadequate. You
certainly don't have to rebuild Emacs! update-file-autoloads is called
when emacs is rebuilt, yes, but there's nothing to stop you calling
update-file-autoloads yourself. It works by parsing a file and
constructing autoload calls (like the one above) based on occurrences of
magic cookies (;;;###autoload) in elisp code. The constructed autoload
calls are then written to a file named according to the value of the
variable generated-autoload-file.
update-directory-autoloads works in exactly the same way, but on all the
files within a directory. So,
(let ((generated-autoload-file "~/elisp/dotemacs/auto-autoloads.el"))
(update-directory-autoloads "~/elisp/lib/"))
works by temporarily binding the value of generated-autoload-file so
that autoload calls based on magic cookies found within files in
~/elisp/lib are written to a file within ~/elisp/dotemacs.
As for loaddefs.el, this is the equivalent of auto-autoloads.el above.
It is a file full of autoload calls created by the update-file-autoloads
function. There are no less than six loaddefs.el on my machine but the
main one (/usr/share/emacs/22.1/lisp/loaddefs.el) is some 33,000 lines
long and I have no doubt it was generated once at build time, but is
loaded every time at startup, making all those functions available to
me, but not actually loading any of them until they're needed.
Perhaps someone else could confirm that this is the case.
Sebastian
next prev parent reply other threads:[~2007-11-09 14:18 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.2759.1193756709.18990.help-gnu-emacs@gnu.org>
2007-11-07 17:13 ` An alternative to a monolithic ~/.emacs init file rustom
2007-11-08 13:08 ` Sebastian Tennant
[not found] ` <mailman.3126.1194527313.18990.help-gnu-emacs@gnu.org>
2007-11-08 19:53 ` rustom
2007-11-09 14:18 ` Sebastian Tennant [this message]
[not found] ` <mailman.3180.1194617919.18990.help-gnu-emacs@gnu.org>
2007-11-10 12:18 ` rustom
2007-11-10 17:13 ` Tom Tromey
[not found] ` <mailman.3247.1194750639.18990.help-gnu-emacs@gnu.org>
2007-11-11 15:29 ` rustom
2007-11-12 21:56 ` Tim X
2007-11-13 4:21 ` rustom
2007-11-13 9:26 ` Tim X
2007-11-14 3:52 ` rustom
2007-11-13 1:22 ` rustom
2007-11-11 0:09 ` Francisco Miguel Colaço
2007-10-30 15:04 Sebastian Tennant
2007-10-30 20:30 ` Sebastian Tennant
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=873avf8pue.fsf@moley.moleskin.org \
--to=sebyte@smolny.plus.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.