From: Nicolas Sceaux Date: Tue, 16 Aug 2005 18:30:32 +0000 (+0000) Subject: * input/no-notation/display-lily-tests.ly: remove X-Git-Tag: release/2.7.6~37 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4ffbb7b09303b7ba9e8bc9d166ff4bcc994b412c;p=lilypond.git * input/no-notation/display-lily-tests.ly: remove display-lily-init call. * ly/music-functions-init.ly (displayLilyMusic): move display-lily-init call at top level, so that the user should not have to call it. * scm/define-music-display-methods.scm (note-name->lily-string): retrieve note names directly from pitchnames using new function `rassoc'. (display-lily-init): note names list construction removed. --- diff --git a/ChangeLog b/ChangeLog index 8799e980a4..c4c268f350 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2005-08-16 Nicolas Sceaux + + * input/no-notation/display-lily-tests.ly: delete + display-lily-init call. + + * ly/music-functions-init.ly (displayLilyMusic): move + display-lily-init call at top level, so that the user should not + have to call it. + + * scm/define-music-display-methods.scm (note-name->lily-string): + retrieve note names directly from pitchnames using new function `rassoc'. + (display-lily-init): note names list construction removed. + 2005-08-16 Han-Wen Nienhuys * Documentation/topdocs/NEWS.tely (Top): add entry for percent diff --git a/input/no-notation/display-lily-tests.ly b/input/no-notation/display-lily-tests.ly index c0372f243d..60f856cf2b 100644 --- a/input/no-notation/display-lily-tests.ly +++ b/input/no-notation/display-lily-tests.ly @@ -1,4 +1,4 @@ -\version "2.7.2" +\version "2.7.6" #(use-modules (srfi srfi-13) (ice-9 format)) @@ -34,13 +34,6 @@ #(define (lily-string->markup str) (make-column-markup (string-split str #\NewLine))) -initTest = #(def-music-function (parser location) () - ;; Before using display-lily-music, it must be - ;; inited using display-lily-init - (display-lily-init parser) - (set! test-number 0) - (make-music 'SequentialMusic)) - test = #(def-music-function (parser location result-info strings) (string? pair?) (display-lily-init parser) (let ((input (car strings)) @@ -92,7 +85,6 @@ test = #(def-music-function (parser location result-info strings) (string? pair? } } { - \initTest %% Sequential music \test #"" ##[ { { a b } { c d } } #] % SequentialMusic \test #"" ##[ << { a b } { c d } >> #] % SimultaneousMusic diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index e6ad784786..d211476bbb 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -52,9 +52,9 @@ displayMusic = %#(use-modules (scm display-lily))invalid module name for use-syntax ((srfi srfi-39)) #(use-modules (scm display-lily)) +#(display-lily-init parser) displayLilyMusic = #(def-music-function (parser location music) (ly:music?) - (display-lily-init parser) (display-lily-music music) music) diff --git a/scm/define-music-display-methods.scm b/scm/define-music-display-methods.scm index c6ee229821..625e6e933a 100644 --- a/scm/define-music-display-methods.scm +++ b/scm/define-music-display-methods.scm @@ -11,12 +11,10 @@ (define-module (scm display-lily)) - ;;; `display-lily-init' must be called before using `display-lily-music'. It ;;; takes a parser object as an argument. (define-public (display-lily-init parser) (*parser* parser) - (set-note-names! (ly:parser-lookup (*parser*) 'pitchnames)) #t) ;;; @@ -80,12 +78,14 @@ ;;; ;;; pitch names ;;; -(define note-names '()) -(define (set-note-names! pitchnames) - (set! note-names (map-in-order (lambda (name+lypitch) - (cons (cdr name+lypitch) (car name+lypitch))) - pitchnames))) +;; It is a pity that there is no rassoc in Scheme. +(define* (rassoc item alist #:optional (test equal?)) + (do ((alist alist (cdr alist)) + (result #f result)) + ((or result (null? alist)) result) + (if (and (car alist) (test item (cdar alist))) + (set! result (car alist))))) (define (note-name->lily-string ly-pitch) ;; here we define a custom pitch= function, since we do not want to @@ -93,9 +93,9 @@ (define (pitch= pitch1 pitch2) (and (= (ly:pitch-notename pitch1) (ly:pitch-notename pitch2)) (= (ly:pitch-alteration pitch1) (ly:pitch-alteration pitch2)))) - (let ((result (assoc ly-pitch note-names pitch=))) ;; assoc from srfi-1 + (let ((result (rassoc ly-pitch (ly:parser-lookup (*parser*) 'pitchnames) pitch=))) (if result - (cdr result) + (car result) #f))) (define (octave->lily-string pitch)