emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] org-trigger-hook and org-babel-execute-subtree


From: Fabio Leimgruber
Subject: [O] org-trigger-hook and org-babel-execute-subtree
Date: Sun, 04 Sep 2016 12:56:43 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (darwin)

Hello all,

I am trying to evaluate source blocks under certain heading when their
TODO state changes.  This is what I have so far to test it:

#+BEGIN_SRC emacs-lisp
(defun my-run-babel-on-todo (plist)
  "When TODO state changes, run all source blocks below heading"
  (let* ((element (org-element-at-point))
         (babel-p (org-element-property :TRIGGER_BABEL element)))
    (when babel-p
      (princ "This gets run alright, but not the next one")
      (org-babel-execute-subtree))))
#+END_SRC

#+BEGIN_SRC emacs-lisp
(add-hook 'org-trigger-hook 'my-run-babel-on-todo)
#+END_SRC

* TODO test
:PROPERTIES:
:TRIGGER_BABEL: t
:END:

#+BEGIN_SRC calc
  1 + 1
#+END_SRC

As hinted at in the (princ ...), org-babel-execute-subtree is not run.
Am I missing something?


Best Regards,
Fabio Leimgruber

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]