* Autoload plus extra configurations
@ 2009-05-19 4:54 Eric
2009-05-19 6:24 ` Giorgos Keramidas
0 siblings, 1 reply; 4+ messages in thread
From: Eric @ 2009-05-19 4:54 UTC (permalink / raw)
To: help-gnu-emacs
I'm shifting a bunch of libraries to autoload in order to reduce load
times, and running into an issue with extra configuration for those
autoloaded libraries. Tramp, for instance, is enormous and slow and I
don't use it often. I want to autoload it, but I've also got some
extra configuration that accesses tramp-default-methods and tramp-set-
completion-fuction, which are unavailable until tramp is actually
loaded.
Is there a way that I can tuck these configurations inside a hook that
runs only when tramp is actually loaded, or otherwise delay the
evaluation of these configurations until the proper variables and
functions are available?
Thanks!
Eric
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Autoload plus extra configurations
2009-05-19 4:54 Autoload plus extra configurations Eric
@ 2009-05-19 6:24 ` Giorgos Keramidas
2009-05-19 6:39 ` Anselm Helbig
0 siblings, 1 reply; 4+ messages in thread
From: Giorgos Keramidas @ 2009-05-19 6:24 UTC (permalink / raw)
To: help-gnu-emacs
On Mon, 18 May 2009 21:54:27 -0700 (PDT), Eric <girzel@gmail.com> wrote:
> I'm shifting a bunch of libraries to autoload in order to reduce load
> times, and running into an issue with extra configuration for those
> autoloaded libraries. Tramp, for instance, is enormous and slow and I
> don't use it often. I want to autoload it, but I've also got some
> extra configuration that accesses tramp-default-methods and tramp-set-
> completion-fuction, which are unavailable until tramp is actually
> loaded.
>
> Is there a way that I can tuck these configurations inside a hook that
> runs only when tramp is actually loaded, or otherwise delay the
> evaluation of these configurations until the proper variables and
> functions are available?
I think tramp *is* autoloaded only at the last possible moment in recent
Emacs versions. At least it is autoloaded only when I try to open a
file URI that requires tramp here in Emacs 23.X.
Having said that, please have a look at `eval-after-load'.
For example, I load a separate lisp source file to configure emacs-w3m
in my `~/.emacs' file, but only after the "w3m" module is itself loaded:
(eval-after-load "w3m"
'(require 'keramida-w3m))
A similar Lisp form loads "keramida-erc.el" from my load-path, but only
when I explicitly load "erc" by invoking it:
(eval-after-load "erc"
'(require 'keramida-erc))
Yet another form loads my cc-mode customizations and hooks, but only
the first time I edit a file that triggers cc-mode to load:
(eval-after-load "cc-mode"
'(require 'keramida-cc-extra))
Note that the Lisp form passed to eval-after-load must be quoted! If
you don't quote it, Emacs will try to evaluate it at the same time
before the `eval-after-load' form, which is very unlikely to be the
intended result.
By lazy loading as many libraries and extensions as possible, the
startup time of Emacs on my laptop is almost a second:
$ time emacs-23.0.93 --batch \
--eval '(princ (format "%s\n" (replace-regexp-in-string "\n" "" (version))))'
GNU Emacs 23.0.93.1 (i386-unknown-freebsd8.0, GTK+ Version 2.16.1) of 2009-05-18 on kobe
0.974 real 0.412 user 0.562 sys
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Autoload plus extra configurations
2009-05-19 6:24 ` Giorgos Keramidas
@ 2009-05-19 6:39 ` Anselm Helbig
2009-05-19 7:27 ` Eric
0 siblings, 1 reply; 4+ messages in thread
From: Anselm Helbig @ 2009-05-19 6:39 UTC (permalink / raw)
To: help-gnu-emacs
Hi!
> > I'm shifting a bunch of libraries to autoload in order to reduce load
> > times, and running into an issue with extra configuration for those
> > autoloaded libraries. Tramp, for instance, is enormous and slow and I
> > don't use it often. I want to autoload it, but I've also got some
> > extra configuration that accesses tramp-default-methods and tramp-set-
> > completion-fuction, which are unavailable until tramp is actually
> > loaded.
> >
> > Is there a way that I can tuck these configurations inside a hook that
> > runs only when tramp is actually loaded, or otherwise delay the
> > evaluation of these configurations until the proper variables and
> > functions are available?
>
> I think tramp *is* autoloaded only at the last possible moment in recent
> Emacs versions. At least it is autoloaded only when I try to open a
> file URI that requires tramp here in Emacs 23.X.
>
> Having said that, please have a look at `eval-after-load'.
>
> For example, I load a separate lisp source file to configure emacs-w3m
> in my `~/.emacs' file, but only after the "w3m" module is itself loaded:
>
> (eval-after-load "w3m"
> '(require 'keramida-w3m))
>
> A similar Lisp form loads "keramida-erc.el" from my load-path, but only
> when I explicitly load "erc" by invoking it:
>
> (eval-after-load "erc"
> '(require 'keramida-erc))
>
> Yet another form loads my cc-mode customizations and hooks, but only
> the first time I edit a file that triggers cc-mode to load:
>
> (eval-after-load "cc-mode"
> '(require 'keramida-cc-extra))
>
> Note that the Lisp form passed to eval-after-load must be quoted! If
> you don't quote it, Emacs will try to evaluate it at the same time
> before the `eval-after-load' form, which is very unlikely to be the
> intended result.
Also note that if you've need to execute more than one form you will need a
progn around them, e.g.
(eval-after-load "erc"
'(progn
(erc-update-modules)
(erc-nickserv-identify-mode 'nick-change)))
HTH,
Anselm
--
Anselm Helbig
mailto:anselm.helbig+news2009@googlemail.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Autoload plus extra configurations
2009-05-19 6:39 ` Anselm Helbig
@ 2009-05-19 7:27 ` Eric
0 siblings, 0 replies; 4+ messages in thread
From: Eric @ 2009-05-19 7:27 UTC (permalink / raw)
To: help-gnu-emacs
On May 19, 2:39 pm, Anselm Helbig <anselm.helbig
+news2...@googlemail.com> wrote:
> Hi!
>
>
>
>
>
> > > I'm shifting a bunch of libraries to autoload in order to reduce load
> > > times, and running into an issue with extra configuration for those
> > > autoloaded libraries. Tramp, for instance, is enormous and slow and I
> > > don't use it often. I want to autoload it, but I've also got some
> > > extra configuration that accesses tramp-default-methods and tramp-set-
> > > completion-fuction, which are unavailable until tramp is actually
> > > loaded.
>
> > > Is there a way that I can tuck these configurations inside a hook that
> > > runs only when tramp is actually loaded, or otherwise delay the
> > > evaluation of these configurations until the proper variables and
> > > functions are available?
>
> > I think tramp *is* autoloaded only at the last possible moment in recent
> > Emacs versions. At least it is autoloaded only when I try to open a
> > file URI that requires tramp here in Emacs 23.X.
>
> > Having said that, please have a look at `eval-after-load'.
>
> > For example, I load a separate lisp source file to configure emacs-w3m
> > in my `~/.emacs' file, but only after the "w3m" module is itself loaded:
>
> > (eval-after-load "w3m"
> > '(require 'keramida-w3m))
>
> > A similar Lisp form loads "keramida-erc.el" from my load-path, but only
> > when I explicitly load "erc" by invoking it:
>
> > (eval-after-load "erc"
> > '(require 'keramida-erc))
>
> > Yet another form loads my cc-mode customizations and hooks, but only
> > the first time I edit a file that triggers cc-mode to load:
>
> > (eval-after-load "cc-mode"
> > '(require 'keramida-cc-extra))
>
> > Note that the Lisp form passed to eval-after-load must be quoted! If
> > you don't quote it, Emacs will try to evaluate it at the same time
> > before the `eval-after-load' form, which is very unlikely to be the
> > intended result.
>
> Also note that if you've need to execute more than one form you will need a
> progn around them, e.g.
>
> (eval-after-load "erc"
> '(progn
> (erc-update-modules)
> (erc-nickserv-identify-mode 'nick-change)))
Perfect! Thanks very much to you both, that's just what I was looking
for.
Eric
>
> HTH,
>
> Anselm
>
> --
> Anselm Helbig
> mailto:anselm.helbig+news2...@googlemail.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-05-19 7:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-19 4:54 Autoload plus extra configurations Eric
2009-05-19 6:24 ` Giorgos Keramidas
2009-05-19 6:39 ` Anselm Helbig
2009-05-19 7:27 ` Eric
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).