Am So., 18. Nov. 2018 um 21:15 Uhr schrieb David Kastrup <d...@gnu.org>: > > Thomas Morley <thomasmorle...@gmail.com> writes: > > > Am So., 18. Nov. 2018 um 20:40 Uhr schrieb David Kastrup <d...@gnu.org>: > > > >> Just do > >> > >> (eq? ctx (ly:context-find ctx 'Staff)) > >> > >> -- > >> David Kastrup > > > > I did not even consider to use ly:context-find. The description says: > > Find a _parent_ of context that has name or alias name. Return #f if not > > found. > > So I expected it could return > > Staff as parent of Voice > > StaffGroup as parent of Staff > > Score as parent of StaffGroup > > > > Similar to > > Function: ly:context-parent context > > Return the parent of context, #f if none. > > Although this one returns a tree of contexts not even a single parent. > > At least for me this was a surprise. > > > > Is my understanding of parents with contexts entirely wrong ...? > > Probably not. I remembered that the function was there. I read the doc > string and said "huh?". I read the C++ code and said "WTF?". And then > I pretended that this was totally obvious to make me look smart.
Rofl > In my > defense, I did not write that doc string (at least I hope so). > > "Find a parent" does not make a lot of sense considering that each > context has at most one parent. > > It's more like "Find among the chain of successive direct parents > starting with the context itself". Indeed. > Some of our doc strings are not particularly helpful. Very true. > At least the > function itself is. Indeed. Some background: Today I was beaten by https://sourceforge.net/p/testlilyissues/issues/556/ "fingeringOrientations affects cross-voices arpeggio" which is still present with 2.21.0 and tried to find a workaround. As a side-effect of this thread I learned that doing whatever = \context Staff \applyContext #(lambda (ctx) ...) will affect Staff _and_ all it's alias. Furthermore it can be put as is into \with or \layout or directly into music. So I don't need to restrict it to Staff-like contexts anymore, this is now built-in. :) But here the code: correctConnectedArpeggio = \context Staff \applyContext #(lambda (ctx) (let* ((x-offs '()) (mom '())) (ly:context-pushpop-property ctx 'Arpeggio 'before-line-breaking (lambda (grob) (if (negative? (ly:grob-property grob 'direction)) (let ((grob-mom (grob::when grob)) (x-off-proc (ly:grob-property-data grob 'X-offset))) (set! x-offs (if (equal? grob-mom mom) (cons (x-off-proc grob) x-offs) '())) (set! mom (grob::when grob)) (if (pair? x-offs) (ly:grob-set-property! grob 'X-offset ;; Mmmh, is using the arbitrary 10 sufficient? (apply min 10 (drop x-offs 1)))))))))) melody = \relative c'' { \voiceOne \set fingeringOrientations = #'(left) <g-0 c-1>2\arpeggio \set fingeringOrientations = #'(right) <g-0 c-1>\arpeggio \set fingeringOrientations = #'(up) <g-0 c-1>1\arpeggio } bass = \relative c' { \voiceTwo \set fingeringOrientations = #'(left) <c-3>2\arpeggio \set fingeringOrientations = #'(right) <c-3>\arpeggio \set fingeringOrientations = #'(down) <c-3>1\arpeggio } \score { \context Staff \with { \consists "Span_arpeggio_engraver" \correctConnectedArpeggio } << \set Staff.connectArpeggios = ##t \context Voice = "melody" { \melody } \context Voice = "bass" { \bass } >> } Thanks, Harm P.S. You _are_ smart :)) _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user