[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 ]


Signed-off-by: Ian Hulin <ian@xxxxxxxxxxxx>
---
 scm/lily-library.scm |   38 +++++++++++++++++++++++---------------
 1 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/scm/lily-library.scm b/scm/lily-library.scm
index adb2bdf..9e12968 100644
--- a/scm/lily-library.scm
+++ b/scm/lily-library.scm
@@ -130,27 +130,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))
-       (count (ly:parser-lookup parser 'output-count))
        (base (ly:parser-output-name parser))
-       (output-suffix (ly:parser-lookup parser 'output-suffix)) )
+       (outfile-name (get-outfile-name parser base)) )
 
-    (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? count))
-	(set! count 0))
-
-    (if (> count 0)
-	(set! base (format #f "~a-~a" base count)))
-    (ly:parser-define! parser 'output-count (1+ 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))
-- 
1.6.0.4


--------------000700000700000201050408--

---

----
Join the Frogs!


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/