When executing the following I get an error:
(defun caller (func)
(url-retrieve "http://m0smith.freeshell.org/"
(lambda (status) (funcall func))))
(caller (lambda() (message "called")))
Result:
error in process filter: Symbol's value as variable is void: func
What is the best way to solve this problem? Basically I need to accept a callback from somewhere else, wrap it in another lambda and use that as the callback to url-retrieve.
If I change caller to
(defun caller (func)
(url-retrieve "http://m0smith.freeshell.org/"
`(lambda (status) (funcall ,func))))
it works. However, I cannot do this as func is being passed by flycheck and the macro expansion breaks it. To see the full context of what I am doing: https://gist.github.com/m0smith/b5961fda6afd71e82983
lexical-let
or setting variablelexical-binding
. Please make clear what the problem is with the not-shown "macro".FUNC
beyond thefuncall
then logically you do not need lexical binding here. There is nothing wrong with using it, but you do not need it, unless some code actually needs to make use of the variableFUNC
. If you do not need it (which is what it looks like, so far), then just replace its occurrence by its value, using backquote with comma.lexical-let
. The global variablelexical-binding
is available in Emacs 24.