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

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

Re: why alias man to woman doesn't work?


From: Tassilo Horn
Subject: Re: why alias man to woman doesn't work?
Date: Thu, 05 Apr 2012 12:52:14 +0200
User-agent: Gnus/5.130004 (Ma Gnus v0.4) Emacs/24.0.95 (gnu/linux)

"Sebastien Vauban"
<address@hidden> 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 via email to

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