lilypond-user
[Top][All Lists]
Advanced

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

Re: define-markup-command with variable number of arguments


From: Urs Liska
Subject: Re: define-markup-command with variable number of arguments
Date: Sat, 2 Nov 2019 18:01:40 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0


Am 01.11.19 um 16:01 schrieb Thomas Morley:
Am Fr., 1. Nov. 2019 um 15:34 Uhr schrieb Karsten Reincke <address@hidden>:

does anyone has / know about an example of a define-markup-command 
implementation
using a variable number of arguments / parameters?
Nope, optional arguments are not possible using define-markup-command.

Unfortunately, in my system (Linux Ubuntu 19.10 with Lilypond 2.18...) the 
normal
GUILE / scheme syntax (define (x y . args) ) (doanythingwith args) ) seems to
executable.

The tutorial LilyPond Extending mentions that there exist such an opportunity
(page 19.), but does not contain any example.
The section of the Extending-tutorial refers to functions, not to the
define-markup-command which is a macro.
(At least if I've identified the section you refer to correctly, I
usually use the big-page-html-version of the docs.)

You could go for properties (see define-markup-commands.scm), but the
syntax in coding and calling it differs ofcourse and you may encounter
unwished side-effects (if namings interfer with grob-properties).

For variable amount of args I'd go for list? (or the like) and let the
body of your code sort it out.


An approach that I personally like very much for its way the input code "speaks" is the \with {} clause. You use that by the ly:context-mod? predicate and then you can stuff arbitrary key=value pairs in it (and parse that within the body, as Harm said).

Urs



Cheers,
   Harm




reply via email to

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