Re: conditional when-property function not working as intended

2016-09-16 Thread Kieren MacMillan
Hi David,

> But we are not talking about music functions (where the quite different
> "parser location" arguments are now usually passed implicitly) but
> markup commands here.

Ah! That would be the source of my confusion.

Thank you,
Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: conditional when-property function not working as intended

2016-09-16 Thread Kieren MacMillan
Hi David,

> By not specifying a default value?  I have absolutely no idea why you
> put `markp' as the default-value of your call to ly:chain-assoc-get.

Because this is somebody else’s code that I’m using, without (obviously) fully 
understanding what it does.
With your hint, I believe I can now modify the code so that it works as I would 
have expected it to in the first place.

Thanks,
Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: conditional when-property function not working as intended

2016-09-16 Thread David Kastrup
Kieren MacMillan  writes:

> Hi David,
>
>> It's necessary for functions taking "layout props" arguments?  Where
>> would that cause reason for doubt?
>
> I thought I recalled a recent update (say, in the past 2 years) in
> which those arguments were rendered unnecessary when writing certain
> music functions — but apparently, I’m mistaken.

But we are not talking about music functions (where the quite different
"parser location" arguments are now usually passed implicitly) but
markup commands here.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: conditional when-property function not working as intended

2016-09-16 Thread David Kastrup
Kieren MacMillan  writes:

> Hi David,
>
> Thank you for the helpful reply and documentation/explanation.
>
>> -- Function: ly:chain-assoc-get key achain default-value
>>  strict-checking
>> Return value for KEY from a list of alists ACHAIN.  If no entry is
>> found, return DEFAULT-VALUE or ‘#f’ if DEFAULT-VALUE is not
>> specified.  [...]
>> 
>> DEFAULT-VALUE is specified as markp, and a markup is never #f.  So your
>> condition is always true when the specified KEY cannot be found.
>
> So how could I code the when-property function so that it is false
> when the KEY cannot be found?

By not specifying a default value?  I have absolutely no idea why you
put `markp' as the default-value of your call to ly:chain-assoc-get.  It
does not serve any purpose conceivable to me, particularly since you are
only planning to use its value when finding the key, and the purpose of
the default-value is to be substituted when _not_ finding the key.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: conditional when-property function not working as intended

2016-09-16 Thread Kieren MacMillan
Hi David,

Thank you for the helpful reply and documentation/explanation.

> -- Function: ly:chain-assoc-get key achain default-value
>  strict-checking
> Return value for KEY from a list of alists ACHAIN.  If no entry is
> found, return DEFAULT-VALUE or ‘#f’ if DEFAULT-VALUE is not
> specified.  [...]
> 
> DEFAULT-VALUE is specified as markp, and a markup is never #f.  So your
> condition is always true when the specified KEY cannot be found.

So how could I code the when-property function so that it is false when the KEY 
cannot be found?

Thank you,
Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: conditional when-property function not working as intended

2016-09-16 Thread Kieren MacMillan
Hi David,

> It's necessary for functions taking "layout props" arguments?  Where
> would that cause reason for doubt?

I thought I recalled a recent update (say, in the past 2 years) in which those 
arguments were rendered unnecessary when writing certain music functions — but 
apparently, I’m mistaken.

Thanks,
Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: conditional when-property function not working as intended

2016-09-15 Thread David Kastrup
Kieren MacMillan  writes:

> Hi all,
>
> Solved my own problem (I think?): the modified version (below) appears to 
> work as expected.
>
> On a related topic: I [clearly] don’t understand when “layout props”
> is necessary, and when it’s not.

It's necessary for functions taking "layout props" arguments?  Where
would that cause reason for doubt?

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: conditional when-property function not working as intended

2016-09-15 Thread David Kastrup
Kieren MacMillan  writes:

> Hello all,
>
> In the snippet included below, I’m hoping the second line of the 
> scoreTitleMarkup will take no vertical space. If you comment out that line, 
> you’ll see that it *does* take no space, but when it’s included, so is the 
> 25mm spacing that is [I thought] conditional on the presence of a ‘testB’ 
> property in the property.
>
> Where is my code going wrong?
> More precisely, how can I make it work as intended?  =)
>
> Thanks,
> Kieren.
>
>   SNIPPET BEGINS
> \version "2.19.46"
>
> #(define-markup-command (when-property layout props symbol markp) (symbol? 
> markup?)
>   (if (chain-assoc-get layout props symbol markp)
>   (interpret-markup layout props markp)
>   empty-stencil))

 -- Function: ly:chain-assoc-get key achain default-value
  strict-checking
 Return value for KEY from a list of alists ACHAIN.  If no entry is
 found, return DEFAULT-VALUE or ‘#f’ if DEFAULT-VALUE is not
 specified.  [...]

DEFAULT-VALUE is specified as markp, and a markup is never #f.  So your
condition is always true when the specified KEY cannot be found.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: conditional when-property function not working as intended

2016-09-15 Thread Kieren MacMillan
Hi all,

Solved my own problem (I think?): the modified version (below) appears to work 
as expected.

On a related topic: I [clearly] don’t understand when “layout props” is 
necessary, and when it’s not.
Is this explained in the docs somewhere?

Thanks,
Kieren.

  SNIPPET BEGINS
\version "2.19.46"

#(define-markup-command (when-property layout props symbol markp) (symbol? 
markup?)
  (if (chain-assoc-get symbol props)
  (interpret-markup layout props markp)
  empty-stencil))

#(define-markup-command (mm-feed layout props amount) (number?)
 (let ((o-s (ly:output-def-lookup layout 'output-scale)))
   (ly:make-stencil "" '(0 . 0) (cons 0 (abs (/ amount o-s))

#(define-markup-command (put-mm layout props dir amount arg)
 (ly:dir? number? markup?) (interpret-markup layout props
   (markup #:put-adjacent Y dir arg #:mm-feed amount)))

\header {
  testA = "True!"
  testC = "True!"
}

\paper {
  scoreTitleMarkup = \markup \center-column {
\when-property #'header:testA { \put-mm #UP #25 \fromproperty 
#'header:testA }
\when-property #'header:testB { \put-mm #UP #25 \fromproperty 
#'header:testB }
\when-property #'header:testC { \put-mm #UP #25 \fromproperty 
#'header:testC }
  }
}

\score {
  c'4
}
  SNIPPET ENDS



Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


conditional when-property function not working as intended

2016-09-15 Thread Kieren MacMillan
Hello all,

In the snippet included below, I’m hoping the second line of the 
scoreTitleMarkup will take no vertical space. If you comment out that line, 
you’ll see that it *does* take no space, but when it’s included, so is the 25mm 
spacing that is [I thought] conditional on the presence of a ‘testB’ property 
in the property.

Where is my code going wrong?
More precisely, how can I make it work as intended?  =)

Thanks,
Kieren.

  SNIPPET BEGINS
\version "2.19.46"

#(define-markup-command (when-property layout props symbol markp) (symbol? 
markup?)
  (if (chain-assoc-get layout props symbol markp)
  (interpret-markup layout props markp)
  empty-stencil))

#(define-markup-command (mm-feed layout props amount) (number?)
 (let ((o-s (ly:output-def-lookup layout 'output-scale)))
   (ly:make-stencil "" '(0 . 0) (cons 0 (abs (/ amount o-s))

#(define-markup-command (put-mm layout props dir amount arg)
 (ly:dir? number? markup?) (interpret-markup layout props
   (markup #:put-adjacent Y dir arg #:mm-feed amount)))

\header {
  testA = "True!"
  testC = "True!"
}

\paper {
  scoreTitleMarkup = \markup \center-column {
\when-property #'header:testA { \put-mm #UP #25 \fromproperty 
#'header:testA }
\when-property #'header:testB { \put-mm #UP #25 \fromproperty 
#'header:testB }
\when-property #'header:testC { \put-mm #UP #25 \fromproperty 
#'header:testC }
  }
}

\score {
  c'4
}
  SNIPPET ENDS



Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user