>
> From: Marc Evanstein <m...@marcevanstein.com>
> To: David Kastrup <d...@gnu.org>
> Cc: lilypond-user@gnu.org
> Date: Mon, 17 Sep 2018 18:14:31 +0000
> Subject: Re: variables for specific kinds of markup?
> Thanks so much – changing it to define-event-function worked perfectly. Is
> a markup considered an "event" rather than "music"? Was
> define-music-function somehow returning that event attached to empty music
> or something?
>
> At any rate, glad to hear that this is getting simpler in the near future,
> and many thanks for all the help!
>
> September 17, 2018 8:01 AM, "David Kastrup" <d...@gnu.org> wrote:
>
> > "Marc Evanstein (formerly Evans)" <m...@marcevanstein.com> writes:
> >
> >> Hi all,
> >>
> >> I'm trying to create a variable to handle a certain type of markup
> >> text. For instance, I'd like percussion strikings to be in small caps
> >> above the staff, and what I really want is to define some sort of
> >> macro that replaces all instances of "\striking { theText }" with
> >> "^\markup\smallCaps { theText }".
> >>
> >> The following clearly doesn't work (much as I would like it to):
> >>
> >> striking = ^\markup\smallCaps
> >
> > Current master will allow
> >
> > striking = ^\markup \smallCaps \etc
> >
> >> From searching around, it seems like I need to define a function using
> >> scheme. I tried this:
> >>
> >> striking = #(define-music-function (parser location text)
> >> (string?)
> >> #{
> >> ^\markup\smallCaps { #text }
> >> #})
> >>
> >> ... and while the single line "\striking mallet" seems to render the
> >> word mallet as a smallCaps markup above a dummy staff, when I try to
> >> incorporate it into a series of notes, e.g.:
> >>
> >> {c'4 \striking mallet d'4 e'4 f'4 }
> >>
> >> I get an "error: unexpected post-event". What exactly does that mean?
> >
> > Current master would have worked as expected for this use...
> >
> > At any rate, you are pretty close (whether we are talking about 2.18 or
> > 2.19). Just use define-event-function instead of define-music-function
> > .
> >
> > And rejoice that LilyPond will have fewer stumbling blocks in the near
> > future. Or at least will be better at hiding the stumbling blocks so
> > you'll just get hit by them when digging deeper.
> >
> > --
> > David Kastrup
>
>
>
You could also consider writing your function to use
the empty chord construct <> as an anchor for your markup.

That might make it more bulletproof since you avoid having
to care about the data type of the previous element.

\version "2.19.15"

striking = #(define-music-function
(parser location text)
    (string?)
    #{
     <>^\markup\smallCaps { #text }
    #}
)

{c'4 \striking mallet d'4 e'4 f'4 }


HTH,

Elaine Alt
415 . 341 .4954                                           "*Confusion is
highly underrated*"
ela...@flaminghakama.com
Producer ~ Composer ~ Instrumentalist
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to