2017-06-25 8:40 GMT+02:00 Menu Jacques <imj-...@bluewin.ch>:
> Thanks Simon for the idea.
>
> I’ve defined the following Scheme function for my needs, with accidental 
> style forced to ‘forget' for the given note:
>
> editorialAccidental =
> #(define-music-function
>   (note)
>   (ly:music?)
>   #{
>     \once\accidentalStyle forget
>     \once\set suggestAccidentals = ##t
>     #note
>   #})
>
> {
>   \editorialAccidental cis4
>   cis4
>   dis4
>   \editorialAccidental cis4
> }
>
> JM


Hi Jaques,

while calling a variable, here 'note', in embedded lily-code, i.e. in
#{ ... #}, always use $note not #note.
Doing something with #note destructively changes 'note', so you can't
access the unchanged 'note' anymore.
Working on $note works on a copy of 'note' so you still have access to
the original 'note'.

To illustrate:
In the scheme-sandbox, i.e. after having done in terminal:
lilypond scheme-sandbox

Try the following sequence:
(define xy #{ c''1 #})
(display-lily-music xy)
(display-lily-music #{ \withMusicProperty #'duration
#(ly:make-duration 2) #xy #})
(display-lily-music xy)

As opposed to:(define xyz #{ c''1 #})
(display-lily-music xyz)
(display-lily-music #{ \withMusicProperty #'duration
#(ly:make-duration 2) $xyz #})
(display-lily-music xyz)

Admittedly, you will not notice any difference in your example, it's a
minimal example, though.
In real life code you may experience some surprises under certain conditions.

Cheers,
  Harm

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

Reply via email to