From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ken Mankoff Subject: Modify a variable before it is passed to babel (or exported)? Date: Mon, 16 Sep 2019 10:21:41 -0700 Message-ID: <87v9ts5f8a.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:55344) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9uhL-0004m2-2l for emacs-orgmode@gnu.org; Mon, 16 Sep 2019 13:22:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9uh6-0002He-QS for emacs-orgmode@gnu.org; Mon, 16 Sep 2019 13:21:58 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:39502) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9uh6-0002GS-Bp for emacs-orgmode@gnu.org; Mon, 16 Sep 2019 13:21:44 -0400 Received: by mail-pg1-x533.google.com with SMTP id u17so371896pgi.6 for ; Mon, 16 Sep 2019 10:21:44 -0700 (PDT) Received: from geus3064linuxwsm (161.11.27.136.in-addr.arpa. [136.27.11.161]) by smtp.gmail.com with ESMTPSA id fa13sm142630pjb.16.2019.09.16.10.21.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Sep 2019 10:21: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" To: org-mode-email I'd like to modify a variable with a babel block before another block sees the variable. For example, I always want to add one to a variable: #+NAME: add-one #+BEGIN_SRC bash :results verbatim :var data=0 data=$(( data + 1 )) echo $data #+END_SRC #+RESULTS: add_one : 1 Test it: #+CALL: add_one(data=42) #+RESULTS: : 43 Can I use =add_one= to modify data passed elsewhere? For example, given #+NAME: table | 42 | I'm having trouble defining a =print_table= function that prints 43, using the =add_one= either via :prologue or <> or some other method. Preferably prologue because then the add_one function could be in a different language. I can get halfway to what I want with a :post option, but need this to be a :pre or :prologue. Example using :post #+NAME: python_using_add_one #+BEGIN_SRC python :results output values :post add-one(data=*this*) print(42) #+END_SRC #+RESULTS: python_using_add_one : 43 Any suggestions how to use this feature with :pre or :prologue? Thanks, -k