From: Martin Alsinet <martin@alsinet.com.ar>
To: "Johan W. Klüwer" <johan.w.kluwer@gmail.com>, emacs-orgmode@gnu.org
Subject: Re: org-babel source block unevaluated into variable?
Date: Wed, 25 Oct 2017 15:52:43 +0000 [thread overview]
Message-ID: <CABUJmkBXEMvicbTGBR5cot1QZjOtKwHCz0sk-FxCJ2PLx78boQ@mail.gmail.com> (raw)
In-Reply-To: <CABUJmkDjtJ2n=e+FEaNOkEo2RRL3GNT3Yyw2sAdLXZhjLTq5Kg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1511 bytes --]
Johan:
To use expanded noweb references you can use text source blocks
#+NAME: lscode
#+BEGIN_SRC *text*
ls -alh
#+END_SRC
#+NAME: example
#+BEGIN_SRC sh :noweb yes
echo <<lscode>>
#+END_SRC
#+RESULTS: example
: ls -alh
#+BEGIN_SRC emacs-lisp :var code=example
(message code)
#+END_SRC
#+RESULTS:
: ls -alh
Martín
On Wed, Oct 25, 2017 at 10:36 AM Martin Alsinet <martin@alsinet.com.ar>
wrote:
> Johan:
>
> You can try the following:
>
> #+NAME: lscode
> #+BEGIN_ASCII
> ls -alh
> #+END_ASCII
>
> #+BEGIN_SRC emacs-lisp :var code=lscode
> (message code)
> #+END_SRC
>
> #+RESULTS:
> : ls -alh
>
> I haven't tried the noweb references, but it does return the code block in
> the variable.
>
>
> Martín
>
> On Wed, Oct 25, 2017 at 9:22 AM Johan W. Klüwer <johan.w.kluwer@gmail.com>
> wrote:
>
>> Is there a way to assign the uninterpreted content of an executable
>> source block to a variable? Preferably, using a :var header argument? That
>> is, return the text in the block, not the result of evaluating it, and
>> preferably with noweb references expanded.
>>
>> "example" blocks return text the way I want, but they can't be evaluated,
>> and of course noweb is ruled out for them.
>>
>> The function org-babel-ref-resolve could to the job if there were a
>> switch to block evaluation.
>>
>>
>> Why this is interesting: I wish to use url-hexify-string on the text of a
>> named SPARQL query.
>>
>> Cheers, Johan
>>
>
[-- Attachment #2: Type: text/html, Size: 3825 bytes --]
next prev parent reply other threads:[~2017-10-25 15:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-25 14:21 org-babel source block unevaluated into variable? Johan W. Klüwer
2017-10-25 15:36 ` Martin Alsinet
2017-10-25 15:52 ` Martin Alsinet [this message]
2017-10-26 11:17 ` Johan W. Klüwer
2017-10-26 12:02 ` Johan W. Klüwer
2017-10-26 12:06 ` Martin Alsinet
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=CABUJmkBXEMvicbTGBR5cot1QZjOtKwHCz0sk-FxCJ2PLx78boQ@mail.gmail.com \
--to=martin@alsinet.com.ar \
--cc=emacs-orgmode@gnu.org \
--cc=johan.w.kluwer@gmail.com \
/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).