From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Anselm Helbig Newsgroups: gmane.emacs.help Subject: Re: Autoload plus extra configurations Date: Tue, 19 May 2009 08:39:19 +0200 Organization: Freie Universitaet Berlin Message-ID: <87ljotfvfs.wl%anselm.helbig+news2009@googlemail.com> References: <87skj18va2.fsf@kobe.laptop> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Trace: ger.gmane.org 1242718854 8394 80.91.229.12 (19 May 2009 07:40:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 19 May 2009 07:40:54 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue May 19 09:40:47 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1M6JwM-0000O8-T7 for geh-help-gnu-emacs@m.gmane.org; Tue, 19 May 2009 09:40:47 +0200 Original-Received: from localhost ([127.0.0.1]:60948 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M6JwH-0000Tw-2G for geh-help-gnu-emacs@m.gmane.org; Tue, 19 May 2009 03:40:41 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!newsserver.news.garr.it!fu-berlin.de!uni-berlin.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 60 Original-X-Trace: news.uni-berlin.de HYMbopwFJGV/vtXA6dPwggi9SuFhyGJJC08olaGCKMM9XJ36sVpk19NXpn Cancel-Lock: sha1:eUlXo1rsJ1rJHzxhMDpZVHHKL4c= In-Reply-To: <87skj18va2.fsf@kobe.laptop> Mail-Followup-To: anselm.helbig+news2009@googlemail.com User-Agent: SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?ISO-8859-4?Q?Shij=F2?=) APEL/10.7 Emacs/22.3 (i686-pc-linux-gnu) MULE/5.0 (SAKAKI) Original-Xref: news.stanford.edu gnu.emacs.help:169312 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:64563 Archived-At: 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