all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tassilo Horn <tassilo@member.fsf.org>
To: help-gnu-emacs@gnu.org
Subject: Re: why alias man to woman doesn't work?
Date: Thu, 05 Apr 2012 12:52:14 +0200	[thread overview]
Message-ID: <8762deqwm9.fsf@thinkpad.tsdh.de> (raw)
In-Reply-To: 80k41u4ohg.fsf@somewhere.org

"Sebastien Vauban"
<wxhgmqzgwmuf@spammotel.com> writes:

Hi Sebastien,

> Do I understand correctly that the above code will load `woman' when
> being parsed, while:
>
>      (eval-after-load "woman" '(defalias 'man 'woman))
>
> would wait until woman was invoked by some other command?

Not until woman was invoked, but until woman.el is loaded.  You can also
write

  (eval-after-load 'woman '(...))

which would evaluate the quoted form after the feature woman has been
provided.  Usually, (provide 'foo) is the last form in a file foo.el, so
in most cases both are equivalent.

> If yes, for performance reasons, one should prefer the latter writing,
> in order to have a quicker startup time of Emacs, right?

Nobody *should*, but it's a possibly way to speed up emacs startup time.
For example, all customizations for programming modes need not be done
until you visit a file of that language.

I have a small macro for that, because I always forget that the form
given to eval-after-load has to be quoted and to have an implicit progn.

--8<---------------cut here---------------start------------->8---
(defmacro th-defer-eval (feature &rest forms)
  "Defer evaluation of FORMS after FEATURE has been provided.
A shorthand for

  (eval-after-load 'FEATURE
     '(progn
	FORMS))

used like

  (th-defer-eval foobar
    (do-this-after-loading-foobar)
    (do-that-after-loading-foobar))"
  (declare (indent defun))
  `(eval-after-load (quote ,feature)
     '(progn
	,@forms)))
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo




  reply	other threads:[~2012-04-05 10:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-04 23:50 why alias man to woman doesn't work? Xah Lee
2012-04-05  1:28 ` Stefan Monnier
2012-04-05  7:02   ` Xah Lee
2012-04-05  7:38   ` Sebastien Vauban
2012-04-05 10:52     ` Tassilo Horn [this message]
2012-04-05 13:02     ` Doug Lewan
2012-04-05 14:19     ` Stefan Monnier
2012-04-05 14:38       ` Sebastien Vauban
2012-04-06 21:28   ` Xah Lee
2012-04-10  2:39     ` Stefan Monnier

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=8762deqwm9.fsf@thinkpad.tsdh.de \
    --to=tassilo@member.fsf.org \
    --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.