[Top][All Lists]

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

Re: Named book file suffixes -- regtest?

From: Reinhold Kainhofer
Subject: Re: Named book file suffixes -- regtest?
Date: Fri, 27 Feb 2009 19:53:16 +0100
User-agent: KMail/1.11.0 (Linux/2.6.27-11-generic; KDE/4.2.0; i686; ; )

Hash: SHA1

On Freitag, 27. Februar 2009 16:12:45 Carl D. Sorensen wrote:
> 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.

To be exact, it does not eliminate the numbering, but it changes the numbering 
to be separate within each suffix. So if you use a different suffix for each 
output file, you won't see any numbering, but if you use the same suffix for 
two files, they will still be numbered and no output file will be overwritten 
(which was the main concern for adding the numbering).

> 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.

Actually, that's not true. -1 will be the key for the lookup in the alist... 
There is no comparison with the actual suffix, just with the value that was 
looked up from the alist, so I don't think that case would be a problem.

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

I would rather use ly:parser-define!, if we can find out why it doesn't work. 
It's simply cleaner than using a global variable...

> 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?

Good question. I have absolutely no idea, though.

> 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.

Yes, that's also quite some work, but it gives you a good insight into the 
whole lilypond distribution... 
What I usually do is to simply search the whole lilypond directory for the 
keyword (output-suffix in this case) and check all files where that keyword 
appears manually to see whether any of them needs some updates, too.

You can ignore all files in directories called out/ or out-www/.

- -- 
- ------------------------------------------------------------------
Reinhold Kainhofer, address@hidden,
 * Financial & Actuarial Math., Vienna Univ. of Technology, Austria
 *, DVR: 0005886
 * LilyPond, Music typesetting,
Version: GnuPG v1.4.9 (GNU/Linux)


reply via email to

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