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

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

Re: Problem when run-hook-with-args with closure


From: Zhongwei Yao
Subject: Re: Problem when run-hook-with-args with closure
Date: Mon, 22 Dec 2014 19:20:49 +0800

Hi, Stefan,
Thanks, it works!

Best Regards,
Zhongwei

On Fri, Dec 19, 2014 at 10:11 PM, Stefan Monnier <monnier@iro.umontreal.ca>
wrote:

> >   (setq foo
> >         (lambda (y)
> >           (message "x+y=%d" (+ x y)))))
> > (run-hook-with-args 'foo 1)
>
> Hooks should contain *lists* of functions.  The fact that they can also
> just contain a function is an old backward compatibility hack: better
> not rely on it.
>
> So, if you do it right, you won't hit the bug:
>
>      (setq foo
>            (list (lambda (y)
>                    (message "x+y=%d" (+ x y))))))
>    (run-hook-with-args 'foo 1)
>
> Or better yet:
>
>      (add-hook 'foo
>                (lambda (y)
>                    (message "x+y=%d" (+ x y))))))
>    (run-hook-with-args 'foo 1)
>
>
> -- Stefan
>
>
>


reply via email to

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