From: David Kastrup Date: Mon, 12 Jun 2017 11:44:51 +0000 (+0200) Subject: Issue 5145/2: Allow $... to specify a markup command X-Git-Url: https://git.donarmstrong.com/?p=lilypond.git;a=commitdiff_plain;h=c3b51542671a9af5647d4cbc63f7c8ae98c1c2bd Issue 5145/2: Allow $... to specify a markup command This is a partial (though more flexible) substitute for \on-the-fly since it allows to replace \on-the-fly #(lambda (layout props args) ...) with $(let ((fun (lambda (layout props args) ...))) (set! (markup-command-signature fun) (list markup?)) fun) Namely: ad-hoc written functions (probably most useful when written using macros) can be employed as markup commands when preceded with $ as long as they have a suitable markup command signature attached. This feature is mainly added for consistency with music functions. --- diff --git a/lily/include/lily-imports.hh b/lily/include/lily-imports.hh index d930f69cf9..1b63a53717 100644 --- a/lily/include/lily-imports.hh +++ b/lily/include/lily-imports.hh @@ -86,6 +86,7 @@ namespace Lily { extern Variable make_safe_lilypond_module; extern Variable make_span_event; extern Variable markup_p; + extern Variable markup_command_signature; extern Variable markup_list_p; extern Variable midi_program; #if !GUILEV2 diff --git a/lily/lexer.ll b/lily/lexer.ll index 19f84616f3..21d2fc1acc 100644 --- a/lily/lexer.ll +++ b/lily/lexer.ll @@ -417,6 +417,20 @@ BOM_UTF8 \357\273\277 sval = eval_scm (sval, hi, '$'); + if (YYSTATE == markup && ly_is_procedure (sval)) + { + SCM sig = Lily::markup_command_signature (sval); + if (scm_is_true (sig)) + { + yylval = sval; + int token = MARKUP_FUNCTION; + if (scm_is_true (scm_object_property + (sval, ly_symbol2scm ("markup-list-command")))) + token = MARKUP_LIST_FUNCTION; + push_markup_predicates (sig); + return token; + } + } int token = scan_scm_id (sval); if (!scm_is_eq (yylval, SCM_UNSPECIFIED)) return token; diff --git a/lily/lily-imports.cc b/lily/lily-imports.cc index 62e58b603c..f3cd3b1ab2 100644 --- a/lily/lily-imports.cc +++ b/lily/lily-imports.cc @@ -80,6 +80,7 @@ namespace Lily { Variable make_safe_lilypond_module ("make-safe-lilypond-module"); Variable make_span_event ("make-span-event"); Variable markup_p ("markup?"); + Variable markup_command_signature ("markup-command-signature"); Variable markup_list_p ("markup-list?"); Variable midi_program ("midi-program"); #if !GUILEV2