John Zaitseff <[EMAIL PROTECTED]> writes:

> [...]  What I would like to do, however, is to replace
> the "\fromproperty #'header:maintainer" with something like:
>
>     \with-url #"mailto:[EMAIL PROTECTED]"
>         \fromproperty #'header:maintainer
>
> except that I would like to extract the actual e-mail address from
> header:maintainerEmail: something like:
>
>     \with-url #(string-append "mailto:"; XXX)

Ok so basicaly you want a \email-property markup command that looks for
a header property and outputs something equivalent to:

  \with-url #"mailto:..."; "..."

First look at the \fromproperty code in scm/define-markup-command.scm,
to find out how the property is got:

(define-builtin-markup-command (fromproperty layout props symbol) (symbol?)
  "Read the @var{symbol} from property settings, and produce a stencil
from the markup contained within.  If @var{symbol} is not defined, it
returns an empty markup."
  (let* ((m (chain-assoc-get symbol props)))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Your \email-property markup command will begin the same way:

(define-markup-command (email-property layout props symbol) (symbol?)
  (let ((address (chain-assoc-get symbol props)))

(use `define-markup-command' for user defined commands).

Then, figure out out to build the markup with this address
argument. Inspect other markup commands in that file, and the
documentation. Supposing for the moment that address is a string:

  (markup #:with-url (string-append "mailto:"; address) address)

which is the scheme way of building the markup:

  \markup \with-url #(string-append "mailto:"; address) \address

Finally, as you can notice by reading other markup command definitions,
markup commands shall return a stencil, not a markup. You do that by
calling `interpret-markup':

  (interpret-markup layout props (markup ...))

So you markup command definition may look like that:

(define-markup-command (email-property layout props symbol) (symbol?)
  (let ((address (chain-assoc-get symbol props)))
    (interpret-markup layout props
                      (markup #:with-url (string-append "mailto:"; address)
                                         address))))

Actually address is not necessarily a string, so you may want to add a
test here, in case address is actually a markup:

(define-markup-command (email-property layout props symbol) (symbol?)
  (let ((address (chain-assoc-get symbol props)))
    (interpret-markup layout props
                      (if (string? address)
                          (markup #:with-url (string-append "mailto:"; address)
                                              address)
                          address))))


------- test-email.ly  -------
#(define-markup-command (email-property layout props symbol) (symbol?)
  (let ((address (chain-assoc-get symbol props)))
    (interpret-markup layout props
                      (if (string? address)
                          (markup #:with-url (string-append "mailto:"; address)
                                              address)
                          address))))

\header {
  email = "[EMAIL PROTECTED]"
  emailMarkup = \markup \bold [EMAIL PROTECTED]
  tagline = \markup \column {
    Emails:
    \email-property #'header:email
    \email-property #'header:emailMarkup
  } 
}

\markup Test
------- test-email.ly  -------

nicolas


_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to