Counters in markup (LSR 543) - getcounter addition

2012-12-19 Thread Olivier Biot
Hi all,

I propose to extend LSR snippet 543 (counters in markup,
http://lsr.dsi.unimi.it/LSR/Snippet?id=543) by adding a "getcounter"
command that does NOT increment a counter when called (as opposed to the
current "counter" command):

#(define-markup-command (getcounter layout props name) (string?)
  "Prints out the value of the given counter named @var{name}.
  If the counter does not yet exist, return 0."
  (let* ((curval (assoc-ref counter-alist name))
 (theval (if (number? curval) curval 0)))
  (interpret-markup layout props
(markup (number->string theval)


I hope it will be useful to others as well.

Best regards,

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


Re: Counters in markup (LSR 543) - getcounter addition

2012-12-20 Thread Olivier Biot
On Wed, Dec 19, 2012 at 5:30 PM, Olivier Biot wrote:

> Hi all,
>
> I propose to extend LSR snippet 543 (counters in markup,
> http://lsr.dsi.unimi.it/LSR/Snippet?id=543) by adding a "getcounter"
> command that does NOT increment a counter when called (as opposed to the
> current "counter" command):
>
> #(define-markup-command (getcounter layout props name) (string?)
>   "Prints out the value of the given counter named @var{name}.
>   If the counter does not yet exist, return 0."
>   (let* ((curval (assoc-ref counter-alist name))
>  (theval (if (number? curval) curval 0)))
>   (interpret-markup layout props
> (markup (number->string theval)
>
>
> I hope it will be useful to others as well.
>

Dear all,

I realize I ran into a known limitation of LSR snippet 543 severely
impairing its usability:
http://lists.gnu.org/archive/html/bug-lilypond/2010-10/msg00144.html

Is there a command to defer / force parsing a command at the "parsing"
stage (as explained in this October 2010 thread), or is the only option to
replace all calls to \counter with the cumbersome snippet below:

#(set! sequence-number (1+ sequence-number))
b'1^\markup\score-sequence #sequence-number

Best regards,

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