From: Ihor Radchenko <yantar92@posteo.net>
To: Ken Mankoff <mankoff@gmail.com>
Cc: Org-mode <emacs-orgmode@gnu.org>
Subject: Re: [O] Injecting properties with noweb
Date: Sat, 08 Apr 2023 12:22:19 +0000 [thread overview]
Message-ID: <87h6tqk1hg.fsf@localhost> (raw)
In-Reply-To: <87ilfwpbfm.fsf@t480.home>
Ken Mankoff <mankoff@gmail.com> writes:
> Is it possible to set variables using Org Babel inside screen, which does not support ":var" header args? I'd actually lke a double-nested screen over ssh, and the ability to re-use Babel code blocks under different headings, using header args or PROPERTIES to change variables. That is, something like:
Yes.
> ...
> #+NAME: get-prop
> #+BEGIN_SRC emacs-lisp :var prop="FOO" :noweb yes
> (org-macro--get-property prop "")
> #+END_SRC
>
> #+NAME: inject_vars
> #+BEGIN_SRC shell :noweb yes
> # echo <<get-prop(prop="FOO")>> # testing
> echo export FOO=<<get-prop(prop="FOO")>>
> echo export BAR=<<get-prop(prop="BAR")>>
> echo export BAZ=<<get-prop(prop="BAZ")>>
> #+END_SRC
This did not work as you expected because noweb evaluates code block
with point at that code block.
To get the property value at the code block where you expand noweb
reference, you need to compute the value in the arguments to the
reference. Something like
#+name: identity
#+begin_src elisp :var x=""
x
#+end_src
...
echo export FOO=<<identity(x=(org-macro--get-property prop "FOO"))
...
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
next prev parent reply other threads:[~2023-04-08 12:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-20 16:07 [O] Injecting properties with noweb Ken Mankoff
2023-04-08 12:22 ` Ihor Radchenko [this message]
2023-04-08 15:01 ` Ken Mankoff
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=87h6tqk1hg.fsf@localhost \
--to=yantar92@posteo.net \
--cc=emacs-orgmode@gnu.org \
--cc=mankoff@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).