emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] org-babel source block unevaluated into variable?


From: Johan W . Klüwer
Subject: Re: [O] org-babel source block unevaluated into variable?
Date: Thu, 26 Oct 2017 13:17:55 +0200

Thanks Martin,

These are good suggestions, but it's not quite what I am after. In your second example, I would like ":var code=example" to make "code" carry the full (and expanded) text of the "example" block, i.e. to have

  echo ls -alh

as the result -- the code itself, unevaluated.

Johan

2017-10-25 17:52 GMT+02:00 Martin Alsinet <address@hidden>:
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 <address@hidden> 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 <address@hidden> 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


reply via email to

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