On Thu, 2026-08-13 at 18:19 +0100, Richard Shann wrote:
> On Thu, 2026-08-13 at 18:49 +0200, David Kastrup wrote:
> > Richard Shann <[email protected]> writes:
> >
> > > On Thu, 2026-08-13 at 12:16 +0100, Richard Shann wrote:
> > > > On Thu, 2026-08-13 at 11:05 +0200, Lukas-Fabian Moser wrote:
> > > > > Hi Richard,
> > > > >
> > > > > Am 13.08.26 um 10:55 schrieb Richard Shann:
> > > > > > Is there a way of putting something like
> > > > > > medium = \normal-weight
> > > > > > in a header file to convert from uses of \medium in markup
> > > > > > in
> > > > > > LilyPond
> > > > > > 2.24 to pass 2.26 (so as to aviud going through physically
> > > > > > replacing
> > > > > > \medium with \normal-weight?)
> > > > > > The above doesn't work, I guess because it's being invoked
> > > > > > inside
> > > > > > markup...
> > > > >
> > > > > The syntax is a bit more complicated in the case of markup
> > > > > functions:
> > > > >
> > > > > \markup medium = \markup \normal-weight \etc
> > > >
> > > > Perfect! Thank you very much.
> > >
> > > I looked up the docs on using ly:version? to allow older files to
> > > be
> > > typeset in older or newer syntax and I understood this should
> > > work:
> > >
> > > #(if (ly:version? > '(2 24))
> > > #{ \markup medium = \markup \normal-weight \etc #})
> >
> > Then the docs are really wrong. #{ ... #} generally is for
> > creating
> > expressions, not side effects, and an assignment is a side effect.
> >
> > > gives
> > > \markup medium = \markup \normal-weight \etc
> > > /tmp/frescobaldi-oorxliqz/tmp7qct88s5/document.ly:4:17: error:
> > > syntax
> > > error, unexpected '='
> > >
> > > I didn't manage to nail down an explanation of #{ ... #} but it
> > > seemed
> > > like it was for inserting LilyPond syntax at that point in the
> > > file.
> >
> > No. It isn't for "inserting LilyPond syntax" but it is for writing
> > expressions utilizing LilyPond syntax instead of Scheme syntax.
> >
> > For older versions, you'd probably have to use something like
> >
> > #(define-markup-command (medium layout props arg) (markup?)
> > (interpret-markup layout props
> > #{ \markup \normal-weight arg #}))
>
> Thanks! That did the trick:
It seems I blundered testing this - the suggested code typesets the
word "arg":
%%%%%%%%%%%%%%%%%%%%%%%%%
\version "2.26.0"
#(define-markup-command (medium layout props arg) (markup?)
(interpret-markup layout props
#{ \markup \normal-weight arg #}))
{c''-\markup {"default text" \italic "italic text" \medium "medium
text"} }
%%%%%%%%%%%%%%%%%%%%%%%%%
But it seems you need $arg to reference it:
%%%%%%%%%%%%%%%%%%%%%%%%%
\version "2.26.0"
#(define-markup-command (medium layout props arg) (markup?)
(interpret-markup layout props
#{ \markup \normal-weight $arg #}))
{c''-\markup {"default text" \italic "italic text" \medium "medium
text"} }
Richard Shann