Here's my attempt at this (I don't know how to check for staff-like
contexts, so I just put them all in a list). It's just \incipit but with
an additional condition and the context mods moved to \layout.
%%%%
betterIncipit =
#(define-music-function (incipit-music) (ly:music?)
(_i "Output @var{incipit-music} as an incipit.
@var{incipit-music} is typeset within a @code{MensuralStaff} if no other
staff-like context is created; the result
is positioned before the main staff (as part of an @code{InstrumentName}
grob)
to indicate the music's original notation.")
#{
\once \override Staff.InstrumentName.stencil =
#(lambda (grob)
(let* ((instrument-name (ly:grob-property grob 'long-text))
(align-x (ly:grob-property grob 'self-alignment-X 0))
(align-y (ly:grob-property grob 'self-alignment-Y 0)))
(set! (ly:grob-property grob 'long-text)
#{ \markup {
\score
{
$(if (member (ly:music-property incipit-music
'context-type) '(ChoirStaff DrumStaff GrandStaff
GregorianTranscriptionStaff KievanStaff MensuralStaff OneStaff
PetrucciStaff PianoStaff RhythmicStaff Staff StaffGroup
StandaloneRhythmStaff TabStaff VaticanaStaff))
#{ { $incipit-music } #}
#{ \new MensuralStaff { $incipit-music } #})
\layout {
$(ly:grob-layout grob)
\context {
\Staff
\override InstrumentName.self-alignment-X = #align-x
\override InstrumentName.self-alignment-Y = #align-y
instrumentName = #instrument-name
}
indent-incipit-default = 15\mm
line-width = #(primitive-eval
'(or (false-if-exception indent)
indent-incipit-default))
indent = #(primitive-eval
'(or (false-if-exception (- line-width
incipit-width))
(* 0.5 line-width)))
ragged-right = ##f
ragged-last = ##f
system-count = 1
}
}
}
#})
(set! (ly:grob-property grob 'self-alignment-Y) #f)
;; Do 'self-alignment-X RIGHT only for the first
InstrumentName, which
;; actually is the incipit. Otherwise self-alignment-X for the
;; shortInstrumentName is not longer settable.
(let ((parts (ly:spanner-broken-into (ly:grob-original grob))))
(if (and (pair? parts) (equal? grob (car parts)))
(ly:grob-set-property! grob 'self-alignment-X RIGHT)))
(system-start-text::print grob)))
#}
)
%%%%
David Kastrup wrote:
YTG 1234 <ytg1234.pm...@gmail.com> writes:
I have tried an override ( \override
Staff.NoteHead.style = #'default )
Note heads are drawn in Voice, so you can just omit the context
name. \override NoteHead.style = #'default
The more fundamental issue here, though, is that \incipit is hardcoded
to create a MensuralStaff context. Does anyone know how to replicate
its effect with a normal Staff, short of just substituting in its
source code?
I think there might be a point in modifying incipit such that if it is
called as
\incipit \new staff-like-context ...
that it will not do a \new MensuralStaff but just take what is given,
add its specific context creation mods to any that might already be
there, and work with that.