]> git.donarmstrong.com Git - lilypond.git/blobdiff - ly/music-functions-init.ly
PartCombine: Shuffle functions around so unisono/solo1/solo2/chords_together/apart...
[lilypond.git] / ly / music-functions-init.ly
index ad53afe592f626f3c0b092010846ca429ac8bac0..4a58f05522f919b1f242735e0965bf8e0adbce65 100644 (file)
 %% this file is alphabetically sorted.
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-%% need SRFI-1 for filter;
-%% optargs for lambda*;
-%% regex for string-match
+%% need SRFI-1 for filter; optargs for lambda*
 #(use-modules (srfi srfi-1)
-             (ice-9 optargs)
-             (ice-9 regex))
+             (ice-9 optargs))
 
 %% TODO: using define-music-function in a .scm causes crash.
 
@@ -201,13 +198,14 @@ bookOutputSuffix =
    (set! book-output-suffix newsuffix)
    (make-music 'SequentialMusic 'void #t))
 
-%% why a function?
+%% \breathe is defined as a music function rather than an event identifier to
+%% ensure it gets useful input location information: as an event identifier,
+%% it would have to be wrapped in an EventChord to prevent it from being
+%% treated as a post_event by the parser
 breathe =
 #(define-music-function (parser location) ()
    (_i "Insert a breath mark.")
-   (make-music 'EventChord
-              'origin location
-              'elements (list (make-music 'BreathingEvent))))
+   (make-music 'BreathingEvent))
 
 
 
@@ -365,32 +363,18 @@ label =
 
 language =
 #(define-music-function (parser location str) (string?)
-   (_i "Select note-names language.")
-   ;; This function is a hack around the old language
-   ;; selection system, using separate .ly files for each
-   ;; supported languages.
-   ;; TODO: re-implement language selection in a cleaner way.
-   (let* ((file-name (string-append (string-downcase! str) ".ly"))
-
-         ; Ugh.  ly:gulp-file's "file not found" error message
-         ; won't be much informative in this specific case.
-         (raw-string (ly:gulp-file file-name))
-
-         ; extract the pitchnames alist.
-         (delim-alist (string-match "`\\(.*\\)\\)\\s[ |\n]?\\)" raw-string ))
-         (extract-alist (if delim-alist
-                            (match:substring delim-alist)
-                            #f)))
-
-     (if extract-alist
-        (let ((lang-alist (eval-string extract-alist)))
+   (_i "Select note names language.")
+   (let ((language (assoc-get (string->symbol str)
+                             language-pitch-names
+                             '())))
+     (if (pair? language)
+        (begin
           (if (ly:get-option 'verbose)
               (ly:message (_ "Using ~a note names...") str))
-          (set! pitchnames lang-alist)
-          (ly:parser-set-note-names parser lang-alist))
-        (ly:error (_ "Cannot process ~a as a language file.
-Use \\include \"~a\" instead.") file-name file-name))
-     make-void-music))
+          (set! pitchnames language)
+          (ly:parser-set-note-names parser language))
+        (ly:warning (_ "Could not find language ~a. Ignoring.") str))
+     (make-music 'Music 'void #t)))
 
 
 makeClusters =
@@ -631,7 +615,6 @@ that they share a staff.")
    (make-part-combine-music parser
                             (list part1 part2)))
 
-#(define (symbol-or-boolean? x) (or (symbol? x) (boolean? x)))
 partcombineForce =
 #(define-music-function (location parser type once) (symbol-or-boolean? boolean?)
    (_i "Override the part-combiner.")