emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Luis Muñiz" <lmuniz@lmunix.net>
To: emacs-orgmode@gnu.org
Subject: Babel-tables: need to enable language to pass tables to code blocks
Date: Sat, 18 Aug 2012 15:13:38 +0200	[thread overview]
Message-ID: <CAOiqyq7_NYOrhDRG_boAVEEQtAZga5_F-iT1oS5x-_0KQWN6Vg@mail.gmail.com> (raw)

Hi!  I've started using tables to provide data to my babel-embedded
scripts, and I've found some issues.  The first one is that table data
is embedded in tangled scripts only if the source language has been
enabled for <a href="http://orgmode.org/org.html#Languages">evaluation</a>.

That is, given a sample table:
#+TBLNAME: sample-table
| n | 2**n | 3**n |
|---+------+------|
| 1 |    2 |    3 |
| 2 |    4 |    9 |

...the next block is supposed to create a file with the table in it
when tangled, but it doesn't...
#+BEGIN_SRC sh :var data=sample-table :tangle yes
  :
#+END_SRC

... unless =sh= has been enabled for evaluation (by default, only
=emacs-lisp= is).

One can simply overcome this by first evaluating this block [fn:1]:
#+NAME: sh-activate
#+BEGIN_SRC emacs-lisp :results silent
  (org-babel-do-load-languages 'org-babel-load-languages '((sh . t))
  )
#+END_SRC

While this is not a serious problem it took me by surprise; I don't
know if it *really* has to be fixed (I'm unsure if this is a bug or a
feature ;) but, at least, it should appear in the documentation; may I
suggest <a href="http://orgmode.org/org.html#var">here</a>, under the
`table' heading?

 I'm using org-mode version 7.8.11 from the GIT repository (updated
yesterday release_7.8.11-505-g952d72), and Emacs 23.2.1.

TIA,
--
  - Luis Muñiz

[fn:1] BTW, I've found a simpler way to achieve the same results by
using file variables:
#+ -*- mode: org; eval: (let () (org-babel-goto-named-src-block
"sh-activate") (org-babel-execute-src-block) (org-babel-tangle)) -*-

                 reply	other threads:[~2012-08-18 13:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CAOiqyq7_NYOrhDRG_boAVEEQtAZga5_F-iT1oS5x-_0KQWN6Vg@mail.gmail.com \
    --to=lmuniz@lmunix.net \
    --cc=emacs-orgmode@gnu.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).