lilypond-devel
[Top][All Lists]
Advanced

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

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


From: David Kastrup
Subject: [GLISS] turn xxx.yyy into ("xxx" "yyy")
Date: Wed, 12 Sep 2012 10:38:27 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux)

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.

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 #`(
[...]

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




reply via email to

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