emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ken Mankoff <mankoff@gmail.com>
To: Org-mode <emacs-orgmode@gnu.org>
Subject: [O] Injecting properties with noweb
Date: Mon, 20 Feb 2023 08:07:57 -0800	[thread overview]
Message-ID: <87ilfwpbfm.fsf@t480.home> (raw)

Hello,

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:

* Setup
:SETTINGS:
:FOO: default
:BAR: one
:header-args:screen+: :cmd /bin/bash :session (org-macro--get-property "FOO" "")
:END:

#+NAME: setup
#+BEGIN_SRC screen
if [[ ! $(hostname) =~ "host"* ]]; then ssh host; fi
<<inject_vars>>
# eval <<inject_vars>> ??
echo $FOO
#+END_SRC

Should print out "one" (the default setting under Setup) in the screen terminal.

** OTHER
:PROPERTIES:
:FOO: two
:END:

#+BEGIN_SRC screen
<<setup>>
#+END_SRC

Should print out "two" (the sub-heding adjusted property) in the screen terminal.


I'm OK with not being able to inject arbitrary variables, only the ~10 or so that I need to be able to set, and having a code block that has these 10 hard-coded on the LHS, but with some <<noweb>> or something on the RHS so that they value of the variable can be controlled using PROPERTIES under headings (better yet, header-args, but I don't think that is possible).  

That's the behavior I'm after, but am having trouble. I thought something like:

#+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

#+BEGIN_SRC screen
<<setup>>
echo $FOO
#+END_SRC

might work, but it's just printing nil.


Thanks for any suggestions,

  -k.


             reply	other threads:[~2023-02-20 16:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-20 16:07 Ken Mankoff [this message]
2023-04-08 12:22 ` [O] Injecting properties with noweb Ihor Radchenko
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=87ilfwpbfm.fsf@t480.home \
    --to=mankoff@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).