From 3a50ddfdd7fb6a85a5266ac4adf3ff9ee6d5d378 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 17 Oct 2005 00:30:32 +0000 Subject: [PATCH] * lily/context-property.cc (execute_general_pushpop_property): robustness checks. * lily/parser.yy (music_property_def): allow \override #'a #'b = #c too. * lily/context-property.cc (lookup_nested_property): new function. (evict_from_alist): new function. (general_pushpop_property): new function. (execute_general_pushpop_property): rewrite. Support nested properties too. --- ChangeLog | 5 +++++ Documentation/user/introduction.itely | 4 ++-- lily/context-property.cc | 8 ++++++++ lily/note-head.cc | 1 + lily/parser.yy | 2 +- lily/stem.cc | 1 + scm/define-music-properties.scm | 1 + scm/document-translation.scm | 28 ++++++++++++++------------- 8 files changed, 34 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index be7900bee1..1bf3a05b47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2005-10-17 Han-Wen Nienhuys + * lily/context-property.cc (execute_general_pushpop_property): + robustness checks. + + * input/regression/override-nest.ly: new file. + * python/convertrules.py (FatalConversionError.subber): conversion rule for #'callbacks diff --git a/Documentation/user/introduction.itely b/Documentation/user/introduction.itely index 78bc0220aa..3d8b8c540e 100644 --- a/Documentation/user/introduction.itely +++ b/Documentation/user/introduction.itely @@ -319,7 +319,7 @@ fragment. (if (and (memq 'note-head-interface interfaces) (memq pos '(-2 -3 -5))) (begin - (ly:grob-set-property! grob 'print-function Text_interface::print) + (ly:grob-set-callback! grob 'stencil Text_interface::print) (ly:grob-set-property! grob 'font-family 'roman) (ly:grob-set-property! grob 'text @@ -336,7 +336,7 @@ fragment. \set autoBeaming = ##f \time 2/4 4 - \once \override NoteHead #'print-function = #Note_head::brew_ez_stencil + \once \override NoteHead #'callbacks #'stencil = #Note_head::brew_ez_stencil \once \override NoteHead #'style = #'cross diff --git a/lily/context-property.cc b/lily/context-property.cc index d7923c7018..4ee9a43002 100644 --- a/lily/context-property.cc +++ b/lily/context-property.cc @@ -161,6 +161,14 @@ execute_general_pushpop_property (Context *context, { SCM current_value = scm_car (current_context_val); SCM daddy = scm_cdr (current_context_val); + + if (!scm_is_pair (grob_property_path) + || !scm_is_symbol (scm_car (grob_property_path))) + { + programming_error ("Grob property path should be list of symbols."); + return; + } + SCM symbol = scm_car (grob_property_path); SCM new_alist = evict_from_alist (symbol, current_value, daddy); diff --git a/lily/note-head.cc b/lily/note-head.cc index 76ce69b706..3b80b114ba 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -153,6 +153,7 @@ ADD_INTERFACE (Note_head, "note-head-interface", /* properties */ "note-names " "accidental-grob " + "glyph-name " "stem-attachment " "style " ); diff --git a/lily/parser.yy b/lily/parser.yy index 52c07bf867..4ddc525e55 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -2755,7 +2755,7 @@ property_op_to_music (SCM op) } else if (tag == ly_symbol2scm ("pop")) { m = MY_MAKE_MUSIC ("RevertProperty"); - grob_path = scm_cdr (args); + grob_path = args; } m->set_property ("symbol", symbol); diff --git a/lily/stem.cc b/lily/stem.cc index cb41fa15fb..c9974220a8 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -467,6 +467,7 @@ Stem::calc_direction (SCM smob) return scm_from_int (dir); } +/* A separate function, since this is used elsewhere too. */ Direction Stem::get_default_dir (Grob *me) { diff --git a/scm/define-music-properties.scm b/scm/define-music-properties.scm index 8bc0e995ab..263c188a62 100644 --- a/scm/define-music-properties.scm +++ b/scm/define-music-properties.scm @@ -48,6 +48,7 @@ descend in the context tree.") (elements ,ly:music-list? "A list of elements for sequential of simultaneous music, or the alternatives of repeated music. ") (force-accidental ,boolean? "If set, a cautionary accidental should always be printed on this note") (grob-property ,symbol? "The symbol of the grob property to set. ") + (grob-property-path ,list? "A list of symbols, locating a nested grob property, e.g. (beamed-lengths details). ") (grob-value ,scheme? "The value of the grob property to set") (input-tag ,scheme? "Arbitrary marker to relate input and output") (inversion ,boolean? "If set, this chord note is inverted.") diff --git a/scm/document-translation.scm b/scm/document-translation.scm index a7ce3b9934..096de09c49 100644 --- a/scm/document-translation.scm +++ b/scm/document-translation.scm @@ -115,25 +115,27 @@ (define (document-property-operation op) (let ((tag (car op)) - (body (cdr op)) - (sym (cadr op))) + (context-sym (cadr op)) + (args (cddr op)) + ) (cond ((equal? tag 'push) + (let* + ((value (car args)) + (path (cdr args))) + (string-append - "@item " - (if (null? (cddr body)) - "Revert " - "Set ") - "grob-property @code{" - (symbol->string (cadr body)) - "} in @ref{" (symbol->string sym) - "}" + "@item Set " + (format "grob-property @code{~a} " (string-join path " ")) + (format " in @ref{~a} " sym) (if (not (null? (cddr body))) - (string-append " to @code{" (scm->texi (cadr (cdr body))) "}" )) - "\n")) + (format " to @code{~a}" (scm->texi value)) + "") + + "\n"))) ((equal? (object-property sym 'is-grob?) #t) "") - ((equal? (car op) 'assign) + ((equal? tag 'assign) (string-append "@item Set translator property @code{" (symbol->string (car body)) -- 2.39.5