* Adding #+name to result block in babel
@ 2022-11-29 1:10 Henrik Frisk
2022-11-29 5:19 ` Bill Burdick
0 siblings, 1 reply; 4+ messages in thread
From: Henrik Frisk @ 2022-11-29 1:10 UTC (permalink / raw)
To: org-mode-email
[-- Attachment #1: Type: text/plain, Size: 227 bytes --]
Hi,
Maybe I'm missing something obvious but is it possible to have a name be
added to the result block such as running:
#+begin_src shell
echo "Hello"
#+end_src
results in
#+RESULTS:
#+name: my_result
: Hello
Thank you!
[-- Attachment #2: Type: text/html, Size: 437 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Adding #+name to result block in babel
2022-11-29 1:10 Adding #+name to result block in babel Henrik Frisk
@ 2022-11-29 5:19 ` Bill Burdick
2022-11-29 22:13 ` Henrik Frisk
0 siblings, 1 reply; 4+ messages in thread
From: Bill Burdick @ 2022-11-29 5:19 UTC (permalink / raw)
To: Henrik Frisk; +Cc: org-mode-email
[-- Attachment #1: Type: text/plain, Size: 738 bytes --]
Hi Henrik,
On Tue, Nov 29, 2022 at 2:11 AM Henrik Frisk <frisk.h@gmail.com> wrote:
> Hi,
>
> Maybe I'm missing something obvious but is it possible to have a name be
> added to the result block such as running:
>
> #+begin_src shell
> echo "Hello"
> #+end_src
>
> results in
>
> #+RESULTS:
> #+name: my_result
> : Hello
>
> Thank you!
>
Name your block, like this:
#+name: my_result
#+begin_src sh
echo hello
#+end_src
When you evaluate it, you'll get this:
#+name: my_result
#+begin_src sh
echo hello
#+end_src
#+RESULTS: my_result
: hello
Then you can use the result like this:
#+begin_src sh :var value=my_result
echo $value
#+end_src
#+RESULTS:
: hello
-- Bill
[-- Attachment #2: Type: text/html, Size: 1390 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Adding #+name to result block in babel
2022-11-29 5:19 ` Bill Burdick
@ 2022-11-29 22:13 ` Henrik Frisk
2022-12-04 12:25 ` Johan Tolö
0 siblings, 1 reply; 4+ messages in thread
From: Henrik Frisk @ 2022-11-29 22:13 UTC (permalink / raw)
To: Bill Burdick; +Cc: org-mode-email
[-- Attachment #1: Type: text/plain, Size: 1314 bytes --]
Den tis 29 nov. 2022 kl 06:20 skrev Bill Burdick <bill.burdick@gmail.com>:
> Hi Henrik,
>
> On Tue, Nov 29, 2022 at 2:11 AM Henrik Frisk <frisk.h@gmail.com> wrote:
>
>> Hi,
>>
>> Maybe I'm missing something obvious but is it possible to have a name be
>> added to the result block such as running:
>>
>> #+begin_src shell
>> echo "Hello"
>> #+end_src
>>
>> results in
>>
>> #+RESULTS:
>> #+name: my_result
>> : Hello
>>
>> Thank you!
>>
>
> Name your block, like this:
> #+name: my_result
> #+begin_src sh
> echo hello
> #+end_src
>
> When you evaluate it, you'll get this:
>
> #+name: my_result
> #+begin_src sh
> echo hello
> #+end_src
>
> #+RESULTS: my_result
> : hello
>
> Then you can use the result like this:
>
> #+begin_src sh :var value=my_result
> echo $value
> #+end_src
>
> #+RESULTS:
> : hello
>
Thank you! That was good to be reminded of, but I should have been more
explicit in my first email. I'm working with a language (sclang) that for
various reasons does not have support for variables in this way. The only
option I have to include the results from one block is by using a noweb
referens:
#+begin_src shell
echo "Hello"
#+end_src
#+RESULTS:
#+name: my_result
: Hello
#+begin_src sclang :noweb yes
<<my_result>>
#+end_src
[-- Attachment #2: Type: text/html, Size: 2404 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Adding #+name to result block in babel
2022-11-29 22:13 ` Henrik Frisk
@ 2022-12-04 12:25 ` Johan Tolö
0 siblings, 0 replies; 4+ messages in thread
From: Johan Tolö @ 2022-12-04 12:25 UTC (permalink / raw)
To: Henrik Frisk; +Cc: Bill Burdick, emacs-orgmode
Henrik Frisk <frisk.h@gmail.com> writes:
[snipped]
>> Then you can use the result like this:
>>
>> #+begin_src sh :var value=my_result
>> echo $value
>> #+end_src
>>
>> #+RESULTS:
>> : hello
>>
This does not use the result but rather reevaluates the
"my_result" code block.
> Thank you! That was good to be reminded of, but I should have
> been more explicit in my first email. I'm working with a
> language (sclang)
> that for various reasons does not have support for variables in
> this way. The only option I have to include the results from one
> block is by
> using a noweb referens:
>
> #+begin_src shell
> echo "Hello"
> #+end_src
>
> #+RESULTS:
> #+name: my_result
> : Hello
>
> #+begin_src sclang :noweb yes
> <<my_result>>
> #+end_src
You could try adapting the examples for using :post at the end of:
https://orgmode.org/manual/Results-of-Evaluation.html
But in my (limited) experience it is difficult to get the output
right.
Another suggestion is to use a templating system for generating
the src block and include the #+name: part in the template. I use
yasnippet for this.
--
Johan Tolö
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-12-04 12:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-29 1:10 Adding #+name to result block in babel Henrik Frisk
2022-11-29 5:19 ` Bill Burdick
2022-11-29 22:13 ` Henrik Frisk
2022-12-04 12:25 ` Johan Tolö
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).