From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: [Org-Babel] Export environments for shell results? Date: Wed, 06 Oct 2010 16:26:04 +0100 Message-ID: <87y6abwdf7.fsf@stats.ox.ac.uk> References: <87y6abicqw.fsf@mundaneum.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=53139 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P3Vsm-0005sq-6S for emacs-orgmode@gnu.org; Wed, 06 Oct 2010 11:26:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P3Vsk-0003Ii-0V for emacs-orgmode@gnu.org; Wed, 06 Oct 2010 11:26:16 -0400 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:34283) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P3Vsj-0003IR-Lv for emacs-orgmode@gnu.org; Wed, 06 Oct 2010 11:26:13 -0400 In-Reply-To: <87y6abicqw.fsf@mundaneum.com> (=?utf-8?Q?=22S=C3=A9bastien?= Vauban"'s message of "Wed, 06 Oct 2010 17:04:23 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: =?utf-8?Q?S=C3=A9bastien?= Vauban Cc: emacs org-mode mailing list Hi Seb, S=C3=A9bastien Vauban writes: > #+TITLE: Org-Babel export environments for shell results > > * Example > > ** Medium output > > #+srcname: is-converted-to-listings > #+begin_src sh :results output :exports both > grep autoload ~/Downloads/emacs/site-lisp/org-mode/lisp/ob.el | cut -d "#= " -f 4 > #+end_src (It's nice that your email is in Org format; I can get the contents into an Org buffer quickly. Could I ask you to make the source blocks reproducible in the future, so that we can execute them without having to alter file paths etc?) > > #+results: is-converted-to-listings > #+begin_example > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > #+end_example > > gets translated (in LaTeX) to: > > #+begin_src latex > \begin{lstlisting} > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > autoload > \end{lstlisting} > #+end_src > > ** Short output > > ... while > > #+srcname: is-converted-to-verbatim > #+begin_src sh :results output :exports both > grep autoload ~/Downloads/emacs/site-lisp/org-mode/lisp/ob.el | cut -d "#= " -f 4 | head -n 3 > #+end_src > > #+results: is-converted-to-verbatim > : autoload > : autoload > : autoload > > gets translated (in LaTeX) to: > > #+begin_src latex > \begin{verbatim} > autoload > autoload > autoload > \end{verbatim} > #+end_src > > with a leading space (that you don't see when running the command in the > shell). > > The only difference is the shell command is adding =3Dhead -n 3=3D. > > * Questions > > 1. Why that difference of behavior? I suspect this is due to=20 --8<---------------cut here---------------start------------->8--- org-babel-min-lines-for-block-output is a variable defined in `ob.el'. Its value is 10 Documentation: The minimum number of lines for block output. If number of lines of output is equal to or exceeds this value, the output is placed in a #+begin_example...#+end_example block. Otherwise the output is marked as literal by inserting colons at the starts of the lines. This variable only takes effect if the :results output option is in effect. --8<---------------cut here---------------end--------------->8--- > > 2. What's the determining factor for switching between =3Dverbatim=3D and > =3Dlstlisting=3D environments? I'm no expert on latex export. But if the colon form and the block form are equivalent in Org, then perhaps it is a bug that they have non-equivalent latex export? I didn't realise that begin_example resulted in a lstlisting environment when using listings with Org. > > 3. Why is there a leading space in the =3Dverbatim=3D environment? I guess it is due to the space after the colon in the Org buffer. Dan > > Best regards, > Seb