* Referring to an Org Babel variable in the invocation arguments to another Org Babel code block
@ 2016-12-27 13:02 Zack Piper
2016-12-27 17:56 ` Charles C. Berry
0 siblings, 1 reply; 7+ messages in thread
From: Zack Piper @ 2016-12-27 13:02 UTC (permalink / raw)
To: emacs-orgmode
Hi all,
Hopefully the below can explain better:
#+NAME: abc
#+BEGIN_SRC shell :noweb yes :var a="b" :results output
echo <<EOF
$a
1
EOF
#+END_SRC
#+NAME: def
#+BEGIN_SRC shell :noweb yes :var c="d" :results output
echo <<EOF
<<abc(c)>>
1
EOF
#+END_SRC
#+RESULTS: def
:
Pressing `C-c C-c' on the second block returns:
org-babel-ref-resolve: Reference ‘c’ not found in this buffer
Org version: 9.0.3
Thanks!
--
Zack Piper System administrator
https://apertron.net
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Referring to an Org Babel variable in the invocation arguments to another Org Babel code block
2016-12-27 13:02 Referring to an Org Babel variable in the invocation arguments to another Org Babel code block Zack Piper
@ 2016-12-27 17:56 ` Charles C. Berry
2016-12-27 18:17 ` Zack Piper
0 siblings, 1 reply; 7+ messages in thread
From: Charles C. Berry @ 2016-12-27 17:56 UTC (permalink / raw)
To: Zack Piper; +Cc: emacs-orgmode
On Tue, 27 Dec 2016, Zack Piper wrote:
> Hi all,
>
> Hopefully the below can explain better:
[deleted]
This is a workable idiom. C-c C-c on the second block produces the
output shown.
#+NAME: block-1
#+BEGIN_SRC shell :var x="X"
echo ">>>" $x "<<<"
#+END_SRC
#+BEGIN_SRC shell :var y=block-1("input to this block")
echo $y
#+END_SRC
#+RESULTS:
: >>> input to this block <<<
HTH,
Chuck
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Referring to an Org Babel variable in the invocation arguments to another Org Babel code block
2016-12-27 17:56 ` Charles C. Berry
@ 2016-12-27 18:17 ` Zack Piper
2016-12-28 23:36 ` Zack Piper
2016-12-29 15:49 ` Nicolas Goaziou
0 siblings, 2 replies; 7+ messages in thread
From: Zack Piper @ 2016-12-27 18:17 UTC (permalink / raw)
To: Charles C. Berry; +Cc: Zack Piper, emacs-orgmode
Hi Charles,
I think I found precisely the issue I'm having.
When I use your example, and adjust it slightly:
#+NAME: block-1
#+BEGIN_SRC shell :var x="X"
echo ">>>" $x "<<<"
#+END_SRC
#+BEGIN_SRC shell :var c="test" y=block-1(c)
echo $y
#+END_SRC
#+RESULTS:
: >>> $c <<<
I added a reference to an argument defined within the same block.
I get the aforementioned error:
org-babel-ref-resolve: Reference ‘c’ not found in this buffer
Thanks!
Zack
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Referring to an Org Babel variable in the invocation arguments to another Org Babel code block
2016-12-27 18:17 ` Zack Piper
@ 2016-12-28 23:36 ` Zack Piper
2016-12-29 15:49 ` Nicolas Goaziou
1 sibling, 0 replies; 7+ messages in thread
From: Zack Piper @ 2016-12-28 23:36 UTC (permalink / raw)
To: Zack Piper; +Cc: emacs-orgmode
Hi all,
Still struggling with this, does anyone have any ideas?
Thanks!
--
Zack Piper System administrator
https://apertron.net
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Referring to an Org Babel variable in the invocation arguments to another Org Babel code block
2016-12-27 18:17 ` Zack Piper
2016-12-28 23:36 ` Zack Piper
@ 2016-12-29 15:49 ` Nicolas Goaziou
2017-01-01 16:15 ` Zack Piper
1 sibling, 1 reply; 7+ messages in thread
From: Nicolas Goaziou @ 2016-12-29 15:49 UTC (permalink / raw)
To: Zack Piper; +Cc: emacs-orgmode, Charles C. Berry
Hello,
Zack Piper <zack@apertron.net> writes:
> When I use your example, and adjust it slightly:
>
> #+NAME: block-1
> #+BEGIN_SRC shell :var x="X"
>
> echo ">>>" $x "<<<" #+END_SRC
>
> #+BEGIN_SRC shell :var c="test" y=block-1(c)
> echo $y
> #+END_SRC
>
> #+RESULTS:
> : >>> $c <<<
ITYM
y=block-1("c")
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Referring to an Org Babel variable in the invocation arguments to another Org Babel code block
2016-12-29 15:49 ` Nicolas Goaziou
@ 2017-01-01 16:15 ` Zack Piper
2017-01-01 18:51 ` Charles C. Berry
0 siblings, 1 reply; 7+ messages in thread
From: Zack Piper @ 2017-01-01 16:15 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 690 bytes --]
Hi Nicolas,
I tried "c", and it gives me:
>>> c <<<
as the result.
I would like it to use the _variable_ "c", not the literal string.
So the result should be ">>> test <<<"
I've also cleaned up the Org I made (something went wrong when I pasted
it before, it missed an #+END_SRC)
Thanks!
#+NAME: block-1
#+BEGIN_SRC shell :var x="X"
echo ">>>" $x "<<<" #+END_SRC
#+END_SRC
#+BEGIN_SRC shell :var c="test" y=block-1("c")
echo $y
#+END_SRC
#+RESULTS:
: >>> c <<<
On 12/29/2016 03:49 PM, Nicolas Goaziou wrote:
>> #+NAME: block-1 #+BEGIN_SRC shell :var x="X" echo ">>>" $x "<<<"
>> #+END_SRC #+BEGIN_SRC shell :var c="test" y=block-1(c) echo $y
>> #+END_SRC #+RESULTS: : >>> $c <<<
[-- Attachment #2: Type: text/html, Size: 1431 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Referring to an Org Babel variable in the invocation arguments to another Org Babel code block
2017-01-01 16:15 ` Zack Piper
@ 2017-01-01 18:51 ` Charles C. Berry
0 siblings, 0 replies; 7+ messages in thread
From: Charles C. Berry @ 2017-01-01 18:51 UTC (permalink / raw)
To: Zack Piper; +Cc: emacs-orgmode
On Sun, 1 Jan 2017, Zack Piper wrote:
> Hi Nicolas,
> I tried "c", and it gives me:
>
>>>> c <<<
>
> as the result.
>
> I would like it to use the _variable_ "c", not the literal string.
> So the result should be ">>> test <<<"
>
You mean you want to use the `name' of one `:var name=assign' argument
in the `assign' part of another --- something like what `let*' does in
lisp.
But you simply cannot do that.
`(info "(org) var")' tells us what you can do:
#+BEGIN_QUOTE
The following syntax is used to pass arguments to `src' code blocks
using the `:var' header argument.
:var name=assign
The `assign' is a literal value, such as a string `"string"', a number
`9', a reference to a table, a list, a literal example, another code
block (with or without arguments), or the results from evaluating a
code block.
#+END_QUOTE
The `name' of one argument is none of these (regardless of its effect when
the body of the src block is executed, which BTW depends on the src block
language).
There are other approaches that might serve a purpose in babel src blocks
like that served by `let*' in lisp:
- putting variables in a table (possibly invoking `org-sbe' in a
formula) and then referencing table cells
- writing other src blocks to handle the preliminary processing and
referncing them
- writing an elisp src block that does those preliminaries (perhaps
using `org-babel-ref-resolve' to call other src blocks), then builds
a string specifying a call to your shell src block and calls it
using `org-babel-ref-resolve'.
- using a noweb reference that executes another src block (or blocks).
- setting property values and referencing them
You might have better luck getting guidance on a useful approach by
trying to describe what you want to accomplish.
HTH,
Chuck
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-01-01 18:51 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-27 13:02 Referring to an Org Babel variable in the invocation arguments to another Org Babel code block Zack Piper
2016-12-27 17:56 ` Charles C. Berry
2016-12-27 18:17 ` Zack Piper
2016-12-28 23:36 ` Zack Piper
2016-12-29 15:49 ` Nicolas Goaziou
2017-01-01 16:15 ` Zack Piper
2017-01-01 18:51 ` Charles C. Berry
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.