From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dirk Scharff Subject: Need control over insertion point of variables in code blocks Date: Fri, 22 Jul 2011 09:22:36 +0200 Message-ID: Mime-Version: 1.0 (Apple Message framework v1244.3) Content-Type: multipart/mixed; boundary="Apple-Mail=_ABB41350-7064-440B-A6D7-5C75C3B61556" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:33381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QkA4K-0002eJ-T8 for emacs-orgmode@gnu.org; Fri, 22 Jul 2011 03:22:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QkA4I-0003RC-Hx for emacs-orgmode@gnu.org; Fri, 22 Jul 2011 03:22:44 -0400 Received: from mail-fx0-f52.google.com ([209.85.161.52]:34367) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QkA4I-0003Qo-Bg for emacs-orgmode@gnu.org; Fri, 22 Jul 2011 03:22:42 -0400 Received: by fxd18 with SMTP id 18so3905172fxd.39 for ; Fri, 22 Jul 2011 00:22:41 -0700 (PDT) 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: Org mailing list --Apple-Mail=_ABB41350-7064-440B-A6D7-5C75C3B61556 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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=3D3 :tangle test.py :results output from __future__ import division print x #+end_src tangling results in: x=3D3 from __future__ import division print x The problem with the result is simple:=20 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.=20 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=3Dcall_the_test(x=3D$<) 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?=20 You can test both cases in the attached org-file.=20 --Apple-Mail=_ABB41350-7064-440B-A6D7-5C75C3B61556 Content-Disposition: attachment; filename=testing.org Content-Type: application/octet-stream; x-unix-mode=0644; name="testing.org" Content-Transfer-Encoding: 7bit #+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=$<) --Apple-Mail=_ABB41350-7064-440B-A6D7-5C75C3B61556 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail=_ABB41350-7064-440B-A6D7-5C75C3B61556--