lilypond-user
[Top][All Lists]
Advanced

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

Re: Dot-separated list as music function argument


From: Simon Albrecht
Subject: Re: Dot-separated list as music function argument
Date: Tue, 08 Jul 2014 18:42:54 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.4.0

Many thanks for the responses, Thomas and David.
And sorry for the messy code layout… I’ll see if I can change that.
Yours, Simon

Am 08.07.2014 15:50, schrieb Thomas Morley:
2014-07-08 13:39 GMT+02:00 Simon Albrecht <address@hidden>:
Hello everybody,

I just wrote a music function to mark grobs as editorial addition by
colouring them grey. See the code and an example:

\version "2.19.8"


ed = #(let

((string-or-list?

(lambda (grob)

(or (string? grob)

(list? grob)))))

(define-music-function

(parser location grob mus)

(string-or-list? ly:music?)

#{ \override $grob . color = #(x11-color 'grey40)

$mus

\revert $grob . color #}

)

)


\relative { \ed NoteHead c' \ed #'(Staff Accidental) { cis dis } es }


%%%%%%%%%%%%%


The 2.18 changes document says that #'(Staff Accidental) and
Staff.Accidental were now interchangeable, however if I replace it in the
second function call, I get errors (unexpected "." etc.). Is there a way to
avoid this in the coding of the function or should it be considered a bug?

Best regards,
Simon

Hi,

use the predicate symbol-list-or-symbol?
Below a working version, displaying some info as well:

\version "2.19.8"

ed =
#(define-music-function (parser location grob mus)
   (symbol-list-or-symbol? ly:music?)
;; displaying some info:
     (format #t "\nI'm the list: \t\t\t~a
My first entry is:          \t~a
My next entry is:           \t~a
My first entry is a symbol? \t~a
My next entry is a symbol?  \t~a"
                grob
                (car grob)
                (if (not (null? (cdr grob)))
                    (cadr grob)
                    "none")
                (symbol? (car grob))
                (if (not (null? (cdr grob)))
                    (symbol? (cadr grob))
                    "none found"))
     (newline)
;; coloring the grob(s)
     #{
       \override $grob . color = #(x11-color 'grey40)
       $mus
       \revert $grob . color
     #})


\relative { \ed NoteHead c' \ed #'(Staff Accidental) { cis dis } es }
\relative { \ed NoteHead c' \ed Staff.Accidental { cis dis } es }

HTH,
   Harm




reply via email to

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