emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Christopher Miles <numbchild@gmail.com>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: [QUESTION] How to use `make-thread` to run org-babel-execute-src-block?
Date: Mon, 1 Feb 2021 05:05:07 +0000	[thread overview]
Message-ID: <PAXPR08MB66402E470272F4D12C967A93A3B69@PAXPR08MB6640.eurprd08.prod.outlook.com> (raw)

[-- 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

                 reply	other threads:[~2021-02-01  5:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PAXPR08MB66402E470272F4D12C967A93A3B69@PAXPR08MB6640.eurprd08.prod.outlook.com \
    --to=numbchild@gmail.com \
    --cc=emacs-orgmode@gnu.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).