Re: Scheme code for extracting LilyPond header properties?

2007-11-04 Thread Erik Sandberg
On Tuesday 09 October 2007, John Zaitseff wrote:
 Dear Nicolas / LilyPonders,

 I store a field in the header, lastupdated, in the form 09-Oct-2007;
 the \parsed-date function converts that to something like 9 October,
 2007:

   % \parsed-date DATE - convert a DD-MMM- property to a fully printed
 date #(define-markup-command (parsed-date layout props date) (symbol?)
 Convert the property @var{date} containing a date in the
   form DD-MMM- into a nicely formatted stencil output D ,
   .
   (let* ((datestr (chain-assoc-get date props)))
   (interpret-markup layout props
   (if (string? datestr)
   (markup #:simple
   (strftime %e %B, %Y (car (strptime %d-%b-%Y
 datestr datestr

 (Of course, I should rewrite that to make it somewhat more robust.
 It works for me, however).

You may want to use SRFI-19 for this,
http://www.gnu.org/software/guile/manual/html_node/SRFI_002d19.html#SRFI_002d19

Erik


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


Re: Scheme code for extracting LilyPond header properties?

2007-10-08 Thread John Zaitseff
Dear Nicolas / LilyPonders,

Nicolas Sceaux wrote:

 John Zaitseff 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:...; ...
 
 [ Actual detailed explanation follows... ]

Thank you very much for your help!  I actually wrote the function
to take the header:maintainer AND header:maintainerEmail properties
into account:

  % \email-property EMAIL ARG - add a mailto link based on property EMAIL
  #(define-markup-command (email-property layout props email arg)
  (symbol? markup?)
  Add a mailto link to property @var{email} around @var{arg}.
  This only works in the PDF backend.
  (let* ((address (chain-assoc-get email props)))
  (interpret-markup layout props
  (if (string? address)
  (markup #:with-url (string-append mailto:; address) arg)
  arg

For other people's edification :-), the following is my tagline:

  tagline = \markup {
  \fontsize #-3.5
  \override #'(word-space . 0)
  \line {
  Typeset by 
  \email-property #'header:maintainerEmail
  \fromproperty #'header:maintainer
   using 
  \with-url #http://www.lilypond.org/;
  \line {
  LilyPond 
  #(ly:export (string-append (lilypond-version) .))
  }
File version 
  \fromproperty #'header:version
  , last modified 
  \parsed-date #'header:lastupdated
  .
  }
  }

I store a field in the header, lastupdated, in the form 09-Oct-2007;
the \parsed-date function converts that to something like 9 October,
2007:

  % \parsed-date DATE - convert a DD-MMM- property to a fully printed date
  #(define-markup-command (parsed-date layout props date) (symbol?)
  Convert the property @var{date} containing a date in the
  form DD-MMM- into a nicely formatted stencil output D ,
  .
  (let* ((datestr (chain-assoc-get date props)))
  (interpret-markup layout props
  (if (string? datestr)
  (markup #:simple
  (strftime %e %B, %Y (car (strptime %d-%b-%Y 
datestr
  datestr

(Of course, I should rewrite that to make it somewhat more robust.
It works for me, however).


Once again, thank you for your help.

Yours truly,

John Zaitseff

-- 
John Zaitseff,--_|\The ZAP Group
Phone:  +61 2 9643 7737 /  \   Sydney, Australia
E-mail: [EMAIL PROTECTED]   \_,--._*   http://www.zap.org.au/
  v


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


Re: Scheme code for extracting LilyPond header properties?

2007-10-04 Thread Graham Percival

Carl Sorensen wrote:

This is a great example of how to work with Scheme code.

It should be added to the docs, IMO.


Please go through LSR first; that makes it much easier for everybody 
involved.



Perhaps also to the LSR.


Please do so.

Cheers,
- Graham


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


Scheme code for extracting LilyPond header properties?

2007-10-02 Thread John Zaitseff
Dear LilyPonders,

I am not a particular expert on Scheme, hence my request for help.
I am trying to write a new version of tagline that includes the
particular document maintainer's name and e-mail address.  Thus, I
have the following in my header:

\header {
...
maintainer = John Zaitseff
maintainerEmail = [EMAIL PROTECTED]
}

and I redefine tagline as:

tagline = \markup {
\teeny
\override #'(word-space . 0)
\line {
% [... other information ...]
Document maintained by 
\fromproperty #'header:maintainer
.
}
}

So far, so good.  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)

It's the XXX that I'm having problems with!  How do I extract the
header:maintainerEmail property as a Scheme string?  Any help would
be much appreciated!

Yours truly,

John Zaitseff

-- 
John Zaitseff,--_|\The ZAP Group
Phone:  +61 2 9643 7737 /  \   Sydney, Australia
E-mail: [EMAIL PROTECTED]   \_,--._*   http://www.zap.org.au/
  v


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