emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [QUESTION] How to use `make-thread` to run org-babel-execute-src-block?
@ 2021-02-01  5:05 Christopher Miles
  0 siblings, 0 replies; only message in thread
From: Christopher Miles @ 2021-02-01  5:05 UTC (permalink / raw)
  To: Org Mode

[-- Attachment #1.1: Type: text/plain, Size: 1719 bytes --]

<#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)))
          (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
  :EVAL: src_sh{mpv "video.mp4"}

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.

[-- Attachment #1.2: Type: text/html, Size: 6491 bytes --]

[-- Attachment #2: ATT00001.txt --]
[-- Type: text/plain, Size: 253 bytes --]

[ 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-02-01  5:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-01  5:05 [QUESTION] How to use `make-thread` to run org-babel-execute-src-block? Christopher Miles

Code repositories for project(s) associated with this inbox:


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).