Hi Scheme wizards, can you help me?

I have two unrelated questions regarding the attached file.
It is a very much stripped down version of a function actually in use.

It takes an annotation from the input file, produces a clickable message on the console and colors the affected object. (In reality it does and will do more, but that's what's necessary for the example/question).

###
The first question should be quite simple, but I don't seem to find a solution on my own: How can I make the function be able to affect only selected items, e.g. only one note of the chord in the example (or only a specific tie etc.)

When I change the \once \override clause to


\tweak color #magenta #item


it colors all subsequent items of the given type.


###
The other issue is probably trickier. Is it possible (at all) to determine the current barnumber from within such a music function? I want to print that to the console along with the other arguments and particularly to annotation files.
Is there any hope in achieving that?


TIA
Urs

\version "2.18.2"

annotate =
#(define-music-function (parser location properties item)
   (ly:context-mod? symbol-list-or-music?)
   ;; annotates a musical object for use with lilypond-doc

   (let*
    (
      ;; create dummy alist (is that necessary?)
      (props '( )))

    ;; Add or replace props entries taken from the properties argument
    (map (lambda (mod) (set! props
                             (assoc-set! props
                               (symbol->string (cadr mod)) (caddr mod))))
      (ly:get-context-mods properties))

    ;; produce a clickable message
    (ly:input-message location "Annotation")

    ;; Print a message with all properties to the console
    (map (lambda (prop)
           (ly:message (format "    ~a: ~a" (car prop) (cdr prop))))
      props)
    (ly:message "\n"))

   ;; Color the affected grob
   #{ \tweak color #darkgreen #item #})

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Usage example

{
  \annotate \with {
    author = "Urs Liska"
    message = "Important information"
  }
  NoteHead
  <c' e' g'>-> d' e'
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to