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.