From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Schmitt Subject: Re: How do I specify the language for a :results code block Date: Wed, 04 Dec 2013 14:18:50 +0100 Message-ID: References: <8661r7ze4y.fsf@somewhere.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35299) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoCM5-0006ry-Qa for emacs-orgmode@gnu.org; Wed, 04 Dec 2013 08:19:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VoCLx-0002zI-0k for emacs-orgmode@gnu.org; Wed, 04 Dec 2013 08:19:05 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:26592) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoCLw-0002zB-QM for emacs-orgmode@gnu.org; Wed, 04 Dec 2013 08:18:56 -0500 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Sean O'Halpin Cc: Sebastien Vauban , Org Mode Hi Sean, sean.ohalpin@gmail.com writes: > Taking a slightly different approach, you could use the :post header > argument to wrap the results in a source block. > > See http://orgmode.org/org.html#post (from which the example below is derived). > > For example, you could use something like this: > > #+OPTIONS: d:RESULTS > > * Example > > #+name: eg-1 > #+begin_src sh :results replace drawer :exports results :post > wrap-src(text=*this*) > head -n 3 demo.v > #+end_src > > Output > #+results: eg-1 > > * Utils :noexport: > #+name: wrap-src > #+begin_src emacs-lisp :var text="" :results raw > (concat "#+BEGIN_SRC coq\n" text "\n#+END_SRC") > #+end_src Thank you for the suggestion. Unfortunately I get the same problem than with "wrap": if the results are present, they become duplicated in the export. Here is a small example showing it: --8<---------------cut here---------------start------------->8--- #+name: mywrap #+BEGIN_SRC sh :exports none :results raw echo "(+ 1 2)" #+END_SRC Exporting using ~:post~ #+name: wrap-src #+BEGIN_SRC emacs-lisp :var text="" :results raw :exports none (concat "#+BEGIN_SRC emacs-lisp\n" text "\n#+END_SRC") #+END_SRC #+name: test4 #+call: mywrap() :post wrap-src(text=*this*) :results raw #+RESULTS: test4 #+BEGIN_SRC emacs-lisp (+ 1 2) #+END_SRC --8<---------------cut here---------------end--------------->8--- If you export this, you will see some duplication of the test4 block. Your example showed more than the ~:post~ approach: there is also the use of a drawer. And this solves my export problem (with a drawer, things are not duplicated). Thanks a lot! (I tried to apply the drawer trick to the :wrap src but it does not work, unfortunately. I like your approach better anyway as it allows me to specify not only the language used by the output source block, but other properties (such as whether it should be evaluated) which wrap does not let me do.) > BTW I answered a question similar to this on Stack Overflow recently > (http://stackoverflow.com/questions/20194347/org-mode-with-code-example-as-html/20232922#20232922) > - must be something in the air. I grabbed some additional information from there, and this is what I ended up with. Thanks again for the help. --8<---------------cut here---------------start------------->8--- #+OPTIONS: d:RESULTS * utilities :noexport: #+name: fetchfile #+BEGIN_SRC sh :exports none :results raw :var f="foo.v" head $f #+END_SRC #+name: wrap-coq #+BEGIN_SRC emacs-lisp :var text="" :results raw (concat "#+BEGIN_SRC coq\n" text "\n#+END_SRC") #+END_SRC * example :PROPERTIES: :results: drawer :post: wrap-coq(text=*this*) :END: #+call: fetchfile("demo.v") #+RESULTS: :RESULTS: #+BEGIN_SRC coq Definition toto : forall x, exists y, x = y. Lemma foo: forall x, x=x. #+END_SRC :END: --8<---------------cut here---------------end--------------->8--- Alan