Recently I posted a Scheme function to do outline list numbering in markup for one of the list members. Completely unbeknownst to me, LSR 543 shows a counter done in Scheme for markup. My code was developed entirely independently. It's also more of a full outliner than a plain counter. But LSR 543 is highly instructive.
My question is, where does the function make-counter-markup come from in this code? Is this something that is created by the define-markup-command function internally? LSR 543 code is appended for reference.
If you have say
#(define-markup-command (whizzo layout props)...
does a function make-whizzo-markup get defined? What is the actual purpose of such a function, if that is the case?
Where is this in the manuals?
Andrew
#(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 newval)))))
#(define-markup-command (setcounter layout props name value) (string? number?)
"Set the given counter named @var{name} to the given @var{value} and prints
out the value. The counter does not yet have to exist."
(set! counter-alist (assoc-set! counter-alist name (- value 1)))
(interpret-markup layout props (make-counter-markup name)))