emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Setting multiple variables for code blocks in one property drawer
@ 2012-02-09 12:46 Viktor Rosenfeld
  2012-02-15 15:08 ` Eric Schulte
  0 siblings, 1 reply; 7+ messages in thread
From: Viktor Rosenfeld @ 2012-02-09 12:46 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

after following the discussion about the new BABEL syntax I was under
the impression that the following should work to set two variables in
one PROPERTIES drawer:

:PROPERTIES:
:var: foo=1
:var+: bar=2
:END:

However, the definition of bar is ignored. It turns out that there can
only be one :var: or :var+: entry in a drawer and the latter can only be
used to append to inherited entries, but not to those defined in the
same drawer. Is this the intended behavior? How would I define multiple
variables in a drawer (except for putting them all on one line)?

Thanks,
Viktor

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

* Re: Setting multiple variables for code blocks in one property drawer
  2012-02-09 12:46 Setting multiple variables for code blocks in one property drawer Viktor Rosenfeld
@ 2012-02-15 15:08 ` Eric Schulte
  2012-02-15 19:12   ` Viktor Rosenfeld
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Schulte @ 2012-02-15 15:08 UTC (permalink / raw)
  To: emacs-orgmode

Viktor Rosenfeld <listuser36@googlemail.com> writes:

> Hi,
>
> after following the discussion about the new BABEL syntax I was under
> the impression that the following should work to set two variables in
> one PROPERTIES drawer:
>
> :PROPERTIES:
> :var: foo=1
> :var+: bar=2
> :END:
>
> However, the definition of bar is ignored. It turns out that there can
> only be one :var: or :var+: entry in a drawer and the latter can only be
> used to append to inherited entries, but not to those defined in the
> same drawer. Is this the intended behavior? How would I define multiple
> variables in a drawer (except for putting them all on one line)?
>
> Thanks,
> Viktor
>

You are correct, I believe this is a bug.  I've just pushed up a fix, so
your example above should now work as expected.

Thanks,

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

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

* Re: Setting multiple variables for code blocks in one property drawer
  2012-02-15 15:08 ` Eric Schulte
@ 2012-02-15 19:12   ` Viktor Rosenfeld
  2012-02-18 15:32     ` Eric Schulte
  0 siblings, 1 reply; 7+ messages in thread
From: Viktor Rosenfeld @ 2012-02-15 19:12 UTC (permalink / raw)
  To: emacs-orgmode

Hi Eric,

thanks for your input. I just pulled the latest code from git and while
my original example works, the following does not:

:PROPERTIES:
:var: foo=1
:var+: bar=2 
:var+: baz=3
:END:

#+BEGIN_SRC sh
echo foo: $foo
echo bar: $bar
echo baz: $baz
#+END_SRC

If I evaluate the source block I get the following error in the messages
buffer: 

  =: Args out of range: "", 0

The following works:

:PROPERTIES:
:var: foo=1
:var+: bar=2 baz=3
:END:

#+BEGIN_SRC sh
echo foo: $foo
echo bar: $bar
echo baz: $baz
#+END_SRC

There also appears to be a difference between quoted and unquoted
values and commatas. E.g. the following works

:PROPERTIES:
:var: foo=1
:var+: bar="2", baz=3
:END:

#+BEGIN_SRC sh
echo foo: $foo
echo bar: $bar
echo baz: $baz
#+END_SRC

If I remove the quotes around 2 I get the following error: 

  ad-Orig-error: reference '2,' not found in this buffer

On the other hand, the following version does not produce an error, but
the value of $baz is not set.

:PROPERTIES:
:var: foo=1
:var+: bar="2",
:var+: baz=3
:END:

#+BEGIN_SRC sh
echo foo: $foo
echo bar: $bar
echo baz: $baz
#+END_SRC

Cheers,
Viktor

Eric Schulte wrote:

> Viktor Rosenfeld <listuser36@googlemail.com> writes:
> 
> > Hi,
> >
> > after following the discussion about the new BABEL syntax I was under
> > the impression that the following should work to set two variables in
> > one PROPERTIES drawer:
> >
> > :PROPERTIES:
> > :var: foo=1
> > :var+: bar=2
> > :END:
> >
> > However, the definition of bar is ignored. It turns out that there can
> > only be one :var: or :var+: entry in a drawer and the latter can only be
> > used to append to inherited entries, but not to those defined in the
> > same drawer. Is this the intended behavior? How would I define multiple
> > variables in a drawer (except for putting them all on one line)?
> >
> > Thanks,
> > Viktor
> >
> 
> You are correct, I believe this is a bug.  I've just pushed up a fix, so
> your example above should now work as expected.
> 
> Thanks,
> 
> -- 
> Eric Schulte
> http://cs.unm.edu/~eschulte/
> 

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

* Re: Setting multiple variables for code blocks in one property drawer
  2012-02-15 19:12   ` Viktor Rosenfeld
@ 2012-02-18 15:32     ` Eric Schulte
  2012-02-20 11:43       ` Viktor Rosenfeld
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Schulte @ 2012-02-18 15:32 UTC (permalink / raw)
  To: emacs-orgmode

Viktor Rosenfeld <listuser36@googlemail.com> writes:

> Hi Eric,
>
> thanks for your input. I just pulled the latest code from git and while
> my original example works, the following does not:
>
> :PROPERTIES:
> :var: foo=1
> :var+: bar=2 
> :var+: baz=3
> :END:
>
> #+BEGIN_SRC sh
> echo foo: $foo
> echo bar: $bar
> echo baz: $baz
> #+END_SRC
>

Thanks for reporting, I've just pushed up a fix for this bug.

>
> There also appears to be a difference between quoted and unquoted
> values and commatas. E.g. the following works
>
> :PROPERTIES:
> :var: foo=1
> :var+: bar="2", baz=3
> :END:
>
> #+BEGIN_SRC sh
> echo foo: $foo
> echo bar: $bar
> echo baz: $baz
> #+END_SRC
>
> If I remove the quotes around 2 I get the following error: 
>
>   ad-Orig-error: reference '2,' not found in this buffer
>
> On the other hand, the following version does not produce an error, but
> the value of $baz is not set.
>
> :PROPERTIES:
> :var: foo=1
> :var+: bar="2",
> :var+: baz=3
> :END:
>
> #+BEGIN_SRC sh
> echo foo: $foo
> echo bar: $bar
> echo baz: $baz
> #+END_SRC
>

Yes, the comma results in the 2 not being parsed as a number, which
means that it will then try to be understood by Babel (which thinks
first of a reference unless the value is wrapped in quotes indicating it
is a string).  The moral is to not give references purely numerical
names.

Best,

>
> Cheers,
> Viktor
>
> Eric Schulte wrote:
>
>> Viktor Rosenfeld <listuser36@googlemail.com> writes:
>> 
>> > Hi,
>> >
>> > after following the discussion about the new BABEL syntax I was under
>> > the impression that the following should work to set two variables in
>> > one PROPERTIES drawer:
>> >
>> > :PROPERTIES:
>> > :var: foo=1
>> > :var+: bar=2
>> > :END:
>> >
>> > However, the definition of bar is ignored. It turns out that there can
>> > only be one :var: or :var+: entry in a drawer and the latter can only be
>> > used to append to inherited entries, but not to those defined in the
>> > same drawer. Is this the intended behavior? How would I define multiple
>> > variables in a drawer (except for putting them all on one line)?
>> >
>> > Thanks,
>> > Viktor
>> >
>> 
>> You are correct, I believe this is a bug.  I've just pushed up a fix, so
>> your example above should now work as expected.
>> 
>> Thanks,
>> 
>> -- 
>> Eric Schulte
>> http://cs.unm.edu/~eschulte/
>> 
>

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

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

* Re: Setting multiple variables for code blocks in one property drawer
  2012-02-18 15:32     ` Eric Schulte
@ 2012-02-20 11:43       ` Viktor Rosenfeld
  2012-02-25 19:11         ` Eric Schulte
  0 siblings, 1 reply; 7+ messages in thread
From: Viktor Rosenfeld @ 2012-02-20 11:43 UTC (permalink / raw)
  To: emacs-orgmode

Hi Eric,

Eric Schulte wrote:

> Viktor Rosenfeld <listuser36@googlemail.com> writes:
> 
> > Hi Eric,
> >
> > thanks for your input. I just pulled the latest code from git and while
> > my original example works, the following does not:
> >
> > :PROPERTIES:
> > :var: foo=1
> > :var+: bar=2 
> > :var+: baz=3
> > :END:
> >
> > #+BEGIN_SRC sh
> > echo foo: $foo
> > echo bar: $bar
> > echo baz: $baz
> > #+END_SRC
> >
> 
> Thanks for reporting, I've just pushed up a fix for this bug.

Thanks for your fix. The above example now works for me.

However, I've noticed a problem with inheriting var properties. They are
inherited in a child task only if the child task itself has no var
property. Is this the intended behavior? See the example below.

Cheers,
Viktor

* Parent task
:PROPERTIES:
:var: foo="1"
:var+: bar="2"
:END:
** Child task without own properties

#+BEGIN_SRC sh
echo foo: $foo
echo bar: $bar
#+END_SRC

#+RESULTS:
| foo: | 1 |
| bar: | 2 |

** Child task with own properties
:PROPERTIES:
:var: foo="a"
:END:

#+BEGIN_SRC sh
echo foo: $foo
echo bar: $bar
#+END_SRC

#+RESULTS:
| foo: | a |
| bar: |   |

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

* Re: Setting multiple variables for code blocks in one property drawer
  2012-02-20 11:43       ` Viktor Rosenfeld
@ 2012-02-25 19:11         ` Eric Schulte
  2012-02-27  7:00           ` Viktor Rosenfeld
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Schulte @ 2012-02-25 19:11 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

Viktor Rosenfeld <listuser36@googlemail.com> writes:

> Hi Eric,
>
> Eric Schulte wrote:
>
>> Viktor Rosenfeld <listuser36@googlemail.com> writes:
>> 
>> > Hi Eric,
>> >
>> > thanks for your input. I just pulled the latest code from git and while
>> > my original example works, the following does not:
>> >
>> > :PROPERTIES:
>> > :var: foo=1
>> > :var+: bar=2 
>> > :var+: baz=3
>> > :END:
>> >
>> > #+BEGIN_SRC sh
>> > echo foo: $foo
>> > echo bar: $bar
>> > echo baz: $baz
>> > #+END_SRC
>> >
>> 
>> Thanks for reporting, I've just pushed up a fix for this bug.
>
> Thanks for your fix. The above example now works for me.
>
> However, I've noticed a problem with inheriting var properties. They are
> inherited in a child task only if the child task itself has no var
> property. Is this the intended behavior? See the example below.
>

Yes,

The example below is the intended behavior.  The property mechanism is
not tailored to variable setting, but is rather a general mechanism for
the concatenation of property strings.  Any property specification
unless it is postfixed with a "+" will /reset/ the value of that
property to its current value.

However try replacing
> :var: foo="a"
with
> :var+: foo="a"
which is valid and should work for your use case below.

There are still some lingering issues with inheritance and Org-mode
properties which I may try to address one of these days.

Cheers,

>
> Cheers,
> Viktor
>
> * Parent task
> :PROPERTIES:
> :var: foo="1"
> :var+: bar="2"
> :END:
> ** Child task without own properties
>
> #+BEGIN_SRC sh
> echo foo: $foo
> echo bar: $bar
> #+END_SRC
>
> #+RESULTS:
> | foo: | 1 |
> | bar: | 2 |
>
> ** Child task with own properties
> :PROPERTIES:
> :var: foo="a"
> :END:
>
> #+BEGIN_SRC sh
> echo foo: $foo
> echo bar: $bar
> #+END_SRC
>
> #+RESULTS:
> | foo: | a |
> | bar: |   |
>
>

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

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

* Re: Setting multiple variables for code blocks in one property drawer
  2012-02-25 19:11         ` Eric Schulte
@ 2012-02-27  7:00           ` Viktor Rosenfeld
  0 siblings, 0 replies; 7+ messages in thread
From: Viktor Rosenfeld @ 2012-02-27  7:00 UTC (permalink / raw)
  To: emacs-orgmode

Hi Eric,

Eric Schulte wrote:

> However try replacing
> > :var: foo="a"
> with
> > :var+: foo="a"
> which is valid and should work for your use case below.

I'm not sure if I understood you correctly, but even if I replace "var"
with "var+" in the child's property drawer, the value of bar that is set
in the parent task is not available in the child task.

Cheers,
Viktor

> 
> There are still some lingering issues with inheritance and Org-mode
> properties which I may try to address one of these days.
> 
> Cheers,
> 
> >
> > Cheers,
> > Viktor
> >
> > * Parent task
> > :PROPERTIES:
> > :var: foo="1"
> > :var+: bar="2"
> > :END:
> > ** Child task without own properties
> >
> > #+BEGIN_SRC sh
> > echo foo: $foo
> > echo bar: $bar
> > #+END_SRC
> >
> > #+RESULTS:
> > | foo: | 1 |
> > | bar: | 2 |
> >
> > ** Child task with own properties
> > :PROPERTIES:
> > :var: foo="a"
> > :END:
> >
> > #+BEGIN_SRC sh
> > echo foo: $foo
> > echo bar: $bar
> > #+END_SRC
> >
> > #+RESULTS:
> > | foo: | a |
> > | bar: |   |
> >
> >
> 
> -- 
> Eric Schulte
> http://cs.unm.edu/~eschulte/
> 

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

end of thread, other threads:[~2012-02-27  7:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-09 12:46 Setting multiple variables for code blocks in one property drawer Viktor Rosenfeld
2012-02-15 15:08 ` Eric Schulte
2012-02-15 19:12   ` Viktor Rosenfeld
2012-02-18 15:32     ` Eric Schulte
2012-02-20 11:43       ` Viktor Rosenfeld
2012-02-25 19:11         ` Eric Schulte
2012-02-27  7:00           ` Viktor Rosenfeld

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