]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/translation-functions.scm
Merge branch 'release/unstable' into HEAD
[lilypond.git] / scm / translation-functions.scm
index 6f7d0524938969c5ba26a5b903917df321f4858a..cc94b67acfbeb2aae9c3364d577e937b4d89d5c5 100644 (file)
@@ -326,6 +326,7 @@ if no string-number is present."
          #t
          (map (lambda (specced-fret)
                 (or (eq? 0 specced-fret)
+                     (eq? 0 fret)
                     (>= maximum-stretch (abs (- fret specced-fret)))))
               specified-frets))))
 
@@ -333,7 +334,7 @@ if no string-number is present."
       "Can @var{pitch} be played on @var{string}, given already placed
 notes?"
       (let* ((fret (calc-fret pitch string tuning)))
-       (and (>= fret minimum-fret)
+       (and (or (eq? fret 0) (>= fret minimum-fret))
             (close-enough fret))))
 
     (define (open-string string pitch)
@@ -657,3 +658,39 @@ only ~a fret labels provided")
   (= 0 (modulo count n)))
 
 (define-public (all-repeat-counts-visible count context) #t)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; make-engraver helper macro
+
+(defmacro-public make-engraver forms
+  "Helper macro for creating Scheme engravers.
+
+The usual form for an engraver is an association list (or alist)
+mapping symbols to either anonymous functions or to another such
+alist.
+
+@code{make-engraver} accepts forms where the first element is either
+an argument list starting with the respective symbol, followed by the
+function body (comparable to the way @code{define} is used for
+defining functions), or a single symbol followed by subordinate forms
+in the same manner.  You can also just make an alist pair
+literally (the @samp{car} is quoted automatically) as long as the
+unevaluated @samp{cdr} is not a pair.  This is useful if you already
+have defined your engraver functions separately.
+
+Symbols mapping to a function would be @code{initialize},
+@code{start-translation-timestep}, @code{process-music},
+@code{process-acknowledged}, @code{stop-translation-timestep}, and
+@code{finalize}.  Symbols mapping to another alist specified in the
+same manner are @code{listeners} with the subordinate symbols being
+event classes, and @code{acknowledgers} and @code{end-acknowledgers}
+with the subordinate symbols being interfaces."
+  (let loop ((forms forms))
+    (if (cheap-list? forms)
+       `(list
+         ,@(map (lambda (form)
+                  (if (pair? (car form))
+                      `(cons ',(caar form) (lambda ,(cdar form) ,@(cdr form)))
+                      `(cons ',(car form) ,(loop (cdr form)))))
+                forms))
+       forms)))