[Top][All Lists]

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

Re: [PATCH] lisp/ob-screen.el: Support ~:var~ header args for babel bloc

From: Ken Mankoff
Subject: Re: [PATCH] lisp/ob-screen.el: Support ~:var~ header args for babel blocks
Date: Thu, 16 Mar 2023 00:12:26 -0400
User-agent: mu4e 1.8.13; emacs 27.1

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
:foo: 42

#+NAME: ex1-screen-bash
#+BEGIN_SRC screen
export foo="<<get_property("foo")>>"

#+NAME: ex2-ssh-python
#+BEGIN_SRC bash
ssh somewhere

#+CALL: ex2-ssh-python()

: foo

The relevant section from my library-of-babel is:

* Properties into header args
:hellomessage: hello


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

** Example Usage

*** Header arg

#+HEADER: :var prop_message=(org-entry-get nil "hellomessage" t)
#+BEGIN_SRC emacs-lisp
  (message prop_message)

: hello

*** Noweb
#+BEGIN_SRC emacs-lisp :noweb yes
  (message "<<get_property("hellomessage")>>")

: hello

#+BEGIN_SRC bash :noweb yes :results verbatim
echo "<<get_property("hellomessage")>>"

: hello

If hope this helps someone if they need it.


reply via email to

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