lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Toc with counter


From: Pierre Perol-Schneider
Subject: Re: Toc with counter
Date: Tue, 3 Jul 2018 01:05:24 +0200

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 <address@hidden>:
Pierre Perol-Schneider <address@hiddencom> 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]