I was most successful with this:
\score {
\new Voice \relative c' {
c4 d e g |
c, d e g
\repeat volta 2 {
a g c b |
a g e d
}
\set Score.repeatCommands = #'(end-repeat start-repeat (volta "1 - 4"))
g f e d
\set Score.repeatCommands = #'(end-repeat (volta "5"))
c1 \bar "|."
}
}
and this gets me the results that I want, but it generates a warning:
warning: already have a volta spanner, ending that one prematurely
I think that's the only way you'll get the desired output, but you haven't told Lilypond when to stop the first volta before creating a new one; using (volta #f) will get rid of the warning:
\set Score.repeatCommands = #'((volta #f) end-repeat (volta "5"))
Naturally, unless the c1 is the last bar, you'll need another (volta #f) to stop the second volta bracket too.
Regards,
Neil