]> git.donarmstrong.com Git - lilypond.git/blobdiff - Documentation/snippets/centering-markup-on-note-heads-automatically.ly
Imported Upstream version 2.16.0
[lilypond.git] / Documentation / snippets / centering-markup-on-note-heads-automatically.ly
index ce227d016e6e8db91ea27efda9f4283d922dfb65..36f83dd4a7a2c9971c95cf69066211eb77caff0a 100644 (file)
@@ -4,8 +4,8 @@
 % and then run scripts/auxiliar/makelsr.py
 %
 % This file is in the public domain.
-%% Note: this file works from version 2.14.0
-\version "2.14.0"
+%% Note: this file works from version 2.15.31
+\version "2.16.0"
 
 \header {
   lsrtags = "text, tweaks-and-overrides, contexts-and-engravers"
@@ -25,29 +25,23 @@ been shifted via @code{force-hshift}.
 #(define (Text_align_engraver ctx)
   (let ((scripts '())
         (note-column #f))
-
-    `((acknowledgers
-       (note-column-interface
-        . ,(lambda (trans grob source)
-             ;; cache NoteColumn in this Voice context
-             (set! note-column grob)))
-
-       (text-script-interface
-        . ,(lambda (trans grob source)
-             ;; whenever a TextScript is acknowledged,
-             ;; add it to `scripts' list
-             (set! scripts (cons grob scripts)))))
-
-      (stop-translation-timestep
-       . ,(lambda (trans)
-            ;; if any TextScript grobs exist,
-            ;; set NoteColumn as X-parent
-            (and (pair? scripts)
-                 (for-each (lambda (script)
-                             (set! (ly:grob-parent script X) note-column))
-                           scripts))
-            ;; clear scripts ready for next timestep
-            (set! scripts '()))))))
+    (make-engraver
+     (acknowledgers
+      ((note-column-interface trans grob source)
+       ;; cache NoteColumn in this Voice context
+       (set! note-column grob))
+      ((text-script-interface trans grob source)
+       ;; whenever a TextScript is acknowledged,
+       ;; add it to `scripts' list
+       (set! scripts (cons grob scripts))))
+     ((stop-translation-timestep trans)
+      ;; if any TextScript grobs exist,
+      ;; set NoteColumn as X-parent
+      (for-each (lambda (script)
+                 (set! (ly:grob-parent script X) note-column))
+               scripts)
+      ;; clear scripts ready for next timestep
+      (set! scripts '())))))
 
 \layout {
   \context {