[Top][All Lists]

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

Named book file suffixes -- regtest?

From: Carl D. Sorensen
Subject: Named book file suffixes -- regtest?
Date: Fri, 27 Feb 2009 08:12:45 -0700

Marek Klein has made a patch that allows the use of user-defined name
suffixes for lilypond-book output files and eliminates
automatically-generated numbers as part of the file name if the user
specifies the suffixes.

The code he has shared is the following:

> Thank you, 
> now it works as expected:
> (define counter-alist '())
> (define (print-book-with parser book process-procedure)
>   (let*
>       ((paper (ly:parser-lookup parser '$defaultpaper))
>        (layout (ly:parser-lookup parser '$defaultlayout))
>        (output-suffix (ly:parser-lookup parser 'output-suffix))
>        (output-count (assoc-ref counter-alist output-suffix))
>        (base (ly:parser-output-name parser)) )
>       (if (string? output-suffix)
>     (set! base (format "~a-~a" base (string-regexp-substitute
>                        "[^a-zA-Z0-9-]" "_" output-suffix))))
>     ;; must be careful: output-count is under user control.
>     (if (not (integer? output-count))
>     (set! output-count 0))
>     (if (> output-count 0)
>     (set! base (format #f "~a-~a" base output-count)))
>     (set! counter-alist (assoc-set! counter-alist output-suffix (1+
> output-count)))

Marek -- can you check to make sure the code doesn't break if -1 is
specified as a suffix?  I'm afraid that would pass as an integer, but not
pass as >0, so nothing would happen.

> What about set! versus ly:parser-define! ?

Can somebody answer Marek's question about set! vs ly:parser-define! ?  I
can't, so I don't want to hazard a guess.

Also, this code needs a regtest, IMO.  But the difference in the code will
be in the names of the files produced, rather than the graphical output.
Will this still be caught by make-check?



P.S. Marek, you'll need to write a regression test and a documentation
change to go along with the code change before it can be pushed.


reply via email to

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