emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Need control over insertion point of variables in code blocks
@ 2011-07-22  7:22 Dirk Scharff
  2011-07-22  7:34 ` Rainer M Krug
       [not found] ` <87aac6u0rk.fsf@gnu.org>
  0 siblings, 2 replies; 6+ messages in thread
From: Dirk Scharff @ 2011-07-22  7:22 UTC (permalink / raw)
  To: Org mailing list

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

Hi

i just noticed that variables are assigned in the top of the exported code. That can be problematic in some situations:

#+source: the_test
#+begin_src python :var x=3 :tangle test.py :results output
from __future__ import division
print x
#+end_src


tangling results in:

x=3
from __future__ import division
print x

The problem with the result is simple: 
SyntaxError: from __future__ imports must occur at the beginning of the file

To export this correctly I'd need the possibility to tell org-mode where the variables are supposed to be inserted. Is there a way to do this? I didn't find a keyword for this in the documentation. 

A second problem I have at the moment lies with the execution of source-blocks in tables. What I'd like to do:

| argument | result |
|        1 | #ERROR |
|          |        |
#+TBLFM: $2=call_the_test(x=$<)

I guess I'm just doing something wrong here. Executing the #+Tblfm results in the error: "reference $< not found in buffer". How do I do the reference correctly in this case? 

You can test both cases in the attached org-file. 

[-- Attachment #2: testing.org --]
[-- Type: application/octet-stream, Size: 228 bytes --]

#+source: the_test
#+begin_src python :var x=3 :tangle test.py :results output
from __future__ import division
print x
#+end_src

| argument | result |
|        1 | #ERROR |
|          |        |
#+TBLFM: $2=call_the_test(x=$<)

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-07-22 13:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-22  7:22 Need control over insertion point of variables in code blocks Dirk Scharff
2011-07-22  7:34 ` Rainer M Krug
2011-07-22  7:55   ` Dirk Scharff
2011-07-22  8:02     ` Rainer M Krug
     [not found] ` <87aac6u0rk.fsf@gnu.org>
2011-07-22  9:36   ` Dirk Scharff
2011-07-22 13:32     ` Bastien

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).