4 texidoc = "Incipits can be printed using an @code{InstrumentName}
8 %% to prevent warnings/programming errors:
9 #(set-object-property! 'music 'backend-type? ly:music?)
10 #(set-object-property! 'music 'backend-doc "Incipit music")
11 #(ly:add-interface 'incipit-interface "An incipit." '(music))
12 #(let* ((instrument-def (assoc 'InstrumentName all-grob-descriptions))
13 (meta-def (assoc 'meta (cdr instrument-def)))
14 (interfaces-def (assoc 'interfaces (cdr meta-def)))
15 (interfaces (cdr interfaces-def)))
16 (set-cdr! interfaces-def (cons 'incipit-interface interfaces)))
20 %% All this would be shortcuted by an appropriate music function:
21 \override Staff.InstrumentName #'music = ##{ \clef "petrucci-c1" c'4 d' e' f' #}
22 \override Staff.InstrumentName #'self-alignment-X = #RIGHT
23 \override Staff.InstrumentName #'padding = #0
24 \override Staff.InstrumentName #'stencil =
26 (let* ((instrument-name (ly:grob-property grob 'long-text))
27 (layout (ly:output-def-clone (ly:grob-layout grob)))
28 (music (make-music 'SequentialMusic
29 'elements (list (make-music 'ContextSpeccedMusic
30 'context-type 'MensuralStaff
31 'element (make-music 'PropertySet
32 'symbol 'instrumentName
33 'value instrument-name))
34 (ly:grob-property grob 'music))))
35 (score (ly:make-score music))
36 (mm (ly:output-def-lookup layout 'mm))
37 (indent (ly:output-def-lookup layout 'indent))
38 (incipit-width (ly:output-def-lookup layout 'incipit-width))
39 (scaled-incipit-width (if (number? incipit-width)
42 (ly:output-def-set-variable! layout 'indent (- indent scaled-incipit-width))
43 (ly:output-def-set-variable! layout 'line-width indent)
44 (ly:output-def-set-variable! layout 'ragged-right #f)
45 (ly:score-add-output-def! score layout)
46 (set! (ly:grob-property grob 'long-text)
47 (markup #:score score))
48 (system-start-text::print grob)))
50 %% the instrument name definition is separated:
51 \set Staff.instrumentName = #"Instrument"