From mboxrd@z Thu Jan 1 00:00:00 1970 From: Darlan Cavalcante Moreira Subject: Re: [babel] How to set multiple variables with properties Date: Wed, 22 Jun 2011 22:38:09 -0300 Message-ID: <4e029907.a6c0ec0a.1025.4034@mx.google.com> References: <4e00e5ff.634dec0a.10c2.462f@mx.google.com> <87y60vhrci.fsf@gmail.com> <4E0106B4.7090409@christianmoe.com> <87tybij3r6.fsf@gmail.com> <4E0233F4.4000201@christianmoe.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: Received: from eggs.gnu.org ([140.186.70.92]:53174) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QZYs8-0006hY-Bj for emacs-orgmode@gnu.org; Wed, 22 Jun 2011 21:38:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QZYs6-0007nZ-FV for emacs-orgmode@gnu.org; Wed, 22 Jun 2011 21:38:20 -0400 Received: from mail-gy0-f169.google.com ([209.85.160.169]:47787) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QZYs6-0007nP-Aw for emacs-orgmode@gnu.org; Wed, 22 Jun 2011 21:38:18 -0400 Received: by gyg13 with SMTP id 13so744696gyg.0 for ; Wed, 22 Jun 2011 18:38:17 -0700 (PDT) In-Reply-To: <4E0233F4.4000201@christianmoe.com> 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: mail@christianmoe.com Cc: Orgmode Mailing List One of the things I tried (that didn't work, otherwise I would not have sent any e-mail) was :PROPERTY: :var: variable1="value1" :var variable2="value2" :END: I thought that maybe babel would just ask org what is the value of :var:, put ":var" before it, and include this in the block header. Therefore I would get the effect of adding ":var variable1="value1" :var variable2="value2"" in the block header and it could work. However, even if this method had worked It would not be flexible. One of the nice things about properties is inheritance. I would like to define "general variables" as properties in level-1 headings and define more specific variables in the sub-headings as necessary. However, if babel always use :var: as the property then defining a variable in a subheading will overwrite the upper level variable. The best option in my use-case-scenario would be some name scheme to identify variable definitions for org-babel. For instance --8<---------------cut here---------------start------------->8--- :PROPERTY: :ob-someVariable: "some string maybe with\nline breaks" :ob-someOtherVariable: 123456 :END: --8<---------------cut here---------------end--------------->8--- would make the variables "someVariable" and "someOtherVariable" known to org-babel. -- Darlan Cavalcante At Wed, 22 Jun 2011 20:27:00 +0200, Christian Moe wrote: > > Hi again, > > I was referring to these functions: > - org-entry-put-multivalued-property > - org-entry-get-multivalued-property > - org-entry-add-to-multivalued-property > - org-entry-remove-from-multivalued-property > - org-entry-member-in-multivalued-property > described here: > http://orgmode.org/manual/Using-the-property-API.html > > I've found a few discussions: > - http://comments.gmane.org/gmane.emacs.orgmode/33457 > - http://lists.gnu.org/archive/html/emacs-orgmode/2010-02/msg00251.html > > I don't have anything working with them, as such,[1] and I was curious > if anyone did. They don't currently seem to be integrated into > completion, search functions, Babel, and so on, which would limit > their usefulness (though searching can be done with regexps). And I > think implementing wider support for them would run into a problem > with distinguishing between properties that are meant to be > multivalued, or and properties that just contain a single value which > happens to contain spaces. > > But handling multiple var=value expressions in a :var: property for > Babel, as Darlan asked about, might perhaps be doable...? Stuff might > break, though. > > Yours, > Christian > > > [1] I do have a small research database with some "multivalued" > properties in it. For queries, I use your org-collector and regular > expression matching against properties with multiple values. The > multivalued-properties functions didn't really come into it, except > that knowing they were there made me go ahead and put multiple values > in one property. (As it turned out, that wasn't a very good design > choice.) > > On 6/21/11 11:03 PM, Eric Schulte wrote: > > Hi Christian, > > > > That's the first I've heard of that variable? If you do get something > > working with multivalued properties please do share. > > > > Cheers -- Eric > > > > Christian Moe writes: > > > >> Hi, Eric, > >> > >> Just curious: What about the org-entry--multivalued-property functions > >> mentioned in "Using the properties API"? > >> > >> Is anybody using multivalued properties for anything? > >> > >> Yours, > >> Christian > >> > >> > >> On 6/21/11 10:17 PM, Eric Schulte wrote: > >>> Unfortunately org-mode properties only allow a single entry for any > >>> given key, so you can only specify one variable using properties. > >>> > >>> However the following workaround does exist. > >>> > >>> *** alternative > >>> :PROPERTIES: > >>> :var: vars=variables > >>> :END: > >>> > >>> #+tblname: variables > >>> | var1 | 1 | > >>> | var2 | 2 | > >>> > >>> #+begin_src python > >>> print vars[0][1] > >>> print vars[1][1] > >>> #+end_src > >>> > >>> Best -- Eric > >>> > >>> Darlan Cavalcante Moreira writes: > >>> > >>>> I'm using org-babel to automate a few tasks and I'd like to define a few > >>>> variables that are common to several code blocks as sub-tree properties. > >>>> > >>>> It works when I have only one variable, where I can use > >>>> * Heading > >>>> :PROPERTY: > >>>> :var: variable1="value1" > >>>> :END: > >>>> #+begin_src python :results output > >>>> print variable1 > >>>> #+end_src > >>>> > >>>> #+results: > >>>> : value1 > >>>> > >>>> Is it possible to set multiples variables in this way? > >>>> I tried things like > >>>> :PROPERTY: > >>>> :var: variable1="value1" variable2="value2" > >>>> :END: > >>>> > >>>> :PROPERTY: > >>>> :var: variable1="value1",variable2="value2" > >>>> :END: > >>>> > >>>> :PROPERTY: > >>>> :variable1: "value1" > >>>> :variable2: "value2" > >>>> :END: > >>>> but none of them worked. > >>>> > >>>> > >>>> -- > >>>> Darlan Cavalcante > >>>> > >>> > >> > > > >