lilypond-user
[Top][All Lists]
Advanced

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

Re: Naming output files


From: Reinhold Kainhofer
Subject: Re: Naming output files
Date: Thu, 26 Feb 2009 11:32:15 +0100
User-agent: KMail/1.11.0 (Linux/2.6.27-11-generic; KDE/4.2.0; i686; ; )

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Donnerstag, 26. Februar 2009 10:58:19 Mats Bengtsson wrote:
> The obvious follow-up question is, why you get the additional number
> even when the file name would
> be unique without the number, i.e. when the output-suffix is set
> differently for each book block.
> I realize that it probably requires a few more lines of code in the
> LilyPond implementation to handle
> the book-keeping, but it would still be a valuable feature.

It would actually be quite simple to implement: In scm/lily-library.scm in the 
print- book-with function, instead of storing the file count as a number in 
'output-count, store it in an alist (which is set as the 'output-count parser 
variable), with the suffix as key. This way, the counting is per suffix and 
we'll automatically not append the number for the first file with a given 
suffix...

I think this would be quite a nice task or a frog, so I'm not coding it 
myself, just giving a few pointers... The way to work with the alist (that's 
Scheme's idea of a Hash) can be seen e.g. in my counter snippet on LSR:
http://lsr.dsi.unimi.it/LSR/Item?id=543

All you need to do is to use assoc-ref instead of count and ly:parser-define! 
(instead of the set! in the counter example) with assoc-set! to set one entry 
of the hash / alist. The key for the alist would be the suffix. The rest of 
the function doesn't even need to be changed...

Cheers,
Reinhold

PS: Why do we call (string-regexp-substitute "[^a-zA-Z0-9-]" "_" output-
suffix) on the suffix? This makes it impossible to use e.g. "Flöte" as the 
suffix, which is German for Flute! Similar, any other accented or non-latin 
letter is not possible and will be replaced by a "_". Similarly, spaces or + 
etc. are also not allowed... I understand that some letters may cause problems 
(in particular, ":", "/", "\" and maybe also "?" and "*"), but I don't think 
this is a reason to prevent everything other than latin letters and numbers.

- -- 
- ------------------------------------------------------------------
Reinhold Kainhofer, address@hidden, http://reinhold.kainhofer.com/
 * Financial & Actuarial Math., Vienna Univ. of Technology, Austria
 * http://www.fam.tuwien.ac.at/, DVR: 0005886
 * LilyPond, Music typesetting, http://www.lilypond.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iD8DBQFJpm+wTqjEwhXvPN0RAgD5AJ9Yevrt36GTtR544ti788eerN3+pACgjXuT
oNwcsvyQzNkBe8JVjnixem0=
=//Rx
-----END PGP SIGNATURE-----




reply via email to

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