help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Autoload plus extra configurations


From: Anselm Helbig
Subject: Re: Autoload plus extra configurations
Date: Tue, 19 May 2009 08:39:19 +0200
User-agent: SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.7 Emacs/22.3 (i686-pc-linux-gnu) MULE/5.0 (SAKAKI)

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


reply via email to

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