lilypond-user
[Top][All Lists]
Advanced

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

Simulating parametrized `macros' for single context overrides


From: Matthias Kilian
Subject: Simulating parametrized `macros' for single context overrides
Date: Wed, 14 Apr 2004 20:08:45 +0200
User-agent: Mutt/1.3.28i

Hi all,

earlier this day, Roland did ask me (per PM) a question leading to an
IMHO very usable little helper.

Ronald wanted some feature like the following:

- At top level, define
    textshift = \once\override TextScript #'extra-offset = #'(#1 . #2)

- Within music expressions, use
    \textshift{0}{-1.5}

Since that isn't possible in LilyPond, I searched the documentation and
the LilyPond sources some minutes, found ly:context-pushpop-property
and an example of it in wilhelmus.ly.

After a first quick hack I sent to Roland, I tried the following refined
(yet not working) solution:

  % Helper for single context-overrides.
  #(define (single-context-override context-name property-name)
    (lambda (value)
      (lambda (context)
        (ly:context-pushpop-property context context-name property-name value)
      )
    )
  )

That function can be used for defining context-overriding functions. For
example (to use Rolands use case):

  #(define textshift (single-context-override 'TextScript 'extra-offset))

That can be used in the music expressions by

  \applycontext #(textshift '(0 . -1.5))

Unfortunately, that doesn't imply the semantic of \once. There seems to
be an internal *music* property named 'once', but I've no idea wether
or how that can be used here.

Has anyone an idea of how to get the property really set *once*?

Ciao,
        Kili




reply via email to

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