From: Ken Mankoff <mankoff@gmail.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Max Nikulin <manikulin@gmail.com>, emacs-orgmode@gnu.org
Subject: Re: [PATCH] lisp/ob-screen.el: Support ~:var~ header args for babel blocks
Date: Thu, 16 Mar 2023 00:12:26 -0400 [thread overview]
Message-ID: <874jqluyfp.fsf@t480.home> (raw)
In-Reply-To: <87a60yxec3.fsf@localhost>
Hi Ihor and Max,
Just a follow-up note that I am unlikely to be able to complete this patch anytime soon. Re-alignment of priorities because my need for :var header support in Org Babel is mitigated by a different method of injecting variables into Org Babel sections: Use noweb.
I find this more powerful than =:var=. The examples below show (1) setting a bash environment variable in screen, or (2) printing from a Python prompt after sshing to a remote computer. It is language agnostic. Because it uses PROPERTIES and not :var, it also lets me work in Org Column View mode.
* Header
:PROPERTIES:
:foo: 42
:END:
#+NAME: ex1-screen-bash
#+BEGIN_SRC screen
export foo="<<get_property("foo")>>"
#+END_SRC
#+NAME: ex2-ssh-python
#+BEGIN_SRC bash
ssh somewhere
python
print("<<get_property("foo")>>")
#+END_SRC
#+CALL: ex2-ssh-python()
#+RESULTS:
: foo
The relevant section from my library-of-babel is:
* Properties into header args
:PROPERTIES:
:hellomessage: hello
:END:
https://emacs.stackexchange.com/questions/41922/
#+NAME: get_property
#+BEGIN_SRC emacs-lisp :var prop_name="" :results silent
(org-with-point-at org-babel-current-src-block-location
(org-entry-get nil prop_name t))
#+END_SRC
** Example Usage
*** Header arg
#+HEADER: :var prop_message=(org-entry-get nil "hellomessage" t)
#+BEGIN_SRC emacs-lisp
(message prop_message)
#+END_SRC
#+RESULTS:
: hello
*** Noweb
#+BEGIN_SRC emacs-lisp :noweb yes
(message "<<get_property("hellomessage")>>")
#+END_SRC
#+RESULTS:
: hello
#+BEGIN_SRC bash :noweb yes :results verbatim
echo "<<get_property("hellomessage")>>"
#+END_SRC
#+RESULTS:
: hello
If hope this helps someone if they need it.
-k.
next prev parent reply other threads:[~2023-03-16 4:13 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-24 17:03 [PATCH] lisp/ob-screen.el: Support ~:var~ header args for babel blocks Ken Mankoff
2023-02-24 18:33 ` Ken Mankoff
2023-02-25 3:51 ` Max Nikulin
2023-02-25 15:14 ` Ken Mankoff
2023-02-25 15:19 ` Ken Mankoff
2023-02-25 16:05 ` Max Nikulin
2023-02-25 16:47 ` Ken Mankoff
2023-02-26 10:11 ` Max Nikulin
2023-02-27 1:59 ` Ken Mankoff
2023-02-28 10:40 ` Ihor Radchenko
2023-03-16 4:12 ` Ken Mankoff [this message]
2023-03-16 10:22 ` Ihor Radchenko
2023-03-16 15:09 ` [PATCH v4] " Max Nikulin
2023-03-17 11:41 ` Max Nikulin
2023-03-18 12:08 ` Ihor Radchenko
2023-03-19 14:42 ` Ken Mankoff
2023-03-21 14:12 ` Max Nikulin
2023-03-02 13:38 ` [PATCH] " Max Nikulin
2023-02-26 12:18 ` Ihor Radchenko
2023-02-27 1:59 ` Ken Mankoff
2023-02-27 19:43 ` Ihor Radchenko
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=874jqluyfp.fsf@t480.home \
--to=mankoff@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=manikulin@gmail.com \
--cc=yantar92@posteo.net \
/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).