From: Jeremie Juste <jeremiejuste@gmail.com>
To: stardiviner <numbchild@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: [Share] collect some idea about auto eval code when TAB expand headline
Date: Fri, 16 Oct 2020 22:45:17 +0200 [thread overview]
Message-ID: <87y2k599ya.fsf@gmail.com> (raw)
In-Reply-To: <5f892a7b.1c69fb81.c0551.2f2e@mx.google.com> (stardiviner's message of "Fri, 16 Oct 2020 13:01:21 +0800")
Hello,
I don't see very clearly how you want to use the code.
(It might well be because of my lack of skills)
Could you give a usage example?
Best regards,
Jeremie
On Friday, 16 Oct 2020 at 13:01, stardiviner wrote:
> I write an elisp config for Org Mode to auto evaluate inline source block in property "EVAL".
>
> #+begin_src emacs-lisp
> (defcustom org-property-eval-keywords-list '("EVAL")
> "A list of property keywords for evaluate code."
> :type 'list
> :safe #'listp
> :group 'org)
>
> (defun org-property-eval-code (&optional state)
> "Evaluate Org inline source block in property value."
> (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)
> ;; ob-async: `org-babel-execute-src-block:async'
> (org-babel-execute-src-block nil src-block-info)))))))
>
> (add-hook 'org-cycle-hook #'org-property-eval-code)
> #+end_src
>
> A question:
>
> How to get all property keywords under headline? I want to use ~member~ to detect
> whether property keywords has member in defined custom list
> ~org-property-eval-keywords-list~.
>
> Second question:
>
> Do you have any good idea or suggest about this?
>
> Thanks for sharing your idea.
next prev parent reply other threads:[~2020-10-16 20:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-16 5:01 [Share] collect some idea about auto eval code when TAB expand headline stardiviner
2020-10-16 20:45 ` Jeremie Juste [this message]
2020-10-17 0:55 ` stardiviner
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
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=87y2k599ya.fsf@gmail.com \
--to=jeremiejuste@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=numbchild@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
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).