lilypond-user
[Top][All Lists]
Advanced

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

Re: markup function


From: David Kastrup
Subject: Re: markup function
Date: Sat, 05 Jan 2013 17:25:38 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Noeck <address@hidden> writes:

>> Have you tried looking into the "Extending LilyPond" manual?
>> 
>> <URL:http://lilypond.org/doc/v2.16/Documentation/extending/markup-functions>
>
> I did not reach it, because I did not understand the sections 2.1 and
> 2.2 and then I gave up. Examples would help me a lot in these sections.
> I played around, but I could not figure out how functions are defined
> and how scheme works. My test is below, just to show on which basic
> level I am stuck.
>
> \version "2.17.9"
>
> function = % does not work
> #(define-scheme-function
>   (parser location text)
>   (markup?)
>   \markup{ \with-url #"http" #text} )
>
> \function "Hallo"

Well, change this to
\version "2.17.9"

function =
#(define-scheme-function
  (parser location text)
  (markup?)
  #{ \markup{ \with-url #"http" #text } #})

\function "Hallo"

And it will work.  There was a #{ #} missing (you can't otherwise use
LilyPond syntax within Scheme), and #text} will complain because the
Scheme reader considers "text}" a single variable name which it can't
find anywhere.

Of course, this again requires at least 2.17.7:

commit a30c13f4658f03cb30820a27b42ddb4aea941380
Author: David Kastrup <address@hidden>
Date:   Mon Nov 5 23:13:07 2012 +0100

    Issue 2949: Allow (closed) scheme function calls as text scripts.
    
    One motivation of recent grammar changes was to make scheme variables
    identical to markup variables.  The obvious parallel idea of letting
    scheme function calls be available for calculating markups has not
    received similar attention.
    
    The purpose of this patch is to allow for using scheme function calls
    producing markup within text scripts.


In older versions, you'll have to go via define-markup-command:

> Section 2.5.3 finally has an example and using that, I could finally
> write the following function. But I only understand the part in #{ #}.
> The words "layout props" and the "interpret-markup" are still cryptic
> to me. Is there a documentation where this is described for noobs like
> me?

No.  I don't think there is reasonable documentation where this is
described for experts either.  Consider it a magic incantation.

> #(define-markup-command (myfunction layout props text) (markup?)
>   "Draw a double box around text."
>   (interpret-markup layout props
>     #{\markup \with-url #"http" { #text }#}))
>
> How can I combine two strings? The #"http" and the #text in this example?

It might make sense to look in the Guile manual for string operations.
Other than that, check out the notation manual for a description of
available markup commands (like \concat).

> How can I change a string to lower case?

That would again be something to look up in the Guile manual.

-- 
David Kastrup




reply via email to

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