Hi Stefan,
There's an #'attach-dir property that's useful for this sort of thing. TextSpanner #'left #'attach-dir defaults to #-1 (meaning the left edge of the parent notehead). This makes sense. Oddly, however, TextSpanner #'right #'attach-dir likewise defaults to #-1. This is weird. It would be better for TextSpanner #'right #'attach-dir to default to #1 (meaning the *RIGHT* edge of the parent notehead).
Fortunately, this is easy to override:
%%% BEGIN %%%
\version "2.11.34"
mute = {
\textSpannerUp
\override TextSpanner #'bound-details #'left #'text =
\markup {\italic "mute" } \override TextSpanner #'style =
#'dashed-line
\override TextSpanner #'dash-period = #0.01
\override TextSpanner #'bound-details #'right #'attach-dir = #1
\override TextSpanner #'bound-details #'right #'text =
\markup { \draw-line #'(0 . -1) }
}
\relative
{ \mute d\startTextSpan e f e d2\stopTextSpan c1 }
%%% END %%%
Now the spanner nib lines up exactly at the right edge of the final notehead.
Personally, I prefer the spanner to be even a bit longer in the X direction. There's a padding attribute that is helpful here:
%%% BEGIN %%%
\version "2.11.34"
mute = {
\textSpannerUp
\override TextSpanner #'bound-details #'left #'text =
\markup {\italic "mute" } \override TextSpanner #'style =
#'dashed-line
\override TextSpanner #'dash-period = #0.01
\override TextSpanner #'bound-details #'right #'attach-dir = #1
\override TextSpanner #'bound-details #'right #'text =
\markup { \draw-line #'(0 . -1) }
\override TextSpanner #'bound-details #'right #'padding = #-0.5
}
\relative
{ \mute d\startTextSpan e f e d2\stopTextSpan c1 }
%%% END %%%
Note that you could make all of your adjusts using only #'right #'padding. But it's better to set #'right #'attach-dir first, and then save #'right #'padding for optical tweaks only.