lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Defining a new markup command (e.g. \lower by a specified amount)


From: David Kastrup
Subject: Re: Defining a new markup command (e.g. \lower by a specified amount)
Date: Wed, 16 May 2012 10:36:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

Philip Thomas <address@hidden> writes:

> I am having great difficulty getting the hang of defining new markup commands.
>
> The examples given in the Extending 
> manual in section 2.2.3 "New markup command definition" are
> comprehensible to me in their own right, but they aren't
> exactly simple examples, and I have so far failed to adapt definitions
> found in the scm/define-markup-commands.scm file
> to make my own new commands.
>
> The particular problem that I'm trying to get to grips with at the
> moment is this:
>
> I 
> want to use the \lower command at about 15 places in text in a \markup
> block (i.e. outside the \score block). The
> \lower command works just fine to get the spacing I want between
> sections of text (whereas both \override #'(baseline-
> skip . xx) and \vspace #xx have proved quirky). The problem is that I
> don't at this stage know exactly how much I want
> to lower the text by (\lower #xx). When the overall layout of the
> score is settled, I would like to experiment with
> different values of N, without having to change each \lower command
> separately. The solution seemed to me to be to
> define a new markup command (e.g. \dropNextline) which specifies the
> amount to which the line should be lowered. Then
> my 15 entries could all read \dropNextLine { text text text }, and the
> experiment would only involve changing the value
> of xx in the define-markup-command code until the overall spacing is
> correct when judged by the eye. But I'm bu**ered
> if I can get it to work. Sorry if I'm ignorant of something I should
> have found in the documentation.

For what it's worth, define-markup-command is a macro, and in particular
the command name it defines is treated in a macroesque way.  That pretty
much implies that a useful command calling define-markup-command with a
non-constant name will need to be a macro as well, or alternatively call
primitive-eval manually (a macro does not evaluate its arguments as
usual, but interprets its body _twice_ instead).

You can write something like

(define-markup-command (drop-next-line layout props m) (markup?)
  (interpret-markup layout props #{ \markup \lower #3 #m #}))

This will provide a command \drop-next-line taking a markup.  Note that
{ text text text } is  not actually a markup, but a markup list (a top
level markup would wrap it into a \line without asking), so maybe you
want to go for
(define-markup-command (drop-next-line layout props m) (markup-list?)
  (interpret-markup layout props #{ \markup \lower #3 \line #m #}))
instead.

Note the spelling: markup commands usually don't use CamelCaps by
convention but rather dashed-names.

-- 
David Kastrup




reply via email to

[Prev in Thread] Current Thread [Next in Thread]