lilypond-user
[Top][All Lists]
Advanced

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

Re: Add an arbitrary music property


From: Thomas Morley
Subject: Re: Add an arbitrary music property
Date: Sun, 10 Jun 2018 15:15:45 +0200

2018-06-09 23:59 GMT+02:00 Urs Liska <address@hidden>:

> You mean I should use set-object-property! rather than set!
> (ly:music-property .... ?

Well, look at the example below (for custom-grob-properties):

{
  \override NoteHead #'wtf = ##t
  c'
  d'
  \once \override NoteHead #'color =
  #(lambda (grob)
    (if (eq? (ly:grob-property grob 'wtf) #t)
        red
        '()))
  e'
  f'
}

This used to work, alas emitting a warning:
warning: cannot find property type-check for `wtf' (backend-type?).
perhaps a typing error?
warning: doing assignment anyway

Since 2.18.2 it fails with:
warning: cannot find property type-check for `wtf' (backend-type?).
perhaps a typing error?
warning: skipping assignment

Unless you prepend the example with something at the lines of:

#(define (define-grob-property symbol type? description)
  (if (not (equal? (object-property symbol 'backend-doc) #f))
      (ly:error (_ "symbol ~S redefined") symbol))

  (set-object-property! symbol 'backend-type? type?)
  (set-object-property! symbol 'backend-doc description)
  symbol)

#(for-each
  (lambda (x)
    (apply define-grob-property x))
    `(
      (wtf ,boolean? "DOCME")
      ;; other custom-properties
      ))

I just thought doing similar for custom-_music_-properties would be a
littel more robust for changes of our internals.


> Does that also work with whole music expressions (vs. single grobs)? I want
> to "tag" the whole (sequential) music expression.

I expect so, but didn't check.


Cheers,
  Harm



reply via email to

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