lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: incorporating templates w/ conditionals


From: Br. Samuel Springuel
Subject: Re: incorporating templates w/ conditionals
Date: Fri, 6 Oct 2017 13:31:14 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

I developed something similar based on some suggestions on the list back in December of last year. You can see what I ended up using here:

http://lists.gnu.org/archive/html/lilypond-user/2016-12/msg00636.html

For my actual implementation I further refined the idea as follows:

In an included formatting file (which is used for every file in the project) I have the following code block:

#(if (not (defined? 'gender))
     (define gender "neutral"))

heshe = #(cond ((equal? gender "male") #{ \lyricmode { he } #})
               ((equal? gender "female")  #{ \lyricmode{ she } #})
(else #{ \lyricmode { \override Lyrics.LyricText.font-shape = #'italic he/she \revert Lyrics.LyricText.font-shape } #}))

hisher = #(cond ((equal? gender "male") #{ \lyricmode { him } #})
                ((equal? gender "female")  #{ \lyricmode{ her } #})
(else #{ \lyricmode { \override Lyrics.LyricText.font-shape = #'italic his/her \revert Lyrics.LyricText.font-shape } #}))

himher = #(cond ((equal? gender "male") #{ \lyricmode { him } #})
                ((equal? gender "female")  #{ \lyricmode{ her } #})
(else #{ \lyricmode { \override Lyrics.LyricText.font-shape = #'italic him/her \revert Lyrics.LyricText.font-shape } #}))

In this way, the variable gender is always defined and has a default value of "neutral". Simultaneously, I can, in any particular project file, define gender manually and that will be respected (the use of the defined? conditional means that it doesn't matter whether gender is defined before or after file inclusion.

I would imagine that something like this should work for you too.
--
✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝
Br. Samuel, OSB
St. Anselm’s Abbey
Washington, DC
(R. Padraic Springuel)

PAX ☧ ΧΡΙΣΤΟΣ



reply via email to

[Prev in Thread] Current Thread [Next in Thread]