Hi Simon, On Wed, Mar 25, 2015 at 1:29 PM, Simon Albrecht <simon.albre...@mail.de> wrote:
> Hello, > > thanks a lot for your thoughts, David. > > Am 25.03.2015 um 16:33 schrieb David Nalesnik: > > Hi Simon, > > I can't judge whether this is getting closer to you want, but maybe my > observations can help. > > On Wed, Mar 25, 2015 at 9:17 AM, Simon Albrecht <simon.albre...@mail.de> > wrote: > >> Hello, >> >> I’m experimenting with an implementation of automatic tagline language >> selection and currently have two problems with the void function \language >> that I adapted from music-functions-init.ly: >> – I can’t get the first, optional argument to work; it needs to be >> explicitly given or Lily will take the string as first argument – although >> it’s required to be a symbol. >> > > I haven't succeeded in making this work with the optional argument in > the first position. I moved it last. > > From the design point of view I think it’s necessary to have it first: > it’s much more intuitive to write \language output "deutsch" than \language > "deutsch" output. > I don’t quite get why having the optional argument first doesn’t work: > after all, this is commonly used in music functions and scheme functions. > But apparently define-void-function is implemented differently. > No, the same issues exist here with music and scheme functions. Try the below with define-scheme-function and define-music-function. (With the latter you'll need to add some music return--like #{ #} ) > This would then mean that one has to always specify the first argument, > which is not the most elegant form. I’ll probably switch to using three > distinct functions \language, \inputLanguage and \outputLanguage (with the > names being subject to discussion of course). > Sure, it could be first. And that is more intuitive! You could do: \version "2.19.16" #(define output-language '()) language = #(define-void-function (parser location channel language) ((symbol? 'general) string?) (_i "Define languages for input (i.e. set note names for @var{language}), output (i.e. display tagline and table of contents in @var{language}), or both.") (if (not (eq? channel 'output)) (note-names-language parser language)) (if (not (eq? channel 'input)) (set! output-language (string->symbol language))) ) \language \default "deutsch" %% works %\language general "deutsch" %% works %\language "deutsch" %% does not { c } [...etc...] %%% The problem with the last invocation is this. LilyPond considers whether the first argument you give it--"deutsch"--is a symbol. It isn't, so it uses 'general. Then, it looks further on for a suitable value for 'language', not for 'channel'. The next thing encountered is the music expression, which raises an error because it's not a string.... --David
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user