<#secure method=pgpmime mode=sign>

I have following code snippet config:

(defun org-property-eval-on-cycle-expand (&optional state)
  "Evaluate Org inline source block in property value on headline cycle expand."
  (when (memq state '(children subtree))
    (if-let ((inline-src-block (org-entry-get nil "EVAL" nil)))
        (with-temp-buffer
          (insert inline-src-block)
          (goto-char (point-min))
          (require 'ob-async nil t)
          (setq-local org-babel-default-inline-header-args
                      '((:results . "silent") (:async . t)))
          (let* ((context (org-element-context))
                 (src-block-info (org-babel-get-src-block-info nil context))
                 (type (org-element-type context)))
            (when (eq type 'inline-src-block)
              ;; TODO use `make-thread'
              ;; ob-async: advice `org-babel-execute-src-block:async' on 
‘org-babel-execute-src-block’
              (org-babel-execute-src-block nil src-block-info)))))))

(add-hook 'org-cycle-hook #'org-property-eval-on-cycle-expand)


I use upper config in bellowing case to auto play video when I expand headline.

* eval inline src code block
  :PROPERTIES:
  :EVAL: src_sh{mpv "video.mp4"}
  :END:



As upper code snippet marked TODO comment. Because I'm using ob-async. So the 
org-babel-execute-src-block is async by default with ob-async's advice. I want 
to get rip of it. Using make-thread, I tried to use (make-thread FUNCTION) (the 
FUNCTION is a wrapper of org-babel-execute-src-block) but it will block current 
Emacs instance. How to make it async without blocking current Emacs?

Hope someone can help me. Thank you in advance.
-- 
[ stardiviner ]
       I try to make every word tell the meaning that I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3

Reply via email to