How about :

\version "2.19.82"

#(set-default-paper-size "a6")

#(define counter-alist '())

#(define-markup-command (counter layout props name) (string?)
  "Increases and prints out the value of the given counter named @var{name}.
  If the counter does not yet exist, it is initialized with 1."
  (let* ((oldval (assoc-ref counter-alist name))
         (newval (if (number? oldval) (+ oldval 1) 1)))
  (set! counter-alist (assoc-set! counter-alist name newval))
  (interpret-markup layout props
    (markup (number->string (round newval))))))

\markup {
  \column {
    "counter :"
    \fill-line {
      \counter #"counter" \counter #"counter" \counter #"counter"
      \counter #"counter" \counter #"counter" \counter #"counter"
      \counter #"counter"
    }
    \null
    "\pattern :"
    \fill-line { \pattern #7 #X #7 \counter #"pattern" }
    \null
    "\fill-with-pattern :"
    \fill-with-pattern #7 #RIGHT \counter #"fill-with-pattern" \null \null
  }
}


2018-07-02 23:47 GMT+02:00 David Kastrup <d...@gnu.org>:

> Pierre Perol-Schneider <pierre.schneider.pa...@gmail.com> writes:
>
> >> ... counter shows only pairs.
> > " counter shows only even numbers"... sorry.
> > Pierre
>
> This is an abomination.
>
> Tracker issue: 5365 (https://sourceforge.net/p/testlilyissues/issues/5365/
> )
> Rietveld issue: 357740043 (https://codereview.appspot.com/357740043)
> Issue description:
>   Avoid multiple evaluation of markups \pattern \fill-with-pattern
>   For markup commands with side effects like counters, that could end
>   up being a nuisance.
>
> Want to write a nice concise regtest?
>
> --
> David Kastrup
>
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to