From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rainer M Krug Subject: Re: Local variables in an org file Date: Fri, 21 Aug 2015 13:57:47 +0200 Message-ID: References: <87fv3e4g63.fsf@iki.fi> <87twrssyhy.fsf@iki.fi> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41412) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZSkxK-0006o2-MQ for emacs-orgmode@gnu.org; Fri, 21 Aug 2015 07:57:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZSkxH-0000Cd-Fi for emacs-orgmode@gnu.org; Fri, 21 Aug 2015 07:57:58 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:38778) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZSkxH-0000CV-AD for emacs-orgmode@gnu.org; Fri, 21 Aug 2015 07:57:55 -0400 Received: by wicja10 with SMTP id ja10so14171612wic.1 for ; Fri, 21 Aug 2015 04:57:54 -0700 (PDT) In-Reply-To: <87twrssyhy.fsf@iki.fi> (Jarmo Hurri's message of "Fri, 21 Aug 2015 13:54:17 +0300") 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: Jarmo Hurri Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Jarmo Hurri writes: > Thomas S. Dye writes: > >> * Define a local variable >> #+name: my-var >> #+header: :exports none >> #+begin_src R >> 768 >> #+end_src >> #+name: pass-my-var-to-code-block >> #+header: :var x=3Dmy-var >> #+header: :exports both >> #+begin_src emacs-lisp >> (+ x 1) >> #+end_src >> >> #+results: pass-my-var-to-code-block >> : 769 >> >> The variable is call_my-var(). > > Yeah, this will work, but it's a huge amount of work. > > It would be brilliant if one could easily refer to a property inside a > subtree. In both text and code. I agree - and I asked the same question some time (years?) ago. But you could make this easier if you would use macro expansion and to insert your value instead of the variable name - so my-var is {{{my-var}}} would be exported to my-var is 769 Just don't ask me how to define the macro... - possibly #+MACRO: my-var call_my-var() ? Actually, I think it would be a cool if one could always use {{{VARIABLE_NAME}}} and get the value of the variable VARIABLE_NAME back to be inserted in text. In other words, macro expansion would do the following: 1) Check if a macro is defined with the name, if yes, use that 2) if no macro is defined with this name, return the variable as string 3) if no variable is defined continue as usual Cheers, Rainer > > Jarmo > > =2D-=20 Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,= UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax : +33 - (0)9 58 10 27 44 Fax (D): +49 - (0)3 21 21 25 22 44 email: Rainer@krugs.de Skype: RMkrug PGP: 0x0F52F982 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2 iQEcBAEBCAAGBQJV1xI/AAoJENvXNx4PUvmCZq4IAN1VGmjqY88JlyOo1AXl1tU0 RyZYTxZDLRAWC/OKjTtwXvlyFN1WEOFBaF3iDG//3Gd93HC6VSJOtOZqq2adAE93 NgLQJok3ZKbSgn40Bw/wqpDmE1obPCnbE3LlBD78qi32/h2V8fGPaQ1P6gySx2+V Nra3Swos6qjovKGj0bs4e1hgc3ityCvYcQq20vCEGQKSCxt5zBnNuNNUapG7TZKe m6DUmm60eAI3mMIwIXewSFf+pMHAzyygxuh9i1DvzO/fBuShbHJuSP0qJIblhKnM zJAcdzU+ZetcfmFlt53cjfNZj9KKLSN96bVvmb3MxmPw+kFyxBcMn55lwVib30k= =MNOq -----END PGP SIGNATURE----- --=-=-=--