emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: Nick Dokos <ndokos@gmail.com>
Cc: emacs-org list <emacs-orgmode@gnu.org>
Subject: Re: Generate BEGIN_EXAMPLE block dynamically during export
Date: Tue, 16 Feb 2016 17:40:03 -0500	[thread overview]
Message-ID: <CAFyQvY3gGgt7-AYJPFt=S=A-nuNZoh_-pJZ1MbuuyX91GuOP2A@mail.gmail.com> (raw)
In-Reply-To: <87mvr0nvc8.fsf@alphaville.usersys.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1633 bytes --]

This is turning out to be more complicated than I anticipated ..

I need to
(1) Export the evaluated emacs-lisp block to a separate file, and
(2) also include the result in the same document

I can do that but it is a multi-step process:

(1) First I need to export the result to the file only. I cannot include it
as that file hasn't yet been created.

===== org buffer =====
#+AUTHOR:
#+OPTIONS: toc:nil
#+PROPERTY: header-args:emacs-lisp :var tar-file="bar.tar.gz" :exports
results :file "results.txt"

#+NAME: tar-eg
#+BEGIN_SRC emacs-lisp
(format "> tar xzvf %s" tar-file)
#+END_SRC

# #+CAPTION: =results.txt=
# #+NAME: code__results
# #+INCLUDE: "results.txt" :src text
=====

So "C-c C-e t A" gives me:

===== org ascii export =====
[file:results.txt]
=====

(2) But I do not need that file link in the export.. I need the whole
exported result embedded verbatim in the exported document too.

So I need to export the document the second time with the :exports in
#+PROPERTY set to none and the CAPTION/NAME/INCLUDE lines uncommented.

===== org buffer =====
#+AUTHOR:
#+OPTIONS: toc:nil
#+PROPERTY: header-args:emacs-lisp :var tar-file="bar.tar.gz" :exports none
:file "results.txt"

#+NAME: tar-eg
#+BEGIN_SRC emacs-lisp
(format "> tar xzvf %s" tar-file)
#+END_SRC

#+CAPTION: =results.txt=
#+NAME: code__results
#+INCLUDE: "results.txt" :src text
=====

Then I get the desired output on doing "C-c C-e t A".

===== org ascii export =====
,----
| > tar xzvf bar.tar.gz
`----
Listing 1: `results.txt'
=====

Is there a way to export results of a code block evaluation to a file and
also embed them in the exported document?

[-- Attachment #2: Type: text/html, Size: 3899 bytes --]

  reply	other threads:[~2016-02-16 22:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-16 19:10 Generate BEGIN_EXAMPLE block dynamically during export Kaushal Modi
2016-02-16 20:02 ` Thomas S. Dye
2016-02-16 20:51   ` Kaushal Modi
2016-02-16 21:03     ` Thomas S. Dye
2016-02-16 21:16       ` Kaushal Modi
2016-02-16 21:47         ` Kaushal Modi
2016-02-16 22:18           ` Thomas S. Dye
2016-02-16 22:20             ` Kaushal Modi
2016-02-16 22:28           ` Nick Dokos
2016-02-16 22:40             ` Kaushal Modi [this message]
2016-02-16 23:10               ` Kaushal Modi

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='CAFyQvY3gGgt7-AYJPFt=S=A-nuNZoh_-pJZ1MbuuyX91GuOP2A@mail.gmail.com' \
    --to=kaushal.modi@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=ndokos@gmail.com \
    /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).