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:36:42 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="f403045f58c8271f44055c60d371" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Njo-0004wy-DF for emacs-orgmode@gnu.org; Wed, 25 Oct 2017 11:37:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7Nji-0008U3-DN for emacs-orgmode@gnu.org; Wed, 25 Oct 2017 11:37:00 -0400 Received: from mail-wr0-f174.google.com ([209.85.128.174]:43218) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7Nji-0008Ro-6M for emacs-orgmode@gnu.org; Wed, 25 Oct 2017 11:36:54 -0400 Received: by mail-wr0-f174.google.com with SMTP id w105so432457wrc.0 for ; Wed, 25 Oct 2017 08:36:53 -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 --f403045f58c8271f44055c60d371 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 in 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 sourc= e > 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 switc= h > to block evaluation. > > > Why this is interesting: I wish to use url-hexify-string on the text of a > named SPARQL query. > > Cheers, Johan > --f403045f58c8271f44055c60d371 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Johan:

You can try the following:
=

#+NAME: lscode=
#+BEGIN_ASCII<= /div>
ls -alh
#+END_ASCII

#+BEGIN_SRC emacs-lisp :var code=3Dlsc= ode
(message code)
#+END_SRC

#+RESULTS:
: ls -alh

I haven't tried the noweb references, but it does return the cod= e block in the variable.


Mart=C3=AD= n

On Wed, Oct 25= , 2017 at 9:22 AM Johan W. Kl=C3=BCwer <johan.w.kluwer@gmail.com> wrote:
Is there a way to assign the uninter= preted content of an executable source block to a variable? Preferably, usi= ng a :var header argument? That is, return the text in the block, not the r= esult of evaluating it, and preferably with noweb references expanded.
<= /div>

"example" blocks return text the way I w= ant, 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.

<= /div>

Why this is interesting: I wish to use url-hexify-= string on the text of a named SPARQL query.

Cheers= , Johan
--f403045f58c8271f44055c60d371--