Am 01.03.2018 um 18:31 schrieb Stefano Troncaro:
...

@Urs, I not familiar with \with blocks, I'll take a look at the oll-core code and experiment a bit with it. Maybe I'll be able to help.


Look at https://github.com/openlilylib/scholarly/blob/master/usage-examples/annotate.ly to see an example for the syntax. Actually this does what you want: an unlimited number of optional arguments.

%%%
\version "2.19.80"

#(define (context-mod->props mod)
   (map
    (lambda (prop)
      (cons (cadr prop) (caddr prop)))
    (ly:get-context-mods mod)))

myVariableFunc =
#(define-void-function (opts mus)((ly:context-mod? #f) ly:music?)
   (let ((props
          (if opts
              (context-mod->props opts)
              '())))
     (for-each (lambda (prop)
                 (ly:message "Option '~a': '~a'" (car prop) (cdr prop)))
       props)
     mus))

\relative {
  c' d e f
  \myVariableFunc \with {
    first = "Hello"
    second = 124
    third = #'((a . red)(b . blue))
    fourth = #(ly:version)
    fifth = #display
  } g1
}
 %%%

Note that instead of defining context-mod->props you could include "oll-core/package.ily" (or rather: if you have included anything from OLL you can simply use that procedure.

HTH
Urs
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to