I am searching for a piece of emacs-lisp code that checks if an emacs-babel block finished its execution.

I am trying to write smth like

(while (babel-block not finished its execution)
       (sleep-for 0.1))

(do smth)

Thank you in advance.

I will maybe try to be more specific to foster the understanding.

I have the following piece of code for executing a babel block after the cursor.

(defun execute-after-cursor ()
  "Execute the block up until after the cursor"
  (let* ((el (org-element-context))
       (p (point))
       (language (org-element-property :language el))
       (switches (org-element-property :switches el))
       (parameters (org-element-property :parameters el)))

      (insert (format "\n#+END_SRC
                     ,#+BEGIN_SRC %s %s %s\n" language (or switches "") (or parameters ""))))

    (previous-line 3)
    (kill-line 3)

The issue is now that when I execute the above in EIN; I do not get the results displayed. I noticed that if I put a time (sleep-for 1) it works. I guess that EIN binds the results to the named babel block and if emacs deletes the name of the cell before EIN finishes the execution works but the results do not show.

Hope this gives you a better intuition of why I need the piece of code above.

  • Perhaps (sleep-for 0.1) before execute it and then execute it? – zixuan Apr 10 at 16:21
  • @zixuan; thank you for your answer. I made the problem more explicit. maybe it helps – mhass Apr 11 at 6:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.