%% \ifDefined symbol %% %% If the symbol is defined, returns its music expression value. %% Otherwise, returns a void expression. ifDefined = #(define-music-function (parser location sym) (symbol?) (let ((music (ly:parser-lookup parser sym))) (if (ly:music? music) music (make-music 'Music 'void #t)))) %% \ifDefinedElse symbol expression %% %% If the symbol is defined, returns its music expression value. %% Otherwise, returns the expression. ifDefinedElse = #(define-music-function (parser location sym else) (symbol? ly:music?) (let ((music (ly:parser-lookup parser sym))) (if (ly:music? music) music else))) %% \ifDefinedThen symbol expression %% %% If the symbol is defined, returns the expression. %% Otherwise, returns a void expression. ifDefinedThen = #(define-music-function (parser location sym music) (symbol? ly:music?) (if (defined? sym) music (make-music 'Music 'void #t))) %% \ifDefinedThenElse symbol expression else-expression %% %% If the symbol is defined, returns the expression. %% Otherwise, returns the else-expression. ifDefinedThenElse = #(define-music-function (parser location sym music else) (symbol? ly:music? ly:music?) (if (defined? sym) music else)) %% Example: %% %% \ifDefinedThen #'leadWords \lyricsto lead \ifDefined #'leadWords