From 1c21b5be116515292462fa1d3ec62b4eea1584a4 Mon Sep 17 00:00:00 2001 From: Valentin Villenave Date: Tue, 16 Nov 2010 11:00:40 +0100 Subject: [PATCH] Use parameters. --- bin/lyrics.scm | 1 - bin/macros.scm | 1 - bin/markup-commands.scm | 1 - bin/text.scm | 1 - lib/10-score.scm | 55 ++++++++++++++++++++++++++----------------------- lib/20-readconf.scm | 9 ++++---- lib/30-readlang.scm | 1 - lib/40-loadmacros.scm | 1 - lib/70-findskel.scm | 1 - lib/80-buildskel.scm | 12 +++++------ lib/90-makescore.scm | 8 +++---- lib/include.ly | 1 - lib/init.scm | 9 ++++++-- lib/libgraphics.scm | 1 - lib/liblayout.scm | 1 - lib/libtext.scm | 1 - 16 files changed, 50 insertions(+), 54 deletions(-) diff --git a/bin/lyrics.scm b/bin/lyrics.scm index e9698fc..eb3eb7e 100644 --- a/bin/lyrics.scm +++ b/bin/lyrics.scm @@ -35,4 +35,3 @@ #{ \once \override LyricText #'self-alignment-X = #-0.9 #}) - diff --git a/bin/macros.scm b/bin/macros.scm index 808ee9c..ae73b25 100644 --- a/bin/macros.scm +++ b/bin/macros.scm @@ -111,4 +111,3 @@ $x (acons 'duration-log 4 (ly:music-property arg 'tweaks))) arg)) - diff --git a/bin/markup-commands.scm b/bin/markup-commands.scm index 0095da6..e57be2f 100644 --- a/bin/markup-commands.scm +++ b/bin/markup-commands.scm @@ -113,4 +113,3 @@ marks. Regular spaces are allowed inside words. (if up? "" text)))))) (if (not up?) (set! pos (- pos))) (interpret-markup layout props (stack pos)))) - diff --git a/bin/text.scm b/bin/text.scm index 321530b..353e522 100644 --- a/bin/text.scm +++ b/bin/text.scm @@ -121,4 +121,3 @@ \once \override Fingering #'X-extent = #'(-2.0 . 0.0) $(add-bracket current-staff-position #f text music) $music #}))) - diff --git a/lib/10-score.scm b/lib/10-score.scm index 0923d82..5183802 100644 --- a/lib/10-score.scm +++ b/lib/10-score.scm @@ -36,31 +36,34 @@ "Is LOC an accessible file/directory?" (access? loc F_OK)) -(define score-dir -;; "The directory that contains all music variables -;; and local settings, typically located in scores/. -;; Think of it as the usr/ directory in a standard -;; *nix file-tree." - (let* ((defined-score (ly:parser-lookup parser 'scores)) - (branch (if (ly:get-option 'git-branch-as-score-name) - (let* ((port (open-input-pipe "git branch --no-color | grep \\*")) - (str (read-line port))) - (if (string? str) - (set! str (string-drop str 2)) - #f) - (close-pipe port) - str) - #f)) - (make-path (lambda (f) (string-append conf:scores-dir "/" f)))) - (if (and branch (not (equal? branch "master"))) - (if (exists? (make-path branch)) - (make-path branch)) - (if defined-score - (if (exists? (make-path defined-score)) - (make-path defined-score) - (begin (ly:warning "Score directory ~a not found in ~a. +(define-public *current-score* + (make-parameter + ;; "The directory that contains all music variables + ;; and local settings, typically located in scores/. + ;; Think of it as the usr/ directory in a standard + ;; *nix file-tree." + (let* ((defined-score (ly:parser-lookup parser 'scores)) + (branch (if (ly:get-option 'git-branch-as-score-name) + (let* ((port (open-input-pipe "git branch --no-color | grep \\*")) + (str (read-line port))) + (if (string? str) + (set! str (string-drop str 2)) + #f) + (close-pipe port) + str) + #f)) + (make-path (lambda (f) (string-append conf:scores-dir "/" f)))) + (if (and branch (not (equal? branch "master"))) + (if (exists? (make-path branch)) + (make-path branch)) + (if defined-score + (if (exists? (make-path defined-score)) + (make-path defined-score) + (begin (ly:warning "Score directory ~a not found in ~a. A blank score will be created instead." defined-score conf:scores-dir) - conf:default-score)) - (begin (ly:warning "Score directory not defined! + conf:default-score)) + (begin (ly:warning "Score directory not defined! A blank score will be created instead.") - conf:default-score))))) + conf:default-score)))))) + +(define-public *current-part* (make-parameter "")) diff --git a/lib/20-readconf.scm b/lib/20-readconf.scm index bda4876..73d1ba2 100644 --- a/lib/20-readconf.scm +++ b/lib/20-readconf.scm @@ -84,9 +84,9 @@ ;; dedicated subdir of the score dir, or if none can be found, in ;; the score dir itself. This allows for local overrides to be ;; loaded early in the compilation process." - (let ((local-score (string-append score-dir "/score.ly")) + (let ((local-score (string-append (*current-score*) "/score.ly")) (usr-conf (if (defined-string? 'conf:local-conf-dir) - (let ((usr-dir (string-append score-dir "/" conf:local-conf-dir))) + (let ((usr-dir (string-append (*current-score*) "/" conf:local-conf-dir))) (if (exists? usr-dir) (begin (ly:debug-message "Local configuration dir found in ~a" usr-dir) @@ -94,8 +94,8 @@ (begin (ly:debug-message "~a does not exist; looking for overrides in parent directory." usr-dir) - score-dir))) - score-dir))) + (*current-score*)))) + (*current-score*)))) (parse-def-file conf:conf-file conf:conf-prefix) (parse-def-dir conf:conf-dir) (if (exists? local-score) @@ -106,4 +106,3 @@ ;; be used later for macros, themes, local overrides etc. (set! conf:local-conf-dir usr-conf) (parse-def-dir conf:local-conf-dir))) - diff --git a/lib/30-readlang.scm b/lib/30-readlang.scm index de8823d..eeb6794 100644 --- a/lib/30-readlang.scm +++ b/lib/30-readlang.scm @@ -64,4 +64,3 @@ f))))) (load-lang-file input-lang-file) (load-lang-file local-lang-file))) - diff --git a/lib/40-loadmacros.scm b/lib/40-loadmacros.scm index 17a6080..b5bb817 100644 --- a/lib/40-loadmacros.scm +++ b/lib/40-loadmacros.scm @@ -81,4 +81,3 @@ (begin (load-macros-in conf:macros-dir) (load-macros-in conf:local-conf-dir))) - diff --git a/lib/70-findskel.scm b/lib/70-findskel.scm index 088b498..462a140 100644 --- a/lib/70-findskel.scm +++ b/lib/70-findskel.scm @@ -61,4 +61,3 @@ Defaulting to \"universal\" skeleton." requested-skel) file)) (begin (ly:warning "No skeleton defined; defaulting to \"universal\" skeleton.") default-skel))) - diff --git a/lib/80-buildskel.scm b/lib/80-buildskel.scm index 8a54501..bb52a41 100644 --- a/lib/80-buildskel.scm +++ b/lib/80-buildskel.scm @@ -53,11 +53,11 @@ markup exists." ;; create a Voice for it. If a matching timeline can be ;; found, try and squash it as well." (define-music-function (parser location name) (string?) - (let* ((current-name (string-append current-part name)) + (let* ((current-name (string-append (*current-part*) name)) (music (ly:parser-lookup parser (string->symbol current-name))) (part-timeline (ly:parser-lookup parser (string->symbol - (string-append current-part lang:timeline-suffix)))) + (string-append (*current-part*) lang:timeline-suffix)))) (instr-timeline (ly:parser-lookup parser (string->symbol (string-append current-name lang:timeline-suffix))))) @@ -107,7 +107,7 @@ markup exists." ;; this staff (using appropriate suffixes)." (define-music-function (parser location name) (string?) (let* ((name (assoc-name lang:instruments name)) - (current-name (string-append current-part name)) + (current-name (string-append (*current-part*) name)) (music (ly:parser-lookup parser (string->symbol current-name))) (instr (make-this-text name lang:instr-suffix)) (short-instr (make-this-text name lang:short-instr-suffix))) @@ -131,7 +131,7 @@ markup exists." ;; Create Lyrics contexts accordingly." (define-music-function (parser location name) (string?) (let* ((name (assoc-name lang:instruments name)) - (current-name (string-append current-part name))) + (current-name (string-append (*current-part*) name))) #{ $(let* ((musiclist (list #{ {} #})) (numlist (if (ly:get-option 'only-suffixed-varnames) @@ -161,7 +161,7 @@ markup exists." lang:numbers (cons "" lang:numbers)))) (map (lambda (x) - (let ((staff-name (string-append current-part name (string-capitalize x)))) + (let ((staff-name (string-append (*current-part*) name (string-capitalize x)))) (append! musiclist (list #{ \newStaff $staff-name #})))) lang:numbers) @@ -181,7 +181,7 @@ markup exists." (let* ((name (assoc-name lang:instruments name)) (upper (string-append name (string-capitalize lang:upper-hand))) (lower (string-append name (string-capitalize lang:lower-hand))) - (dynamics (string-append current-part name lang:dynamics-suffix)) + (dynamics (string-append (*current-part*) name lang:dynamics-suffix)) (dynvar (ly:parser-lookup parser (string->symbol dynamics))) (instr (make-this-text name lang:instr-suffix)) (short-instr (make-this-text name lang:short-instr-suffix))) diff --git a/lib/90-makescore.scm b/lib/90-makescore.scm index aaacd25..e409580 100644 --- a/lib/90-makescore.scm +++ b/lib/90-makescore.scm @@ -18,7 +18,6 @@ (define numbers #f) -(define current-part #f) (define conf:structure numbers) (define (alist-reverse alist) @@ -36,7 +35,7 @@ current-part music." (eval-string (format #f "(define-public (apply-skel arg instr-list) - (set! current-part (car arg)) + (*current-part* (car arg)) (let* ((str (cdr arg)) (key (assoc-ref (alist-reverse instr-list) str))) (if (string? key) #{ \\newStaff $key #} @@ -60,7 +59,7 @@ current-part music." (string-append conf:output-dir "/") #f)) (new-filename (car (reverse - (string-split score-dir #\/))))) + (string-split (*current-score*) #\/))))) (if (not prefix) orig-filename (string-append prefix new-filename))))) @@ -80,7 +79,6 @@ current-part music." eval-macros eval-layout eval-theme - (include-ly score-dir) (let* ((defined-structure (ly:parser-lookup parser 'structure)) (struct (cond ((not defined-structure) conf:default-structure) ((string? defined-structure) (list defined-structure)) @@ -109,3 +107,5 @@ current-part music." struct) (make-music 'Music 'void #t)))) + +(include-ly (*current-score*)) diff --git a/lib/include.ly b/lib/include.ly index a0132b1..cb24728 100644 --- a/lib/include.ly +++ b/lib/include.ly @@ -36,7 +36,6 @@ #(load "lib/init.scm") #(include-scm conf:lib-dir #t) -#(include-ly score-dir) %%%%%%%%%%%%%%%%%%%%%% Define music-functions %%%%%%%%%%%%%%%%%%%%%% %% Required by main.ly --------------------------------------------% diff --git a/lib/init.scm b/lib/init.scm index b9b77ed..2f61c67 100644 --- a/lib/init.scm +++ b/lib/init.scm @@ -20,10 +20,16 @@ ; Init file: mandatory variables and functions. (use-modules + ; regular expressions (ice-9 regex) + ; optional arguments (ice-9 optargs) + ; delimited i/o (ice-9 rdelim) - (ice-9 popen)) + ; command pipe + (ice-9 popen) + ; parameters + (srfi srfi-39)) (define-public (ly:debug-message string . rest) @@ -91,4 +97,3 @@ scm-files))) ;------------------------------------------------------------------; -; diff --git a/lib/libgraphics.scm b/lib/libgraphics.scm index b73a4fb..972d934 100644 --- a/lib/libgraphics.scm +++ b/lib/libgraphics.scm @@ -35,4 +35,3 @@ (ly:music-property obj 'tweaks)))) obj))))) music)) - diff --git a/lib/liblayout.scm b/lib/liblayout.scm index 7ab060f..fa47a62 100644 --- a/lib/liblayout.scm +++ b/lib/liblayout.scm @@ -29,4 +29,3 @@ (define modern-cautionaries-style `(Staff ,(make-accidental-rule 'same-octave 1) ,(make-accidental-rule 'any-octave 1))) - \ No newline at end of file diff --git a/lib/libtext.scm b/lib/libtext.scm index 7ce15c4..69f4026 100644 --- a/lib/libtext.scm +++ b/lib/libtext.scm @@ -142,4 +142,3 @@ details) (ly:music-property m 'tweaks))) m)) - -- 2.11.4.GIT