1;;;LilyPondInclude 2(define-once LilyPondInclude::return #f) 3(let* ((tag "LilyPondInclude")(params LilyPondInclude::params) (includes (d-DirectiveGet-score-data tag))) 4 (define (setinclude) ;;; sets the LilyPond to include all the files listed in Directive-score-data 5 (d-SetSaved #f) 6 (d-DirectivePut-score-display tag (_ "Included LilyPond Files")) 7 (d-DirectivePut-score-override tag (logior DENEMO_OVERRIDE_AFFIX DENEMO_OVERRIDE_DYNAMIC)) 8 (let ((prefix "")) 9 (define (do-append str) 10 (set! prefix (string-append prefix "\\include \"" str "\"\n"))) 11 (for-each do-append (eval-string (d-DirectiveGet-score-data tag))) 12 (d-DirectivePut-score-prefix tag prefix))) 13 14 (define (update-data include) ;; if include is not in includes: adds include to the Directive-score-data and updates LilyPond 15 (if (not (member include includes)) 16 (begin 17 (set! includes (cons include includes)) 18 (d-DirectivePut-score-data tag (string-append "'" (format #f "~s" includes))) 19 (setinclude)))) 20 21 (define (delete-include name) ;; removes name from the Directive-score-data and updates LilyPond 22 (if (member name includes) 23 (begin 24 (set! includes (delete name includes)) 25 (if (null? includes) 26 (d-DirectiveDelete-score tag) 27 (begin 28 (d-DirectivePut-score-data tag (string-append "'" (format #f "~s" includes))) 29 (setinclude)))))) 30 31 ;;;;;start of procedure 32 (set! LilyPondInclude::return #f) ;;; "return" value 33 (if includes 34 (set! includes (eval-string includes)) 35 (set! includes '())) 36 37 (cond 38 ((equal? params "edit") 39 (d-DirectiveTextEdit-score tag)) 40 ((string? params) 41 (update-data params)) 42 ((equal? params 'refresh) 43 (setinclude)) 44 ((and (pair? params) (eq? (car params) 'query)) 45 (set! LilyPondInclude::return (member (cdr params) includes))) 46 ((and (pair? params) (eq? (car params) 'delete)) 47 (delete-include (cdr params))) 48 49 (else 50 (let ((include (d-ChooseFile (_ "Include LilyPond File") DENEMO_LILYPOND_DIR (list "*.ily" "*.ly")))) 51 (if include 52 (begin 53 (set! include (d-FilenameFromPath include)) 54 (update-data include)) 55 (d-WarningDialog (_ "LilyPond include files unchanged"))))))) 56