0

Is there a way to link to an orgmode variable's value? Or at least export it?

I can get a link to jump to the variable definition, but not display its value or export.

for example the text in testmesage below should read: "and I'm like wut ever"

I'm trying to insert live data into a document without turning the whole thing in a src block and using :var.

* huh
#+BEGIN_SRC shell
echo "wut ever"
#+END_SRC
#+NAME: ww
#+RESULTS:
: wut ever

* testmessage
and I'm like [[ww]]
#+END_SRC
1
  • I'm looking for something like this as well. Possibly more in the form of a constant that could be viewed in two forms 1) the value and 2) the substitution variable (like your [[ww]]. I'd want to toggle between the two modes perhaps.
    – lucidquiet
    Feb 5 at 20:14

1 Answer 1

0

Maybe you are looking for inline evaluation of code blocks? Name your code block with #+name: ww and then use and I'm like call_foo(). Like this:

* huh
#+NAME: ww
#+BEGIN_SRC shell
echo "wut ever"
#+END_SRC
#+NAME: ww
#+RESULTS:
: wut ever

* testmessage
and I'm like call_ww()
#+END_SRC

You can execute the inline code block by pressing C-c C-c on it and it will have its result appended after the call in the buffer:

 ... and I'm like call_foo() {{{results(=wut evah=)}}}

That's a verbatim wut evah: you can customize the format a bit using the variable org-babel-inline-result-wrap'. The built-in Org macro results just returns its argument unchanged, but you can also redefine that if you want to do something different: Org mode's middle name is flexibility :-). But note that the doc cautions against that:

Moreover, inline source blocks (see *note Structure of Code Blocks::) use the special ‘results’ macro to mark their output. As such, you are advised against re-defining it, unless you know what you are doing.

In any case, exporting the document (I would tag the huh section as :noexport: so it does not appear in the exported output) produces what you want, I think.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.