Hi Andrew,

2016-05-05 5:57 GMT+02:00 Andrew Bernard <andrew.bern...@gmail.com>:
> David Nalesnik and various others I think have written scheme to allow you
> to skip a range of numbers when page numbering, or to give a direct list of
> page numbers to be used.

Right now I don't remember such code. Just to refresh my memory,
please provide a link.

> I want to be able to specify something like this
> list to only have the specified ranges printed, all in one continous score
> (yes, there is a use case for this!).
>
> ((1 24) (52 64) (70 80) (100 110))
>
> Of course, alternatively you could have list of ranges to skip rather than
> include.


How about:

\version "2.19.36"

#(define-markup-command
  (page-range-fromproperty layout props page-ranges symbol)
  (list? symbol?)

  (define (my-nmbrs rngs)
    (append-map (lambda (e) (iota (- (last e) (- (car e) 1)) (car e) 1)) rngs))

  (let ((m (chain-assoc-get symbol props))
        (page-nmbr (chain-assoc-get 'page:page-number props -1)))
    (if (markup? m)
        ;; prevent infinite loops by clearing the interpreted property:
        (interpret-markup
          layout
          (cons
            (list (cons symbol `(,property-recursive-markup ,symbol)))
            props)
          (if (and (string? m)
                   (number? (string->number m))
                   (= (string->number m) page-nmbr))
              (format #f "~a"
                (let ((my-ranges (my-nmbrs page-ranges)))
                  ;; if entries from `page-ranges' are done, fall back to
                  ;; usual page-numbering
                  (if (> (length my-ranges) (1- page-nmbr))
                      (list-ref my-ranges (1- page-nmbr))
                      page-nmbr)))
               m))
        empty-stencil)))

#(define ranges '((1 24) (52 64) (70 80) (100 110)))

\paper {
  oddHeaderMarkup = \markup
  \fill-line {
    ""
    \on-the-fly #not-part-first-page \fromproperty #'header:instrument
    \on-the-fly #print-page-number-check-first
      \page-range-fromproperty #ranges #'page:page-number-string
  }

  %% evenHeaderMarkup would inherit the value of
  %% oddHeaderMarkup if it were not defined here
  evenHeaderMarkup = \markup
  \fill-line {
    \on-the-fly #print-page-number-check-first
      \page-range-fromproperty #ranges #'page:page-number-string
    \on-the-fly #not-part-first-page \fromproperty #'header:instrument
    ""
  }
}


\new Staff \repeat unfold 70 { c''1 \pageBreak }


HTH,
  Harm

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

Reply via email to