--- latest/output-ps.scm	2006-04-03 20:34:22.476876800 -0400
+++ /lily/scm/output-ps.scm	2006-04-03 21:18:51.845240000 -0400
@@ -42,6 +42,7 @@
 
 (use-modules (guile)
 	     (ice-9 regex)
+	     (ice-9 syncase)
 	     (srfi srfi-1)
 	     (srfi srfi-13)
 	     (scm framework-ps)
@@ -72,6 +73,23 @@
 (define (numbers->string4 numlist)
   (string-join (map str4 numlist) " "))
 
+(define-syntax expf
+  (syntax-rules (tostr4)
+    ((expf (done ...)) (format done ...))
+    
+    ((expf (done ...) (tostr4 n) terms ...)
+     (expf (done ... (str4 n)) terms ...))
+    
+    ((expf (done ...) (tostr4 n1 n2 ...) terms ...)
+     (expf (done ... (str4 n1)) (tostr4 n2 ...) terms ...))
+    ((expf (done ...) term terms ...)
+     (expf (done ... term) terms ...))))
+
+(define-syntax expand-format
+  (syntax-rules ()
+    ((_ terms ...) (expf () terms ...))))
+
+
 ;; FIXME: lily-def
 (define-public (ps-string-def prefix key val)
   (format #f "/ ~a~a (~a) def\n"
@@ -112,32 +130,22 @@
    (round4 radius) (round4 thick)))
 
 (define (dashed-line thick on off dx dy)
-  (format #f "~a ~a ~a [ ~a ~a ] 0 draw_dashed_line"
-   (str4 dx)
-   (str4 dy)
-   (str4 thick)
-   (str4 on)
-   (str4 off)))
+  (expand-format #f "~a ~a ~a [ ~a ~a ] 0 draw_dashed_line"
+   (tostr4 dx dy thick on off)))
 
 ;; what the heck is this interface ?
 (define (dashed-slur thick on off l)
-  (format #f "~a ~a [ ~a ~a ] 0 draw_dashed_slur"
+  (expand-format #f "~a ~a [ ~a ~a ] 0 draw_dashed_slur"
 	  (string-join (map number-pair->string4 l) " ")
-	  (str4 thick)
-	  (str4 on)
-	  (str4 off)))
+	  (tostr4 thick on off)))
 
 (define (dot x y radius)
-  (format #f " ~a draw_dot"
-   (numbers->string4 (list x y radius))))
+  (expand-format #f " ~a draw_dot"
+   (tostr4 x y radius)))
 
 (define (draw-line thick x1 y1 x2 y2)
-  (format #f "1 setlinecap 1 setlinejoin ~a setlinewidth ~a ~a moveto ~a ~a lineto stroke"
-   (str4 thick)
-   (str4 x1)
-   (str4 y1)
-   (str4 x2)
-   (str4 y2)))
+  (expand-format #f "1 setlinecap 1 setlinejoin ~a setlinewidth ~a ~a moveto ~a ~a lineto stroke"
+		 (tostr4 thick x1 y1 x2 y2)))
 
 (define (embedded-ps string)
   string)
@@ -305,10 +313,6 @@
 
 
 (define (zigzag-line centre? zzw zzh thick dx dy)
-  (format #f "~a ~a ~a ~a 0 0 ~a ~a draw_zigzag_line"
+  (expand-format #f "~a ~a ~a ~a 0 0 ~a ~a draw_zigzag_line"
    (if centre? "true" "false")
-   (str4 zzw)
-   (str4 zzh)
-   (str4 thick)
-   (str4 dx)
-   (str4 dy)))
+   (tostr4 zzw zzh thick dx dy)))
