Urs Liska <u...@openlilylib.org> writes: >>> This is better because obviously it contains the correct location. (14:3 >>> of the input file). >>> However, I don't know how to get "inside" that <Prob: or if there's >>> another, more straightforward way to get to the location of the grob. >> The cause obviously is a stream event. Try something like >> >> (ly:event-warning (event-cause grob) "This is bad!") > > Obviously this is what I was looking for. > Would I have had a reasonable chance to find it myself in the docs?
No. In C++, the function to use is Grob::warning. There is no Scheme equivalent as of now. Feel free to implement it. It would be something like (define (grob-warning grob format . args) (let ((ev (event-cause grob))) (if ev (apply ly:event-warning ev format args) (apply ly:warning format args)))) >> Note that the string is a format string and can take ~S-like format >> elements to be followed by corresponding values in the function call. >> Also notice that ly:event-warning is not robust against a missing event >> (currently). > > That means if (event-cause grob) doesn't evaluate something useful it > will crash and I should take precautions? But can a grob in a stencil > that overrides a slur *not* have an event anyway? Sure. dak@lola:/usr/local/tmp/lilypond$ git grep "\(make_item\|make_spanner\).*SCM_" lily/ambitus-engraver.cc: ambitus_ = make_item ("AmbitusLine", SCM_EOL); lily/ambitus-engraver.cc: group_ = make_item ("Ambitus", SCM_EOL); lily/ambitus-engraver.cc: heads_[d] = make_item ("AmbitusNoteHead", SCM_EOL); lily/ambitus-engraver.cc: accidentals_[d] = make_item ("AmbitusAccidental", SCM_EOL); lily/axis-group-engraver.cc: return make_spanner ("VerticalAxisGroup", SCM_EOL); lily/bar-engraver.cc: bar_ = make_item ("BarLine", SCM_EOL); lily/bar-number-engraver.cc: text_ = make_item ("BarNumber", SCM_EOL); lily/break-align-engraver.cc: align_ = make_item ("BreakAlignment", SCM_EOL); lily/break-align-engraver.cc: left_edge_ = random_source->make_item ("LeftEdge", SCM_EOL); lily/clef-engraver.cc: Item *c = make_item ("Clef", SCM_EOL); lily/clef-engraver.cc: Item *g = make_item ("ClefModifier", SCM_EOL); lily/collision-engraver.cc: col_ = make_item ("NoteCollision", SCM_EOL); lily/completion-note-heads-engraver.cc: Spanner *p = make_spanner ("Tie", SCM_EOL); lily/cue-clef-engraver.cc: Item *g = make_item ("ClefModifier", SCM_EOL); lily/cue-clef-engraver.cc: Item *c = make_item ("CueClef", SCM_EOL); lily/cue-clef-engraver.cc: clef_ = make_item ("CueEndClef", SCM_EOL); lily/custos-engraver.cc: Item *custos = make_item ("Custos", SCM_EOL); lily/dot-column-engraver.cc: dotcol_ = make_item ("DotColumn", SCM_EOL); lily/figured-bass-engraver.cc: = make_spanner ("BassFigureContinuation", SCM_EOL); lily/figured-bass-engraver.cc: alignment_ = make_spanner ("BassFigureAlignment", SCM_EOL); lily/figured-bass-engraver.cc: group.group_ = make_spanner ("BassFigureLine", SCM_EOL); lily/fingering-column-engraver.cc: fingering_columns_[d] = make_item ("FingeringColumn", SCM_EOL); lily/grace-spacing-engraver.cc: grace_spacing_ = make_spanner ("GraceSpacing", SCM_EOL); lily/grid-line-span-engraver.cc: spanline_ = make_item ("GridLine", SCM_EOL); lily/grid-point-engraver.cc: make_item ("GridPoint", SCM_EOL); lily/instrument-name-engraver.cc: text_spanner_ = make_spanner ("InstrumentName", SCM_EOL); lily/instrument-switch-engraver.cc: text_ = make_item ("InstrumentSwitch", SCM_EOL); lily/kievan-ligature-engraver.cc: return make_spanner ("KievanLigature", SCM_EOL); lily/ledger-line-engraver.cc: span_ = make_spanner ("LedgerLineSpanner", SCM_EOL); lily/measure-grouping-engraver.cc: grouping_ = make_spanner ("MeasureGrouping", SCM_EOL); lily/mensural-ligature-engraver.cc: return make_spanner ("MensuralLigature", SCM_EOL); lily/ottava-engraver.cc: span_ = make_spanner ("OttavaBracket", SCM_EOL); lily/repeat-tie-engraver.cc: semi_tie_column_ = make_item ("RepeatTieColumn", SCM_EOL); lily/rest-collision-engraver.cc: rest_collision_ = make_item ("RestCollision", SCM_EOL); lily/script-column-engraver.cc: script_column_ = make_item ("ScriptColumn", SCM_EOL); lily/script-row-engraver.cc: script_row_ = make_item ("ScriptRow", SCM_EOL); lily/separating-line-group-engraver.cc: current_spacings_.staff_spacing_ = make_item ("StaffSpacing", SCM_EOL); lily/spacing-engraver.cc: spacing_ = make_spanner ("SpacingSpanner", SCM_EOL); lily/span-arpeggio-engraver.cc: span_arpeggio_ = make_item ("Arpeggio", SCM_EOL); lily/span-bar-engraver.cc: spanbar_ = make_item ("SpanBar", SCM_EOL); lily/staff-symbol-engraver.cc: span_ = make_spanner ("StaffSymbol", SCM_EOL); lily/stanza-number-engraver.cc: text_ = make_item ("StanzaNumber", SCM_EOL); lily/vaticana-ligature-engraver.cc: return make_spanner ("VaticanaLigature", SCM_EOL); lily/vaticana-ligature-engraver.cc: Item *dotcol = make_item ("DotColumn", SCM_EOL); lily/vertical-align-engraver.cc: valign_ = make_spanner (top_level_ ? "VerticalAlignment" : "StaffGrouper", SCM_EOL); lily/volta-engraver.cc: volta_bracket_ = make_spanner ("VoltaBracket", SCM_EOL); lily/volta-engraver.cc: volta_spanner_ = make_spanner ("VoltaBracketSpanner", SCM_EOL); All those grobs have no event-cause. Whoever calls make_item, make_spanner or ly:engraver-make-grob (why no spanner here?) gets to decide what cause to specify. Can be another grob, can be an event, can be nothing. >> But really, really, really don't use define-scheme-function for >> something not supposed to work on LilyPond input. > > OK, I've changed that. > But is that just unnecessarily complicated/expensive or could it cause > *real* problems too? If you use \testLocation in your LilyPond file, you'll get some rather inventive error messages. -- David Kastrup _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user