emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [babel] How to set multiple variables with properties
@ 2011-06-21 18:42 Darlan Cavalcante Moreira
  2011-06-21 20:17 ` Eric Schulte
  0 siblings, 1 reply; 9+ messages in thread
From: Darlan Cavalcante Moreira @ 2011-06-21 18:42 UTC (permalink / raw)
  To: Orgmode Mailing List


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
--8<---------------cut here---------------start------------->8---
* Heading
  :PROPERTY:
  :var: variable1="value1"
  :END:
  #+begin_src python :results output
    print variable1
  #+end_src

  #+results:
  : value1
--8<---------------cut here---------------end--------------->8---

Is it possible to set multiples variables in this way?
I tried things like
--8<---------------cut here---------------start------------->8---
:PROPERTY:
:var: variable1="value1" variable2="value2"
:END:

:PROPERTY:
:var: variable1="value1",variable2="value2"
:END:

:PROPERTY:
:variable1: "value1"
:variable2: "value2"
:END:
--8<---------------cut here---------------end--------------->8---
but none of them worked.


--
Darlan Cavalcante

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

* Re: [babel] How to set multiple variables with properties
  2011-06-21 18:42 [babel] How to set multiple variables with properties Darlan Cavalcante Moreira
@ 2011-06-21 20:17 ` Eric Schulte
  2011-06-21 21:01   ` Christian Moe
  2011-06-22  1:03   ` Darlan Cavalcante Moreira
  0 siblings, 2 replies; 9+ messages in thread
From: Eric Schulte @ 2011-06-21 20:17 UTC (permalink / raw)
  To: Darlan Cavalcante Moreira; +Cc: Orgmode Mailing List

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 <darcamo@gmail.com> 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
>

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

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

* Re: [babel] How to set multiple variables with properties
  2011-06-21 20:17 ` Eric Schulte
@ 2011-06-21 21:01   ` Christian Moe
  2011-06-21 21:03     ` Eric Schulte
  2011-06-22  1:03   ` Darlan Cavalcante Moreira
  1 sibling, 1 reply; 9+ messages in thread
From: Christian Moe @ 2011-06-21 21:01 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Orgmode Mailing List

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<darcamo@gmail.com>  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
>>
>

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

* Re: [babel] How to set multiple variables with properties
  2011-06-21 21:01   ` Christian Moe
@ 2011-06-21 21:03     ` Eric Schulte
  2011-06-22 18:27       ` Christian Moe
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Schulte @ 2011-06-21 21:03 UTC (permalink / raw)
  To: mail; +Cc: Orgmode Mailing List

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 <mail@christianmoe.com> 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<darcamo@gmail.com>  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
>>>
>>
>

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

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

* Re: [babel] How to set multiple variables with properties
  2011-06-21 20:17 ` Eric Schulte
  2011-06-21 21:01   ` Christian Moe
@ 2011-06-22  1:03   ` Darlan Cavalcante Moreira
  1 sibling, 0 replies; 9+ messages in thread
From: Darlan Cavalcante Moreira @ 2011-06-22  1:03 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Orgmode Mailing List


Thanks Eric,

I'll minimize the need of this by using "#+babel: var=something" for
variables that are common to many blocks.

The tip with the table is a good one also.

--
Darlan Cavalcante

At Tue, 21 Jun 2011 13:17:17 -0700,
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 <darcamo@gmail.com> 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
> >
> 
> -- 
> Eric Schulte
> http://cs.unm.edu/~eschulte/

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

* Re: [babel] How to set multiple variables with properties
  2011-06-21 21:03     ` Eric Schulte
@ 2011-06-22 18:27       ` Christian Moe
  2011-06-23  1:38         ` Darlan Cavalcante Moreira
  2011-06-24  5:25         ` Eric Schulte
  0 siblings, 2 replies; 9+ messages in thread
From: Christian Moe @ 2011-06-22 18:27 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Orgmode Mailing List

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<mail@christianmoe.com>  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<darcamo@gmail.com>   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
>>>>
>>>
>>
>

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

* Re: [babel] How to set multiple variables with properties
  2011-06-22 18:27       ` Christian Moe
@ 2011-06-23  1:38         ` Darlan Cavalcante Moreira
  2011-06-24  5:28           ` Eric Schulte
  2011-06-24  5:25         ` Eric Schulte
  1 sibling, 1 reply; 9+ messages in thread
From: Darlan Cavalcante Moreira @ 2011-06-23  1:38 UTC (permalink / raw)
  To: mail; +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 <mail@christianmoe.com> 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<mail@christianmoe.com>  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<darcamo@gmail.com>   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
> >>>>
> >>>
> >>
> >
> 
> 

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

* Re: [babel] How to set multiple variables with properties
  2011-06-22 18:27       ` Christian Moe
  2011-06-23  1:38         ` Darlan Cavalcante Moreira
@ 2011-06-24  5:25         ` Eric Schulte
  1 sibling, 0 replies; 9+ messages in thread
From: Eric Schulte @ 2011-06-24  5:25 UTC (permalink / raw)
  To: mail; +Cc: Orgmode Mailing List

Hi Christian,

I took a look at these functions, while they do seem to work they don't
provide for any inheritance from higher-level subtrees.  I think this is
a deal-breaker for use resolving header arguments as inheritance is
generally more useful than multiple values.

Thanks for pointing these out, at some point I do think that it may be
worth taking a look at how Org-mode resolves properties generally.

Cheers -- Eric

Christian Moe <mail@christianmoe.com> writes:

> 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<mail@christianmoe.com>  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<darcamo@gmail.com>   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
>>>>>
>>>>
>>>
>>
>

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

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

* Re: [babel] How to set multiple variables with properties
  2011-06-23  1:38         ` Darlan Cavalcante Moreira
@ 2011-06-24  5:28           ` Eric Schulte
  0 siblings, 0 replies; 9+ messages in thread
From: Eric Schulte @ 2011-06-24  5:28 UTC (permalink / raw)
  To: Darlan Cavalcante Moreira; +Cc: Orgmode Mailing List, mail

I think that a solution more integrated with the rest of Org-mode's
property handling would be preferable.  That is to say, there should be
a way to collect multiple value for a property in Org-mode, and Babel
should simply make use of the more general facility.

This doesn't exist yet, but I'd rather wait for the general Org solution
than push through a temporary Babel-specific solution.

Cheers -- Eric

Darlan Cavalcante Moreira <darcamo@gmail.com> writes:

> 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
> :PROPERTY:
> :ob-someVariable:      "some string maybe with\nline breaks"
> :ob-someOtherVariable: 123456
> :END:
> would make the variables "someVariable" and "someOtherVariable" known to
> org-babel.
>
> --
> Darlan Cavalcante
>
> At Wed, 22 Jun 2011 20:27:00 +0200,
> Christian Moe <mail@christianmoe.com> 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<mail@christianmoe.com>  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<darcamo@gmail.com>   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
>> >>>>
>> >>>
>> >>
>> >
>> 
>> 

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

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

end of thread, other threads:[~2011-06-24  5:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-21 18:42 [babel] How to set multiple variables with properties Darlan Cavalcante Moreira
2011-06-21 20:17 ` Eric Schulte
2011-06-21 21:01   ` Christian Moe
2011-06-21 21:03     ` Eric Schulte
2011-06-22 18:27       ` Christian Moe
2011-06-23  1:38         ` Darlan Cavalcante Moreira
2011-06-24  5:28           ` Eric Schulte
2011-06-24  5:25         ` Eric Schulte
2011-06-22  1:03   ` Darlan Cavalcante Moreira

Code repositories for project(s) associated with this 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).