[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lilypond-user
Subject:    Re: Basic function question
From:       Urs Liska <lilypond () ursliska ! de>
Date:       2011-07-26 10:41:38
Message-ID: 4E2E99E2.3090701 () ursliska ! de
[Download RAW message or body]

Am 26.07.2011 12:25, schrieb David Kastrup:
> Urs Liska<lilypond@ursliska.de>  writes:
>
>> Hello list members,
>>
>> after fiddling around too long and getting lost with the basics, I
>> decided to ask my question here.
>> I know it's basic, and I wonder why I get stuck this way, but
>> obviously I'm confused and unable to find the right place in the docs.
>>
>> I want to write a function "instr" to produce formatted markup that I
>> can use like
>>
>> { c d e f^\instr "Vl." }
>>
>> which should be translated to (e.g.)
>>
>> { c d e f^\markup \bold \italic \huge { "Vl." } }
>>
>> Unfortunately I seem absolutely unable to find out how to define the
>> function so I can attach it to the note like in the example.
>>
>> Hopefully someone can either give me a working example or point me to
>> the exact location in the docs where I can fully understand this
>> issue.
> The docs are not useful for this.  A sequential music expression like
> that generated with #{ #} can't be attached in this manner.  But you
> should be able to do
>
> instr=#(define-music-function (parser location instrument) (string?)
> 	(make-music
> 	 'TextScriptEvent
> 	 'direction
> 	 UP
> 	 'text
> 	 (markup #:bold #:italic #:huge instrument)))
>
> Note that this has the upward direction builtin.  If you don't want to
> have the direction fixed in advance (you can always override it with
> explicit ^ and _ instead of -, however), remove 'direction UP.
>
> How do you arrive there?
>
> Take a look what
> \displayMusic { c^\markup { whatever } }
> produces and go from there by stripping the layers that don't belong in
> your expression.
>
Thank you very much,
that's the solution!

The point is to nest the markup construct within the 'text element.

Best
Urs




[Attachment #3 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    Am 26.07.2011 12:25, schrieb David Kastrup:
    <blockquote cite="mid:87y5zl72zu.fsf@fencepost.gnu.org" type="cite">
      <pre wrap="">Urs Liska <a class="moz-txt-link-rfc2396E" \
href="mailto:lilypond@ursliska.de">&lt;lilypond@ursliska.de&gt;</a> writes:

</pre>
      <blockquote type="cite">
        <pre wrap="">Hello list members,

after fiddling around too long and getting lost with the basics, I
decided to ask my question here.
I know it's basic, and I wonder why I get stuck this way, but
obviously I'm confused and unable to find the right place in the docs.

I want to write a function "instr" to produce formatted markup that I
can use like

{ c d e f^\instr "Vl." }

which should be translated to (e.g.)

{ c d e f^\markup \bold \italic \huge { "Vl." } }

Unfortunately I seem absolutely unable to find out how to define the
function so I can attach it to the note like in the example.

Hopefully someone can either give me a working example or point me to
the exact location in the docs where I can fully understand this
issue.
</pre>
      </blockquote>
      <pre wrap="">
The docs are not useful for this.  A sequential music expression like
that generated with #{ #} can't be attached in this manner.  But you
should be able to do

instr=#(define-music-function (parser location instrument) (string?)
	(make-music
	 'TextScriptEvent
	 'direction
	 UP
	 'text
	 (markup #:bold #:italic #:huge instrument)))

Note that this has the upward direction builtin.  If you don't want to
have the direction fixed in advance (you can always override it with
explicit ^ and _ instead of -, however), remove 'direction UP.

How do you arrive there?

Take a look what
\displayMusic { c^\markup { whatever } }
produces and go from there by stripping the layers that don't belong in
your expression.

</pre>
    </blockquote>
    Thank you very much,<br>
    that's the solution!<br>
    <br>
    The point is to nest the markup construct within the 'text element.<br>
    <br>
    Best<br>
    Urs<br>
    <br>
    <br>
    <font size="-1"><br>
    </font>
  </body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic