# How to pass ly:music to a markup-command

I am attempting to create a lilypond markup command which will display a guitar chord fingering above the chord on a stave. The code I have so far follows:

#(define-markup-command (chord_and_fingering layout props
chord fingering) (ly:music? string?)
"…documentation…"
(interpret-markup layout props
#{ \markup { \center-column {
\fret-diagram #(string-append "f:1;h:13;" fingering)
\score {
\new Staff {
\clef "treble_8"
\set fingeringOrientations = #'(left)
#chord \bar "|."
}
\layout {
\override Staff.TimeSignature #'stencil = ##f
\override Staff.Clef #'transparent = ##t
}
}
}}#}
))


It works okay, but I cannot figure out how to pass a music expression directly to it. That is, I can use it like this with a temporary variable:

a_C_major_chord = {
<c-3 e-2 g-0 c'-1 e'-0>1
}

a_C_major = \markup {
\chord_and_fingering
#a_C_major_chord
#"6-x;5-3;4-2;3-o;2-1;1-o;"
}


But would like to use it like this, without:

a_C_major = \markup {
\chord_and_fingering
#{<c-3 e-2 g-0 c'-1 e'-0>1}
#"6-x;5-3;4-2;3-o;2-1;1-o;"
}


This however doesn't work. Could someone tell me where I am going wrong and what is the correct syntax for this?

Thank-you for your time and help.

Well, you can use either

\notemode {<c-3 e-2 g-0 c'-1 e'-0>1}


or (you were almost there)

##{<c-3 e-2 g-0 c'-1 e'-0>1#}


Remember: # throws you from LilyPond input modes into Scheme and #{ introduces stuff in LilyPond syntax into Scheme. Here you are combining both and so need ##{ at the start.

• That's great. \notemode doesn't seem to work for me here, but the alternative is perfect, there's just a small typo in your answer; the closing } in the second example must also be pre-fixed with a # so ##{...#} is the construct. Thanks for the help. – tjm Jul 10 '17 at 10:02