How can I pass a stringvariable in to this function, so
that instead of printing "This is a test",
it prints "This is a value-of-variable"
(async-start
;; What to do in the child process
(lambda ()
(message "This is a test")
(sleep-for 3)
222)
;; What to do when it finishes
(lambda (result)
(message "Async process done, result should be 222: %s" result)))
Update: I tried the answer suggested by @Tobias. Didn't work. Here's my code
;; ~/prelude/personal.el
(eval-after-load 'elfeed-search
'(define-key elfeed-search-mode-map "d" #'my/baa))
;; comment
(defun my/baa ()
(interactive )
(let ((var "value-of-variable"))
;;(message "here %s" (format-time-string "%d/%m/%Y %H:%M:%S" (current-time)))
(async-start
;; What to do in the child process
(lambda ()
(message "This is a %s" var)
(sleep-for 2)
var)
;; What to do when it finishes
(lambda (result)
(message "%s Async process done, result should be 222: %s" (format-time-string "%d/%m/%Y %H:%M:%S" (current-time)) result))))
(next-line)
))
To test it, I would place point/cursor on a elfeed RSS feed item,
and press letter d. I see in the minibuffer:
error in process sentinel: Symbol’s value as variable is void: var
By the way, as you can see, I suck at elisp indentation. How can I tell emacs to fix the indentation of the above code block.
Here's some background on what I'm trying to achieve. I have a RSS feed that has a steady steam of new articles. The feed lacks some key information. Let's say the feed is about companies listed in NYSE, and I would like to see the current stock price of the feed item. Since this info is available via the web via a seperate curl call, my solution is to bind letter "d" to an elisp function "my/baa". This function is non blocking. It is passed a reference to the currently selected elfeed item. When the (async) function returns, it prepends the stock price value to the line in the elfeed-search mode buffer. I can hold down the d key press, and this will trigger a bunch of async's to fetch multiple http requests to get multiple stock quotes. this is non blocking. when the function returns, the display will get updated. each finish of an async function will trigger a redraw of the elfeed-search buffer.