The following lisp code demonstrates how the value of a variable var
can be injected into the lambda used as START-FUNC
in (async-start START-FUNC &optional FINISH-FUNC)
.
I changed the lambda START-FUNC
such that it returns a string modified with the value of the variable. Since the return value of START-FUNC
is printed by FINISH-FUNC
it is easier to check that the injection is successful.
(let ((var "value-of-variable"))
(async-start
;; What to do in the child process
`(lambda ()
(sleep-for 3)
,(format "This is a %s" var))
;; What to do when it finishes
(lambda (result)
(message "Async process done, result should be 222: %s"
result))))