# Markup text inside second volta bracket

I want to format text in the headings of both 1st and 2nd ending Volta brackets in Lilypond. There are several examples of formatted text in the first ending bracket, but I cannot seem to find one with formatted text (using a markup command) in the second ending bracket.

In other words, I have this snippet:

01     voltaAdLib = \markup { 1. 2. 3... \text \italic { ad lib. } }
02
03     \relative c'' {
04       c1
05       \set Score.repeatCommands = #(list (list 'volta voltaAdLib) 'start-repeat)
06       c4 b d e
07       \set Score.repeatCommands = #'((volta #f) (volta "4.") end-repeat)
08       f1
09       \set Score.repeatCommands = #'((volta #f))
10     }


And I want to add another myText = \markup... block in place of "4." in line 07. How would I do that?

That's more a question of Scheme syntax than of LilyPond. First you have to note that ' in Scheme is used for quoting material rather than having it interpreted. What's worth quoting are lists (the things included in (...)) and symbols (basic strings used like identifiers). A list, when quoted, has all of its elements quoted and then is a list. If it is unquoted, it is evaluated. An evaluated list is a function call, with the first element being the function and the remaining elements being the values, all of which are evaluated before the call.

A typical function is list which takes its arguments and puts them into a list.

Another item that is different when evaluated is a symbol (mentioned above). Unevaluated, it is a unique thing that does not compare equal to any other unique thing. Evaluated, it is more or less a variable access.

So in the above,

    #(list (list 'volta voltaAdLib) 'start-repeat)


is basically the same as

    #'((volta i-would-like-the-value-of-voltaAdLib) start-repeat)


for which one can use quasiquotes which quote anything that is not preceded by ,. So one could write this as

    #((volta ,voltaAdLib) start-repeat)


Note that I am now using the backward-pointing quasi-quote after #. If I used the regular quote, the result would be equivalent to

    #'((volta (unquote voltaAdLib)) start-repeat)


which does not help. Quasiquotes are usually quite more convenient for list-building with only a few values from variables or function calls than building the list with explicit calls of list. So getting back to your use-case, you'd likely want

    \set Score.repeatCommands = #((volta #f) (volta ,#{ \markup "ad lib." #}) end-repeat)


Using #{ \markup ... #} directly in Scheme is supported since version 2.16 I think, but of course you can also use a variable like in your first example.