lilypond-devel
[Top][All Lists]
Advanced

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

Re: [GLISS] turn xxx.yyy into ("xxx" "yyy")


From: Thomas Morley
Subject: Re: [GLISS] turn xxx.yyy into ("xxx" "yyy")
Date: Wed, 12 Sep 2012 11:18:27 +0200

2012/9/12 David Kastrup <address@hidden>:
>
> Hi,
>
> if we write xxx in LilyPond, this is considered to be a string.  I want
> xxx.yyy.zzz to be a list of strings ("xxx" "yyy" "zzz").  The main
> incentive is to be able to have music functions be able to accept both
> Stem as well as Staff.TimeSignature as a function argument.

I don't know anything about the impact of your proposal on other stuff.
But speaking as a user, who often writes music-function:
I'd  love it!

> At the current point of time, we have the following abomination:
>
> alterBroken =
> #(define-music-function (parser location name property arg)
>   (string? scheme? list?)
>   (_i "Override @var{property} for pieces of broken spanner @var{name} with
> values @var{arg}.")
>   (let* ((name (string-delete name char-set:blank)) ; remove any spaces
>          (name-components (string-split name #\.))
>          (context-name "Bottom")
>          (grob-name #f))
>
>     (if (> 2 (length name-components))
>         (set! grob-name (car name-components))
>         (begin
>           (set! grob-name (cadr name-components))
>           (set! context-name (car name-components))))
> [...]
>           #{
>             \override $context-name . $grob-name $property =
> [...]
>
> to be used as
>
>     \alterBroken "Staff.OttavaBracket" #'padding #'(1 3)
>     % Spaces in spanner's name are disregarded.
>     \alterBroken "Staff . OttavaBracket" #'style #'(line dashed-line)
>     \ottava #1
>     % It is possible to use procedures as arguments.
>     \alterBroken Hairpin #'stencil #`(
> [...]
>
> With that change, it could be written as
>
> alterBroken =
> #(define-music-function (parser location name property arg)
>   (string-list? symbol? list?)
>   (_i "Override @var{property} for pieces of broken spanner @var{name} with
> values @var{arg}.")
>   #{
>      \override #name #property = arg
> [...]
>
> and used as
>
>    \alterBroken Staff.OttavaBracket #'padding #'(1 3)
>    \alterBroken Hairpin #'stencil #`(
> [...]

The given example was recently added to the source-code. There is
another one in music-functions-init.ly, standing there for a long
time: \overrideProperty

> Basically, if a music function wants to provide a shorthand for an
> override, not being able to specify an optional context is a nuisance.
> I currently have just the same problem writing a \hide function that is
> supposed to be a shortcut for \override ??? #'stencil = ##f .
>
> Using periods to build a string list seems reasonably straightforward to
> me.  It would happen in the parser rather than the lexer, so spaces are
> allowed and it should not cause conflicts with chord modifiers and other
> awkward stuff.
>
> What do you think?
>
> --
> David Kastrup
>
>
> _______________________________________________
> lilypond-devel mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/lilypond-devel

-Harm



reply via email to

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