emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sebastien Vauban" <sva-news-D0wtAvR13HarG/iDocfnWg@public.gmane.org>
To: emacs-orgmode-mXXj517/zsQ@public.gmane.org
Subject: Re: How do I specify the language for a :results code block
Date: Mon, 02 Dec 2013 12:27:41 +0100	[thread overview]
Message-ID: <8661r7ze4y.fsf@somewhere.org> (raw)
In-Reply-To: m2r49vfsc7.fsf@polytechnique.org

Alan Schmitt wrote:
> tsd-P0awH739Ni4AvxtiuMwx3w@public.gmane.org writes:
>> Alan Schmitt <alan.schmitt-o/5/jSaJEHk+NdeTPqioyti2O/JbrIOy@public.gmane.org> writes:
>>
>>> I tried this alternate approach, to directly generate the block:
>>>
>>> #+name: fetchcoq2
>>> #+BEGIN_SRC sh :exports none :results raw :var f="demo.v"
>>> echo "#+BEGIN_SRC coq"
>>> head $f
>>> echo
>>> echo "#+END_SRC"
>>> #+END_SRC
>>>
>>> #+call: fetchcoq2("demo.v")
>>>
>>> But then I get a result like this, with extra quoting:
>>>
>>> #+RESULTS:
>>> : #+BEGIN_SRC coq
>>> : Definition toto : forall x, exists y, x = y.
>>> : 
>>> : Lemma foo: forall x, x=x.
>>> : #+END_SRC
>>>
>>> I feel like I'm missing something obvious. ":results code" is exactly
>>> what I want (put the results in a SRC block), but I don't know how to
>>> specify the headers of the generated code block.
>>
>> You need :results raw at the end of the call line.
>>
>> #+name: fetchcoq2
>> #+BEGIN_SRC sh :exports none :results raw :var f="demo.v"
>> echo "#+BEGIN_SRC coq"
>> echo $f
>> echo "#+END_SRC"
>> #+END_SRC
>>
>> #+results: fetchcoq2
>> #+BEGIN_SRC coq
>> demo.v
>> #+END_SRC
>>
>> #+call: fetchcoq2("demo.v") :results raw
>>
>> #+results:
>> #+BEGIN_SRC coq
>> demo.v
>> #+END_SRC
>
> Thanks, this is helping me much.
>
> There are still one thing that I don't understand: I cannot make this
> work when I have already evaluated the call in the buffer. More
> precisely, if I have the following:
>
> #+name: fetchcoq
> #+BEGIN_SRC sh :exports none :results raw :var f="foo.v"
> echo "#+BEGIN_SRC coq"
> head $f
> echo
> echo "#+END_SRC"
> #+END_SRC
>
> #+call: fetchcoq(f="demo.v") :results raw
>
> when I evaluate the call line, I get this (as expected):
>
> #+name: fetchcoq
> #+BEGIN_SRC sh :exports none :results raw :var f="foo.v"
> echo "#+BEGIN_SRC coq"
> head $f
> echo
> echo "#+END_SRC"
> #+END_SRC
>
> #+call: fetchcoq(f="demo.v") :results raw
>
> #+RESULTS:
> #+BEGIN_SRC coq
> Definition toto : forall x, exists y, x = y.
>
> Lemma foo: forall x, x=x.
> #+END_SRC
>
> Unfortunately, if I export this, the code is duplicated. Here is the
> generated html, for instance:
>
> ,----
> | <pre class="src src-coq"><span style="color: #FBDE2D;">Definition</span>
> | <span style="color: #ff1493;">toto</span> : <span style="color:
> | #D8FA3C;">forall</span> <span style="color: #D8FA3C;">x</span>, <span
> | style="color: #9370db;">exists</span> y, x = y.
> | 
> | <span style="color: #FBDE2D;">Lemma</span> <span style="color: #ff1493;">foo</span>: <span style="color: #D8FA3C;">forall</span> <span style="color: #D8FA3C;">x</span>, x=x.
> | #+END_SRC#+BEGIN_SRC coq
> | <span style="color: #FBDE2D;">Definition</span> <span style="color:
> | #ff1493;">toto</span> : <span style="color: #D8FA3C;">forall</span> <span
> | style="color: #D8FA3C;">x</span>, <span style="color: #9370db;">exists</span>
> | y, x = y.
> | 
> | <span style="color: #FBDE2D;">Lemma</span> <span style="color: #ff1493;">foo</span>: <span style="color: #D8FA3C;">forall</span> <span style="color: #D8FA3C;">x</span>, x=x.
> | </pre>
> `----
>
> Exporting if the result is not in the buffer is fine. I tried adding a
> ":results replace" as inner header argument to the call line and to the
> fetchcoq block, but it does not change anything.
>
> How can I tell the call line to replace the results when exporting?

The syntax of the call line is:

    #+call: <NAME>[<HEADER-ARGS-FOR-BLOCK>](<ARGUMENTS>) <HEADER-ARGS-FOR-CALL-LINE>

So, you should add your option either in [] after the name, or at the end of
the line -- I'm always hesitating about where to put the right stuff (not so
enough clear yet in my mind)...

Best regards,
  Seb

-- 
Sebastien Vauban

  reply	other threads:[~2013-12-02 11:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-29 21:49 How do I specify the language for a :results code block Alan Schmitt
2013-11-29 22:10 ` Thomas S. Dye
2013-11-29 23:48   ` Charles Berry
2013-11-30 10:52     ` Alan Schmitt
2013-11-30 16:57       ` Thomas S. Dye
2013-12-02 10:41         ` Alan Schmitt
2013-12-02 11:27           ` Sebastien Vauban [this message]
2013-12-02 13:04             ` Alan Schmitt
2013-12-02 18:09               ` Sean O'Halpin
2013-12-04 13:18                 ` Alan Schmitt
2013-12-04 20:06                   ` Fabrice Niessen
2013-12-05 12:33                     ` Alan Schmitt
2013-12-02 16:53           ` Thomas S. Dye
2013-12-04 12:35             ` Alan Schmitt

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=8661r7ze4y.fsf@somewhere.org \
    --to=sva-news-d0wtavr13harg/idocfnwg@public.gmane.org \
    --cc=emacs-orgmode-mXXj517/zsQ@public.gmane.org \
    /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).