Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make sure (current-buffer) is not #<killed buffer> #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

make sure (current-buffer) is not #<killed buffer> #70

wants to merge 1 commit into from

Conversation

stardiviner
Copy link
Contributor

When ob-async execute source block in a temp buffer with with-temp-buffer.
Like this:

(with-temp-buffer
(insert "<source block>")
(goto-char (point-min))
(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)
                   ;; ob-async: `org-babel-execute-src-block:async'
                   (org-babel-execute-src-block nil src-block-info)))

I use this implement extension to auto evaluate org inline source block which defined in org property named "EVAL" like this:

*** 《春风十里,不如你》 Spring Breeze Ten Miles 2017
    :PROPERTIES:
    :EVAL:     src_sh{mpv ~/Org/Beauty/周冬雨/春风十里不如你/《春风十里不如你》虐心片段\ 心疼小红把七年青春都给了秋水.flv}
    :END:

@stardiviner
Copy link
Contributor Author

Seems the CI build check timeout?

@stardiviner
Copy link
Contributor Author

stardiviner commented Oct 25, 2020

This patch seems break ob-async function. Somebody have any idea to improve it?

@stardiviner
Copy link
Contributor Author

Gentle ping ...

@spacebat
Copy link

spacebat commented Nov 12, 2020

Hi, I've only just started looking at this repository, and it's not entirely clear to me what you're trying to do with this commit - I've taken the with-temp-buffer example, changed the "< source block >" string so it actually calls a subprocess, but don't run into any errors. Can you give clearer instructions to reproduce the problem you're seeing?

@stardiviner
Copy link
Contributor Author

stardiviner commented Nov 12, 2020

Here is my config code try to auto execute Org Mode "EVAL" property's value.

;;; auto evaluate inline source block in property "EVAL".

(defcustom org-property-eval-keywords-list '("EVAL")
  "A list of property keywords for evaluate code."
  :type 'list
  :safe #'listp
  :group 'org)

(dolist (prop org-property-eval-keywords-list)
  (add-to-list 'org-default-properties prop))

(defun org-property-eval-code (&optional state)
  "Evaluate Org inline source block in property value."
  (when (memq state '(children subtree))
    ;; TODO: detect property keywords in `org-property-eval-keywords-list'.
    ;; (require 'seq nil t)
    ;; (seq-intersection ... org-property-eval-keywords-list)
    (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)
              (org-babel-execute-src-block nil nil src-block-info))))))) ; <----- HERE

(add-hook 'org-cycle-hook #'org-property-eval-code)

Here is the "EVAL" property value looks like:

*** Spring Breeze Ten Miles 2017
    :PROPERTIES:
    :EVAL:     src_sh{mpv "/path/to/a/media/music.mp3"}
    :END:

My Org startup is all folded. So when I put point on this header, and press [TAB] to expand it, with my upper config, Emacs will use ob-async to auto play it. After play music command exit, it will raise warning message:

error in process sentinel: save-current-buffer: Selecting deleted buffer
error in process sentinel: Selecting deleted buffer

@stardiviner
Copy link
Contributor Author

stardiviner commented Jan 10, 2021

I force pushed commit which really fixed my issue, no error message error in process sentinel: save-current-buffer: Selecting deleted buffer now.

@astahlman, can you review my PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants