Subject: bug#30241: Emacs 26.0.91: "Generalized variables" are not defined.

From: Noam Postavsky <[email-masked]>
Date: Wed, 24 Jan 2018 15:49:03 -0500

On Wed, Jan 24, 2018 at 3:06 PM, Alan Mackenzie <[email-masked]> wrote:

>     (add-function :before sit-for (lambda () (acm-backtrace 5)))
>     (add-function :before 'sit-for (....))
>     (add-function :before #'sit-for (.....))
>     (add-function :before (symbol-function 'sit-for) (....))
>
> , and got nothing but unhelpful error messages back, such as
>
>     Symbol's value as variable is void: sit-for

Your last form works for me, but the lambda has to accept the same
arguments as sit-for.

(add-function :before (symbol-function 'sit-for)
          (lambda (&rest _) (acm-backtrace 5)))

I think advice-add would make more sense for that use case though.

(advice-add 'sit-for :before (lambda (&rest _) (acm-backtrace 5)))