> Is there a possibility to do something like this?
>
> if( custom_cfg_flag)
> {
> % default score combination
> % (e.g. with header and chords)
> }
> else
> {
> % some other combination
> % (e.g. only melody)
> }
If having defined a LP variable counts as custom_cfg_flag, the attached
files may be useful.
-- Johan
%% \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
% Thanks to: Dan Eble <[email protected]>
% Usage:
%
% aNotes = \relative c' { c1 e1 g1 }
% bNotes = \relative c' { }
%
% \ifThenElse \bNotes \aNotes \bNotes
%
% Note the test is on emptyness, not definedness.
#(define-public (music-empty? m)
(let ((void-music (ly:music-property m 'void)))
(or (and (not (null? void-music)) void-music)
(and (null? (ly:music-property m 'element))
(null? (ly:music-property m 'elements))))))
ifThenElse =
#(define-music-function
(parser location if-music then-music else-music)
(ly:music? ly:music? ly:music?)
(if (music-empty? if-music)
else-music
then-music))
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user