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

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

Re: How to delay loading of packages (when eval-after-load does notapply


From: Raffaele Ricciardi
Subject: Re: How to delay loading of packages (when eval-after-load does notapply)?
Date: Fri, 17 Aug 2012 11:31:44 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120713 Thunderbird/14.0

On 08/17/2012 11:07 AM, Sebastien Vauban wrote:
> Hi Drew,
>
> "Drew Adams" wrote:
>>> How could I say: load fuzzy when I will make a search for the
>>> first time?
>>
>> Try `isearch-mode-hook' with `require'.
>
> Did you mean this?
>
> --8<---------------cut here---------------start------------->8---
>    ;; fuzzy matching utilities (a must-have)
>    (add-hook 'isearch-mode-hook
>              #'(lambda ()
>                  (require 'fuzzy)))
>
>    (eval-after-load "fuzzy"
>      (turn-on-fuzzy-isearch))
> --8<---------------cut here---------------end--------------->8---
>
> I did the above, restarted Emacs and got:
>
>    Symbol's function definition is void: turn-on-fuzzy-isearch
>
> I don't understand why my `eval-after-load' is executed directly...
>
> Am I missing something?

You have to quote the form you are passing to `eval-after-load', like this:

(eval-after-load "fuzzy"
  '(turn-on-fuzzy-isearch))

Otherwise, yes, the form is evaluated on the spot. This one bit me a couple of
times as well ;-)

Also, "fuzzy" means eval the following form after the library "fuzzy" has been loaded, whilst 'fuzzy means eval the following code after the feature 'fuzzy has
been provided.  I always go for the latter first, because then I'm able to
rename a library according to its version.  I would only backpedal if the
library provided its feature on top of the file as some third-party libraries do - AFAIK this was a workaround for older Emacsen - and I couldn't fix that, but
the latter has never happened.

>
> Best regards,
>    Seb
>
> PS- BTW, is there a better choice to be made between
>
> --8<---------------cut here---------------start------------->8---
>    (add-hook 'isearch-mode-hook
>              #'(lambda () ...
> --8<---------------cut here---------------end--------------->8---
>
> and
>
> --8<---------------cut here---------------start------------->8---
>    (add-hook 'isearch-mode-hook
>              (lambda () ...
> --8<---------------cut here---------------end--------------->8---
>
> ?
>

AFAIK, they mean the same thing. I always use the latter, for I think `lambda'
is verbose enough already ;-)



reply via email to

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