[PATCH] Issues 714 and 404: Add greater user flexibility in naming output files using output-suffix. output name handling now moved to its own procedure in lily-library.scm |
[ Thread Index |
Date Index
| More lilynet.net/frogs Archives
]
- Subject: [PATCH] Issues 714 and 404: Add greater user flexibility in naming output files using output-suffix. output name handling now moved to its own procedure in lily-library.scm
- From: Ian Hulin <ian@xxxxxxxxxxxx>
- Date: Thu, 6 Aug 2009 16:20:52 +0100
Signed-off-by: Ian Hulin <ian@xxxxxxxxxxxx>
---
scm/lily-library.scm | 49 ++++++++++++++++++++++++++++---------------------
1 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/scm/lily-library.scm b/scm/lily-library.scm
index ca52916..3bc47ef 100644
--- a/scm/lily-library.scm
+++ b/scm/lily-library.scm
@@ -127,28 +127,35 @@
(ly:make-score music))
+(define (get-outfile-name parser base)
+(let*
+ ((output-suffix (ly:parser-lookup parser 'output-suffix))
+ (counter-alist (ly:parser-lookup parser 'counter-alist))
+ (output-count (assoc-ref counter-alist output-suffix))
+ (result base ) )
+
+ (if (string? output-suffix)
+ (set! result (format "~a-~a" base (string-regexp-substitute
+ "[^a-zA-Z0-9-]" "_" output-suffix))))
+ ;; must be careful: assoc-ref may return '().
+ (if (not (integer? output-count))
+ (set! output-count 0))
+
+ (if (> output-count 0)
+ (set! result (format #f "~a-~a" result output-count)))
+
+ (ly:parser-define!
+ parser 'counter-alist (assoc-set! counter-alist output-suffix (1+ output-count)))
+ result ) )
+
(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))
- (counter-alist (ly:parser-lookup parser 'counter-alist))
- (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))
+ (base (ly:parser-output-name parser))
+ (outfile-name (get-outfile-name parser base)) )
- (if (> output-count 0)
- (set! base (format #f "~a-~a" base output-count)))
- (ly:parser-define! parser 'counter-alist (assoc-set! counter-alist output-suffix (1+ output-count)))
- (process-procedure book paper layout base)
- ))
+ (process-procedure book paper layout outfile-name) ) )
(define-public (print-book-with-defaults parser book)
(print-book-with parser book ly:book-process))
@@ -638,16 +645,16 @@ possibly turned off."
(define-public (version-not-seen-message input-file-name)
(ly:message
- "~a:0: ~a: ~a"
+ "~a:0: ~a ~a"
input-file-name
- (_ "warning: ")
+ (_ "warning:")
(format #f
(_ "no \\version statement found, please add~afor future compatibility")
(format #f "\n\n\\version ~s\n\n" (lilypond-version)))))
(define-public (old-relative-not-used-message input-file-name)
(ly:message
- "~a:0: ~a: ~a"
+ "~a:0: ~a ~a"
input-file-name
- (_ "warning: ")
+ (_ "warning:")
(_ "old relative compatibility not used")))
--
1.6.0.4
--------------000101040801090500050907
Content-Type: text/plain;
name="Exsultate.ly"
Content-Disposition: inline;
filename="Exsultate.ly"
Content-Transfer-Encoding: base64
XGluY2x1ZGUgImVuZ2xpc2gubHkiClx2ZXJzaW9uICIyLjEyLjEiClxoZWFkZXIgewogIHRp
dGxlID0gIkV4c3VsdGF0ZSwgSnViaWxhdGUiCiAgc3VidGl0bGUgPSAiTW90ZXQiCiAgc3Vi
c3VidGl0bGUgPSAiSy4gMTY1IgogIGluc3RydW1lbnQgPSAiU29wcmFubyBTb2xvIGFuZCBP
cmNoZXN0cmEiCiAgY29tcG9zZXIgPSAiVy4gQS4gTW96YXJ0IgogIG9wdXMgPSAiS1YgMTY1
Igp9ClxwYXBlciB7CiB9ClxtaWRpIHsKICB9ClxsYXlvdXR7CiAgfQptb3ZvbmVzZXR0aW5n
cyA9IHsKIFxrZXkgZiBcbWFqb3IKIFx0aW1lIDQvNAogXHRlbXBvICJBbGxlZ3JvIiA0PTEy
OAogICAKIH0Kb2JvZXNtb3ZvbmVNdXNpYyA9IFx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gIH0KICAgICBcbmV3IFN0YWZmID0gaG9ybnNt
b3ZvbmUgXHdpdGgge2luc3RydW1lbnROYW1lID0gIjIgQ29ybmkgaW4gRiIKICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pZGlJbnN0cnVtZW50ID0gImZyZW5jaCBo
b3JuIn0gCiAgICAgewogICAgICAgIFx0cmFuc3Bvc2l0aW9uIGYgXHRpbWUgNC80IFx0ZW1w
byAiQWxsZWdybyIgXGhvcm5zbW92b25lTXVzaWMKICAgICB9CiAgICAgXG5ldyBHcmFuZFN0
YWZmICA8PAogICAgICAgIFxuZXcgU3RhZmYgPSBWbG5vbmVtb3ZvbmUgXHdpdGgge2luc3Ry
dW1lbnROYW1lID0gIlZpb2xpbm8gSSIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgbWlkaUluc3RydW1lbnQgPSAidmlvbGluIn0KICAgICAgICB7CiAgICAg
ICAgICBcbW92b25lc2V0dGluZ3MgXFZsbm9uZW1vdm9uZU11c2ljCiAgICAgICAgfQogICAg
ICAgIFxuZXcgU3RhZmYgPSBWbG50d29tb3ZvbmUgXHdpdGgge2luc3RydW1lbnROYW1lID0g
IlZpb2xpbm8gSUkiCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
IG1pZGlJbnN0cnVtZW50ID0gInZpb2xpbiJ9CiAgICAgICAgewogICAgICAgICAgXG1vdm9u
ZXNldHRpbmdzIFxWbG50d29tb3ZvbmVNdXNpYwogICAgICAgIH0KICAgICAgIAogICAgICA+
PgogICAgIFxuZXcgU3RhZmYgPSBWbGFtb3ZvbmUgXHdpdGgge2luc3RydW1lbnROYW1lID0g
IlZpb2xhIgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pZGlJbnN0
cnVtZW50ID0gInZpb2xhIn0KICAgICB7CiAgICAgICBcbW92b25lc2V0dGluZ3MgXFZsYW1v
dm9uZU11c2ljCiAgICAgfQ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yBJIgogICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaWRpSW5zdHJ1bWVudCA9
ICJ2aW9saW4ifQogICAgICAgIHsKICAgICAgICAgIFxtb3Z0d29zZXR0aW5ncyBcVmxub25l
bW92dHdvTXVzaWMKICAgICAgICB9CiAgICAgICAgXG5ldyBTdGFmZiA9IFZsbnR3b21vdnR3
byBcd2l0aCB7aW5zdHJ1bWVudE5hbWUgPSAiVmlvbGlubyBJSSIKICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgbWlkaUluc3RydW1lbnQgPSAidmlvbGluIn0K
ICAgICAgICB7CiAgICAgICAgICBcbW92dHdvc2V0dGluZ3MgXFZsbnR3b21vdnR3b011c2lj
CiAgICAgICAgfQogICAgICAgCiAgICAgID4+CiAgICAgXG5ldyBTdGFmZiA9IFZsYW1vdnR3
byBcd2l0aCB7aW5zdHJ1bWVudE5hbWUgPSAiVmlvbGEiCiAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgbWlkaUluc3RydW1lbnQgPSAidmlvbGEifQogICAgIHsKICAg
ICAgIFxtb3Z0d29zZXR0aW5ncyBcVmxhbW92dHdvTXVzaWMKICAgICB9CiAgICAgXG5ldyBT
dGFmZiA9IFNvcHJhbm9tb3Z0d28gXHdpdGgge2luc3RydW1lbnROYW1lID0gIlNvcHJhbm8i
CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pZGlJbnN0cnVtZW50
ID0gInZvaWNlIG9vaHMifQogICAgICB7CiAgICAgICAgXG1vdnR3b3NldHRpbmdzIFxTb3By
YW5vbW92dHdvTXVzaWMKICAgICAgfQogICAgICBcbmV3IFN0YWZmID0gQkNtb3Z0d28gXHdp
dGggeyBpbnN0cnVtZW50TmFtZSA9ICJCYXNzbyBlZCBPcmdhbm8iCiAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgIG1pZGlJbnN0cnVtZW50ID0gImNvbnRyYWJhc3MifQog
ICAgICB7CiAgICAgICAgXG1vdnR3b3NldHRpbmdzIFxCQ21vdnR3b011c2ljCiAgICAgIH0K
ICAgICAgPj4KICAgIH0KICB9CiAgICAKCn0KfQo=
--------------000101040801090500050907
Content-Type: text/plain;
name="Test-output-suffix.ly"
Content-Disposition: inline;
filename="Test-output-suffix.ly"
Content-Transfer-Encoding: base64
XHZlcnNpb24gIjIuMTIuMSIKXGhlYWRlciB7CiAgdGl0bGUgPSAiRXhzdWx0YXRlLCBKdWJp
bGF0ZSIKICBzdWJ0aXRsZSA9ICJNb3RldCIKICBzdWJzdWJ0aXRsZSA9ICJLLiAxNjUiCiAg
aW5zdHJ1bWVudCA9ICJTb3ByYW5vIFNvbG8gYW5kIE9yY2hlc3RyYSIKICBjb21wb3NlciA9
ICJXLiBBLiBNb3phcnQiCiAgb3B1cyA9ICJLViAxNjUiCn0KbW92b25lc2V0dGluZ3MgPSB7
CiBca2V5IGYgXG1ham9yCiBcdGltZSA0LzQKIFx0ZW1wbyAiQWxsZWdybyIgND0xMjgKICAg
CiB9Cm1vdnR3b3NldHRpbmdzID0gewogXGtleSBhIFxtYWpvcgogXHRpbWUgMy80CiBcdGVt
cG8gIkFuZGFudGUiIDQ9NzIKIH0gCkJDbW92b25lTXVzaWMgPSBccmVsYXRpdmUgYyB7CiAg
XG1vdm9uZXNldHRpbmdzCiAgXGNsZWYgYmFzcyBmOCBmIGYgZiBmIGYgZiBmIHwKfSAKQkNt
b3Z0d29NdXNpYyA9IFxyZWxhdGl2ZSBjIHsKXG1vdnR3b3NldHRpbmdzCiAgXGNsZWYgYmFz
cwogIFxwYXJ0aWFsIDggcjgKICByNCBhJzQgYSwgfAp9CiMoZGVmaW5lIG91dHB1dC1zdWZm
aXggIkFsbGVncm8iKQpcYm9vayB7ClxoZWFkZXIgewoJCXN1YnRpdGxlID0gIkkgQWxsZWdy
byIKCX0KXHNjb3JlIHsKCQoJXEJDbW92b25lTXVzaWMKfQp9CiMoZGVmaW5lIG91dHB1dC1z
dWZmaXggJygpKSAKXGJvb2sgewpcaGVhZGVyIHsKCXN1YnRpdGxlID0gIklJLiBBbmRhbnRl
Igp9ClxzY29yZSB7CglcQkNtb3Z0d29NdXNpYwp9Cn0KCg==
--------------000101040801090500050907--
---
----
Join the Frogs!