From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Johan_W=2E_Kl=C3=BCwer?= Subject: Re: org-babel source block unevaluated into variable? Date: Thu, 26 Oct 2017 13:17:55 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a1144c42eefd94b055c7152a5" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:32890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7gAf-0006Ni-Vv for emacs-orgmode@gnu.org; Thu, 26 Oct 2017 07:17:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7gAe-00078y-Nr for emacs-orgmode@gnu.org; Thu, 26 Oct 2017 07:17:57 -0400 Received: from mail-qk0-x22c.google.com ([2607:f8b0:400d:c09::22c]:45576) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7gAe-00078g-In for emacs-orgmode@gnu.org; Thu, 26 Oct 2017 07:17:56 -0400 Received: by mail-qk0-x22c.google.com with SMTP id f199so3752044qke.2 for ; Thu, 26 Oct 2017 04:17:56 -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: Martin Alsinet Cc: emacs-orgmode@gnu.org --001a1144c42eefd94b055c7152a5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks Martin, These are good suggestions, but it's not quite what I am after. In your second example, I would like ":var code=3Dexample" 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 : > 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 >> 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 >>> source block to a variable? Preferably, using a :var header argument? T= hat >>> 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 >>> >> --001a1144c42eefd94b055c7152a5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks Martin,

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

=C2=A0 echo ls -alh

as the result -- the code itself, unevaluated.

= Johan

20= 17-10-25 17:52 GMT+02:00 Martin Alsinet <martin@alsinet.com.ar>= :
Johan:

To use expanded noweb references you can use text source b= locks

#+NAME: lscode
#+BEGIN_SRC text
ls -alh
#+END_SRC


#+NAME: example
#+BEG= IN_SRC sh :noweb yes
e= cho <<lscode>>
#+END_SRC

#+RESULTS: example
: ls -alh
=

#+BEGIN_SRC emacs-lisp :var code=3Dexample
<= div>(message code)
#+END_SRC

#+RESULTS:
: ls -a= lh


Mart=C3=ADn<= /div>

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=3Dlscode<= /div>
(message code)
#+END_SRC

#+RESULTS:
:= ls -alh

I ha= ven'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 <johan.w.kluwer@gmail.com> wrote:
Is there a way to assign the = uninterpreted content of an executable source block to a variable? Preferab= ly, using a :var header argument? That is, return the text in the block, no= t the result of evaluating it, and preferably with noweb references expande= d.

"example" blocks return text the = way I want, but they can't be evaluated, and of course noweb is ruled o= ut for them.

The function org-babel-ref-resolv= e 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

--001a1144c42eefd94b055c7152a5--