]> git.donarmstrong.com Git - lilypond.git/commitdiff
Load the (scm display-lily) module into (lily), instead of from toplevel ly module.
authorNicolas Sceaux <nicolas.sceaux@free.fr>
Mon, 22 Jan 2007 21:14:35 +0000 (22:14 +0100)
committerNicolas Sceaux <nicolas.sceaux@free.fr>
Mon, 22 Jan 2007 21:14:35 +0000 (22:14 +0100)
input/regression/display-lily-tests.ly
ly/music-functions-init.ly
scm/define-music-display-methods.scm
scm/display-lily.scm
scm/music-functions.scm

index 516fbb4acbfa469b6c0438d7948c70b245e6b71a..5b2b4f198c0bdf6689966d489ddd69fa2dc459ba 100644 (file)
@@ -5,7 +5,8 @@
 %%%
 %%% Testing utilities
 %%%
-
+#(use-modules (scm display-lily))
+#(memoize-clef-names supported-clefs)
 #(define (parse-lily-and-compute-lily-string chr port)
   (let ((lily-string (call-with-output-string
                       (lambda (out)
          (if result-info
              result-info "BUG")
           input output))
-
-
-     (make-music 'SequentialMusic 'void #t)
-    
-   ))))
+     (make-music 'SequentialMusic 'void #t)))))
          
 test = 
 #(define-music-function (parser location result-info strings) (string? pair?)
@@ -57,7 +54,6 @@ test =
 stderr of this run." 
 }
 
-
 %% Sequential music
 \test "" ##[ { { a b } { c d } } #]            % SequentialMusic
 \test "" ##[ << { a b } { c d } >> #]          % SimultaneousMusic
index 2f4876b044e35c5840e337fcb7cb709ee9e9c36d..431012eaeeb913cbb5792bfea54a13122c3874f6 100644 (file)
@@ -175,9 +175,6 @@ cueDuring =
              'quoted-voice-direction dir
              'origin location))
 
-%% The following causes an error with guile 1.6.8 (guile 1.6.7 and 1.8.x are fine)
-#(use-modules (scm display-lily))
-
 displayLilyMusic =
 #(define-music-function (parser location music) (ly:music?)
    (newline)
index ea72b1147646fcbd6c81e4b720ac99dfe2467893..91be3e28b38bfc0892a5cea2261dbb2523c33f13 100644 (file)
@@ -900,10 +900,15 @@ Otherwise, return #f."
            ?unit-count)))
 
 ;;; \clef 
-(define clef-name-alist (map (lambda (name+vals)
-                              (cons (cdr name+vals)
-                                    (car name+vals)))
-                            supported-clefs))
+(define clef-name-alist #f)
+(define-public (memoize-clef-names clefs)
+  "Initialize `clef-name-alist', if not already set."
+  (if (not clef-name-alist)
+      (set! clef-name-alist
+            (map (lambda (name+vals)
+                   (cons (cdr name+vals)
+                         (car name+vals)))
+                 clefs))))
 
 (define-extra-display-method ContextSpeccedMusic (expr parser)
   "If `expr' is a clef change, return \"\\clef ...\"
index df0d04df7d97f8204e115178e22664c702e625bf..b7e253566aa54414529d9b099bacf6da21be42e9 100644 (file)
 ;;; Display methods are stored in the `display-methods' property of each music
 ;;; type.
 ;;;
-;;; - `display-lily-music' can be called to display a music expression using
-;;; LilyPond notation. `music->lily-string' return a string describing a music
-;;; expression using LilyPond notation.
+;;; - `music->lily-string' return a string describing a music expression using
+;;; LilyPond notation. The special variables *indent*, *previous-duration*,
+;;; and *force-duration* influence the indentation level and the display of
+;;; music durations.
 ;;;
 ;;; - `with-music-match' can be used to destructure a music expression, extracting
 ;;; some interesting music properties.
@@ -98,13 +99,6 @@ display method will be called."
                    music-type)))
       (format #f "%{ expecting a music expression: ~a %}" expr)))
 
-(define*-public (display-lily-music expr parser #:key force-duration)
-  (parameterize ((*indent* 0)
-                (*previous-duration* (ly:make-duration 2))
-                (*force-duration* force-duration))
-    (display (music->lily-string expr parser))
-    (newline)))
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;
 ;;; Music pattern matching
@@ -267,13 +261,13 @@ inside body."
 ;;;
 
 ;;; indentation
-(define *indent* (make-parameter 0))
+(define-public *indent* (make-parameter 0))
 
 ;;; set to #t to force duration printing
-(define *force-duration* (make-parameter #f))
+(define-public *force-duration* (make-parameter #f))
 
 ;;; last duration found
-(define *previous-duration* (make-parameter (ly:make-duration 2)))
+(define-public *previous-duration* (make-parameter (ly:make-duration 2)))
 
 ;;; Set to #t to force a line break with some kinds of expressions (eg sequential music)
 (define *force-line-break* (make-parameter #t))
index 76b8cf2edc710e8b9a7b803de6d0d28e5aa1fc5c..ed93b33fbdf396f759d60375ce3b80aa81a355a7 100644 (file)
@@ -186,6 +186,21 @@ Returns `obj'.
   (newline)
   obj)
 
+;;;
+;;; Scheme music expression --> Lily-syntax-using string translator
+;;;
+(use-modules (srfi srfi-39)
+             (scm display-lily))
+
+(define*-public (display-lily-music expr parser #:key force-duration)
+  "Display the music expression using LilyPond syntax"
+  (memoize-clef-names supported-clefs)
+  (parameterize ((*indent* 0)
+                (*previous-duration* (ly:make-duration 2))
+                (*force-duration* force-duration))
+    (display (music->lily-string expr parser))
+    (newline)))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (define-public (shift-one-duration-log music shift dot)