emacs-async
emacs-async copied to clipboard
Async-wait: selecting deleted buffer
The documentation for async-start says:
Note: Even when FINISH-FUNC is present, a future is still
returned except that it yields no value (since the value is
passed to FINISH-FUNC). Call ‘async-get’ on such a future always
returns nil. It can still be useful, however, as an argument to
‘async-ready’ or ‘async-wait’.
But I'm finding some errors when this is the case. As minimal examples:
(async-wait
(async-start
(lambda () (message "hello"))
'ignore))
and
(async-wait
(async-start
(lambda () (message "hello"))
(lambda (result) (message "this %s" result))))
Both return the error selecting deleted buffer.
Sorry for late reply.
Seems like the docstring of async-start is wrong or at least confusing.
async-wait is not really meant to be use alone, AFAIU it is an internal function which should be renamed with internal prefix i.e async--wait.
What you want to use here, I guess is async-get, which is meant to be used on a FUTURE (the result of an async-start call) called with a nil callback, e.g
(async-get
(async-start
(lambda () (message "hello") )
nil))
And perhaps there is a bug here when it returns error "selecting deleted buffer" with a call like this:
(async-get
(async-start
(lambda () (message "hello") )
'ignore))
@jwiegley WDYT
And I am wrong about async-wait which should not be internal as I said above, it is useful to as its name say to wait the FUTURE is ready to send its result:
(let ((proc (async-start
(lambda () (message "hello")))))
(async-wait proc)
(async-get proc))
@jwiegley can you clarify about async-wait usage ? Perhaps an example in the test file ?