astahlman / ob-async

Asynchronous src_block execution for org-babel
343 stars 32 forks source link

fix ob-async does not work with ob-ref (#73) #76

Closed f4nyc closed 3 years ago

f4nyc commented 3 years ago

Add org-babel-async-content to pass current buffer

astahlman commented 3 years ago

@f4nyc clever, and thanks for the contribution! Mind adding a unit test to prevent regressions?

A single test that execute an :async block and uses a ref should suffice. Here's a sort-of similar test for inspiration:

https://github.com/astahlman/ob-async/blob/de1cd6c93242a4cb8773bbe115b7be3d4dd6b97e/test/ob-async-test.el#L325-L350

astahlman commented 3 years ago

@f4nyc looks good, thanks for the contribution!

noorul commented 3 years ago

@f4nyc Is this working for you? With the following example,

#+begin_src sh :async
sleep 3s && echo "Done!"
#+end_src

I get

error in process sentinel: async-handle-result: Symbol’s function definition is void: org-babel-execute:sh
error in process sentinel: Symbol’s function definition is void: org-babel-execute:sh
#+begin_src emacs-lisp
(functionp 'org-babel-execute:sh)
#+end_src

#+RESULTS:
: t
f4nyc commented 3 years ago

@noorul Yes, the commit has passed CI tests which also includes this case. Could you execute this

#+begin_src emacs-lisp :async
(functionp 'org-babel-execute:sh)
#+end_src
noorul commented 3 years ago

For the above snippet, I get the following:

async-handle-result: Symbol’s function definition is void: org-babel-execute:emacs-lisp
spacebat commented 3 years ago

@astahlman I ran into the same problem as @noorul but only after switching from an emacsforosx build of emacs 27 to a windows machine running emacs 26.3 under WSL2. I found a solution last night, by editing ob-async-org-babel-execute-src-block in ob-aync.el to add the following forms after ,(async-inject-variables ob-async-inject-variables):

                      (package-initialize)
                      (org-babel-do-load-languages
                       'org-babel-load-languages
                       '((emacs-lisp . t)
                         (shell . t)
                         (perl . t)
                         (python . t)
                         (ruby . t)
                         (restclient . t)
                         (sql . t)))
noorul commented 3 years ago

@spacebat Thank you for the hint. Looks like delayed evaluation of (use-package ob-async) has made it work for me.