From mboxrd@z Thu Jan 1 00:00:00 1970 From: Martin Alsinet Subject: Re: org-babel source block unevaluated into variable? Date: Wed, 25 Oct 2017 15:52:43 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a114422bc781d00055c610cd4" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7NzI-0005aD-JE for emacs-orgmode@gnu.org; Wed, 25 Oct 2017 11:53:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7NzD-0007C6-Sh for emacs-orgmode@gnu.org; Wed, 25 Oct 2017 11:53:00 -0400 Received: from mail-wm0-f44.google.com ([74.125.82.44]:53668) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7NzD-0007Aw-Hs for emacs-orgmode@gnu.org; Wed, 25 Oct 2017 11:52:55 -0400 Received: by mail-wm0-f44.google.com with SMTP id r196so2887383wmf.2 for ; Wed, 25 Oct 2017 08:52:55 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: =?UTF-8?Q?Johan_W=2E_Kl=C3=BCwer?= , emacs-orgmode@gnu.org --001a114422bc781d00055c610cd4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 <> #+END_SRC #+RESULTS: example : ls -alh #+BEGIN_SRC emacs-lisp :var code=3Dexample (message code) #+END_SRC #+RESULTS: : ls -alh Mart=C3=ADn On Wed, Oct 25, 2017 at 10:36 AM Martin Alsinet wrote: > Johan: > > You can try the following: > > #+NAME: lscode > #+BEGIN_ASCII > ls -alh > #+END_ASCII > > #+BEGIN_SRC emacs-lisp :var code=3Dlscode > (message code) > #+END_SRC > > #+RESULTS: > : ls -alh > > I haven't tried the noweb references, but it does return the code block i= n > the variable. > > > Mart=C3=ADn > > On Wed, Oct 25, 2017 at 9:22 AM Johan W. Kl=C3=BCwer > wrote: > >> Is there a way to assign the uninterpreted content of an executable >> source block to a variable? Preferably, using a :var header argument? Th= at >> 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 >> > --001a114422bc781d00055c610cd4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Johan:

To use expanded noweb refe= rences you can use text source blocks

#+NAME: l= scode
#+BEGIN_SRC t= ext
ls -alh=
#+END_SRC
<= br>

#+NAME: example
#+BEGIN_SRC sh :noweb yes
echo <<lscode>>
#+END_SRC

#+RESULTS: example
: ls -alh

<= /font>

= #+BEGIN_SRC emacs-lisp :var code=3Dexam= ple
(message code)
#+END_SRC

#+RESULTS:
: ls -alh


Ma= rt=C3=ADn

On Wed= , Oct 25, 2017 at 10:36 AM Martin Alsinet <martin@alsinet.com.ar> wrote:
Johan:

You can try the fo= llowing:

= #+NAME: lscode
#+BEGIN= _ASCII
ls -alh<= /div>
#+END_ASCII
=
#+BEGIN_SRC emacs-lisp := var code=3Dlscode
(mes= sage code)
#+END_SRC

<= font face=3D"monospace" size=3D"2">#+RESULTS:
: ls -alh

I haven't tried the noweb references, but it doe= s return the code block in the variable.


Mart=C3=ADn

On Wed, Oct 25, 2017 at 9:22 AM Johan W. Kl=C3=BCwer <johan.w.kluwer@gmail.com&= gt; wrote:
Is= there a way to assign the uninterpreted content of an executable source bl= ock to a variable? Preferably, using a :var header argument? That is, retur= n the text in the block, not the result of evaluating it, and preferably wi= th noweb references expanded.

"example&qu= ot; blocks return text the way I want, but they can't be evaluated, and= of course noweb is ruled out for them.

The fu= nction org-babel-ref-resolve could to the job if there were a switch to blo= ck evaluation.


Why this is inte= resting: I wish to use url-hexify-string on the text of a named SPARQL quer= y.

Cheers, Johan
--001a114422bc781d00055c610cd4--