[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 Amended to use ly:get-assoc to pick up initial value of parser variable output-count and remove redundant check on initial call. Accented characters now supported in output-suffix.

[ Thread Index | Date Index | More lilynet.net/frogs Archives ]


---
 scm/lily-library.scm |   37 +++++++++++++++++++++++--------------
 1 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/scm/lily-library.scm b/scm/lily-library.scm
index e7f1d29..4622982 100644
--- a/scm/lily-library.scm
+++ b/scm/lily-library.scm
@@ -134,27 +134,36 @@
 
   (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-get output-suffix counter-alist 0))
+     (result base ) )
+    ;; Allow all ASCII alphanumerics,
+    ;;   including accents
+    (if (string? output-suffix)
+    (set! result (format "~a-~a" base (string-regexp-substitute
+     "[^-[:alnum:]]" "_" output-suffix))))
+
+    ;; assoc-get call will always have returned a number
+    (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


--------------050904050203000206000301--

---

----
Join the Frogs!


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