ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* differences of perl/ruby texexec
@ 2007-05-04 14:54 Henning Hraban Ramm
  2007-05-04 18:17 ` Aditya Mahajan
  0 siblings, 1 reply; 8+ messages in thread
From: Henning Hraban Ramm @ 2007-05-04 14:54 UTC (permalink / raw)
  To: ConTeXt ML

Ahoi!

While processing my LilyPond/ConTeXt songbook, I experience still the  
same behaviour as in 2006-10:

The checking, if a LilyPond buffer/temp file has changed, works only  
with the old Perl texexec, the recent Ruby version creates/processes  
the files only if they're missing completely and then still  
uncomplete: after 20-some songs, some buffers get dropped, so that  
LilyPond score and ConTeXt lyrics don't match.

But I can't simply use the Perl texexec, because that doesn't create  
table of contents and references. Besides being much slower.

Looks like the workaround of first Perl, then Ruby gives the expected  
result, but it's an annoyance.

Maybe it's only a problem of the LilyPond module, but I guess the  
filechange check is somehow broken in the Ruby version.

What details should I provide to track the problem down?

Greetlings from Lake Constance!
Hraban
---
http://www.fiee.net/texnique/
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: differences of perl/ruby texexec
  2007-05-04 14:54 differences of perl/ruby texexec Henning Hraban Ramm
@ 2007-05-04 18:17 ` Aditya Mahajan
  2007-05-04 18:58   ` Henning Hraban Ramm
  0 siblings, 1 reply; 8+ messages in thread
From: Aditya Mahajan @ 2007-05-04 18:17 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Fri, 4 May 2007, Henning Hraban Ramm wrote:

> Ahoi!
>
> While processing my LilyPond/ConTeXt songbook, I experience still the
> same behaviour as in 2006-10:
>
> The checking, if a LilyPond buffer/temp file has changed, works only
> with the old Perl texexec, the recent Ruby version creates/processes
> the files only if they're missing completely and then still
> uncomplete: after 20-some songs, some buffers get dropped, so that
> LilyPond score and ConTeXt lyrics don't match.
>
> But I can't simply use the Perl texexec, because that doesn't create
> table of contents and references. Besides being much slower.
>
> Looks like the workaround of first Perl, then Ruby gives the expected
> result, but it's an annoyance.
>
> Maybe it's only a problem of the LilyPond module, but I guess the
> filechange check is somehow broken in the Ruby version.
>
> What details should I provide to track the problem down?

I usually find the output of texmfstart --verbose texexec --verbose to be 
useful in seeing what is going wrong. I think that the R module also uses 
the --ifchanged switch. If something has broken, it will also affect the R 
module.

Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: differences of perl/ruby texexec
  2007-05-04 18:17 ` Aditya Mahajan
@ 2007-05-04 18:58   ` Henning Hraban Ramm
  2007-05-04 19:15     ` Aditya Mahajan
  0 siblings, 1 reply; 8+ messages in thread
From: Henning Hraban Ramm @ 2007-05-04 18:58 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 2007-05-04 um 20:17 schrieb Aditya Mahajan:

> I usually find the output of texmfstart --verbose texexec --verbose  
> to be
> useful in seeing what is going wrong. I think that the R module  
> also uses
> the --ifchanged switch. If something has broken, it will also  
> affect the R
> module.

Actually it was easy, and I remember to have that problem reported  
when I enhanced the LilyPond module:

It says the following with *-1.tmp for every song, i.e. the counter  
doesn't work in the Ruby version:
"""
TeXUtil | running texmfstart --ifchanged=prd_winternacht- 
lilypond-1.tmp --exec bin:lilypond -b eps -dno-gs-load-fonts - 
dinclude-eps-fonts prd_winternacht-lilypond-1.tmp
"""

In the module it's defined as:
"""
\global\advance\lily!figures\plusone
\edef\lily!filename{\bufferprefix lilypond-\the\lily!figures}
...
\edef\LP{texmfstart --ifchanged=\lily!filename.tmp --exec  
bin:lilypond -b eps -dno-gs-load-fonts -dinclude-eps-fonts \lily! 
filename.tmp}
"""

I still don't understand a lot of TeX programming, so I've no clue.


Greetlings from Lake Constance!
Hraban
---
http://www.fiee.net/texnique/
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: differences of perl/ruby texexec
  2007-05-04 18:58   ` Henning Hraban Ramm
@ 2007-05-04 19:15     ` Aditya Mahajan
  2007-05-04 19:50       ` Henning Hraban Ramm
  0 siblings, 1 reply; 8+ messages in thread
From: Aditya Mahajan @ 2007-05-04 19:15 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Fri, 4 May 2007, Henning Hraban Ramm wrote:

> Am 2007-05-04 um 20:17 schrieb Aditya Mahajan:
>
>> I usually find the output of texmfstart --verbose texexec --verbose
>> to be
>> useful in seeing what is going wrong. I think that the R module
>> also uses
>> the --ifchanged switch. If something has broken, it will also
>> affect the R
>> module.
>
> Actually it was easy, and I remember to have that problem reported
> when I enhanced the LilyPond module:
>
> It says the following with *-1.tmp for every song, i.e. the counter
> doesn't work in the Ruby version:
> """
> TeXUtil | running texmfstart --ifchanged=prd_winternacht-
> lilypond-1.tmp --exec bin:lilypond -b eps -dno-gs-load-fonts -
> dinclude-eps-fonts prd_winternacht-lilypond-1.tmp
> """
>
> In the module it's defined as:
> """
> \global\advance\lily!figures\plusone
> \edef\lily!filename{\bufferprefix lilypond-\the\lily!figures}
> ...
> \edef\LP{texmfstart --ifchanged=\lily!filename.tmp --exec
> bin:lilypond -b eps -dno-gs-load-fonts -dinclude-eps-fonts \lily!
> filename.tmp}
> """
>
> I still don't understand a lot of TeX programming, so I've no clue.

\edef expands its argument at the time of the definition. So 
\lily!filename is always *-1.tmp. Try changing the \edefs to \def.

Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: differences of perl/ruby texexec
  2007-05-04 19:15     ` Aditya Mahajan
@ 2007-05-04 19:50       ` Henning Hraban Ramm
  2007-05-04 20:42         ` Henning Hraban Ramm
  0 siblings, 1 reply; 8+ messages in thread
From: Henning Hraban Ramm @ 2007-05-04 19:50 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 2007-05-04 um 21:15 schrieb Aditya Mahajan:

>> """
>> \global\advance\lily!figures\plusone
>> \edef\lily!filename{\bufferprefix lilypond-\the\lily!figures}
>> ...
>> \edef\LP{texmfstart --ifchanged=\lily!filename.tmp --exec
>> bin:lilypond -b eps -dno-gs-load-fonts -dinclude-eps-fonts \lily!
>> filename.tmp}
>> """
>>
>> I still don't understand a lot of TeX programming, so I've no clue.
>
> \edef expands its argument at the time of the definition. So
> \lily!filename is always *-1.tmp. Try changing the \edefs to \def.

Arrgll! Yes, that helped. Thanks a lot!
I'll see soon if that solved everything and then upload the corrected  
version of the module.


Greetlings from Lake Constance!
Hraban
---
http://www.fiee.net/texnique/
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: differences of perl/ruby texexec
  2007-05-04 19:50       ` Henning Hraban Ramm
@ 2007-05-04 20:42         ` Henning Hraban Ramm
  2007-05-04 21:03           ` Aditya Mahajan
  0 siblings, 1 reply; 8+ messages in thread
From: Henning Hraban Ramm @ 2007-05-04 20:42 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 2007-05-04 um 21:50 schrieb Henning Hraban Ramm:
>
>>> """
>>> \global\advance\lily!figures\plusone
>>> \edef\lily!filename{\bufferprefix lilypond-\the\lily!figures}
>>> ...
>>> \edef\LP{texmfstart --ifchanged=\lily!filename.tmp --exec
>>> bin:lilypond -b eps -dno-gs-load-fonts -dinclude-eps-fonts \lily!
>>> filename.tmp}
>>> """
>>>
>>> I still don't understand a lot of TeX programming, so I've no clue.
>>
>> \edef expands its argument at the time of the definition. So
>> \lily!filename is always *-1.tmp. Try changing the \edefs to \def.

BTW: Why did that change between the two versions?

But anyway: It doesn't reckognize that the buffer has changed, if  
it's from a different component.

Example:
My songbook is a product. Every song is a component.
If I change the order of the components in the product, ConTeXt  
(texmfstart, texexec, whoever) doesn't reckognize that, so I get the  
scores in the old order, i.e. with the wrong title & lyrics!
Similar with my test product that only imports one component (for  
debugging the notes): If I change the component to import, I always  
get the last score that I checked.

And remember: It works with Perl texexec!

Greetlings from Lake Constance!
Hraban
---
http://www.fiee.net/texnique/
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: differences of perl/ruby texexec
  2007-05-04 20:42         ` Henning Hraban Ramm
@ 2007-05-04 21:03           ` Aditya Mahajan
  2007-05-04 22:11             ` Henning Hraban Ramm
  0 siblings, 1 reply; 8+ messages in thread
From: Aditya Mahajan @ 2007-05-04 21:03 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Fri, 4 May 2007, Henning Hraban Ramm wrote:

> Am 2007-05-04 um 21:50 schrieb Henning Hraban Ramm:
>>
>>>> """
>>>> \global\advance\lily!figures\plusone
>>>> \edef\lily!filename{\bufferprefix lilypond-\the\lily!figures}
>>>> ...
>>>> \edef\LP{texmfstart --ifchanged=\lily!filename.tmp --exec
>>>> bin:lilypond -b eps -dno-gs-load-fonts -dinclude-eps-fonts \lily!
>>>> filename.tmp}
>>>> """
>>>>
>>>> I still don't understand a lot of TeX programming, so I've no clue.
>>>
>>> \edef expands its argument at the time of the definition. So
>>> \lily!filename is always *-1.tmp. Try changing the \edefs to \def.
>
> BTW: Why did that change between the two versions?
>
> But anyway: It doesn't reckognize that the buffer has changed, if
> it's from a different component.
>
> Example:
> My songbook is a product. Every song is a component.
> If I change the order of the components in the product, ConTeXt
> (texmfstart, texexec, whoever) doesn't reckognize that, so I get the
> scores in the old order, i.e. with the wrong title & lyrics!
> Similar with my test product that only imports one component (for
> debugging the notes): If I change the component to import, I always
> get the last score that I checked.

It has been a while since I looked at the lilypond module. This is how 
I understand what is happening. The pdfs are not generated again in 
the second run. So, you get the old versions. Try deleting the 
lilypond pdfs, change the order of components, and you should get 
missing images.

> And remember: It works with Perl texexec!

Maybe --ifchanged in not honored at all and lilypond is run every 
time, irrespective of whether the snippet has changed or not.

BTW, how slow if lilypond, if you ask it just to create small music 
snippets and not do the page layout etc. If it runs reasonably fast, 
then there may be no need to do all this --ifchanged stuff. Just as 
metapost graphics are included.

Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: differences of perl/ruby texexec
  2007-05-04 21:03           ` Aditya Mahajan
@ 2007-05-04 22:11             ` Henning Hraban Ramm
  0 siblings, 0 replies; 8+ messages in thread
From: Henning Hraban Ramm @ 2007-05-04 22:11 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 2066 bytes --]

Am 2007-05-04 um 23:03 schrieb Aditya Mahajan:

>> Example:
>> My songbook is a product. Every song is a component.
>> If I change the order of the components in the product, ConTeXt
>> (texmfstart, texexec, whoever) doesn't reckognize that, so I get the
>> scores in the old order, i.e. with the wrong title & lyrics!
>> Similar with my test product that only imports one component (for
>> debugging the notes): If I change the component to import, I always
>> get the last score that I checked.
>
> It has been a while since I looked at the lilypond module. This is how
> I understand what is happening. The pdfs are not generated again in
> the second run. So, you get the old versions. Try deleting the
> lilypond pdfs, change the order of components, and you should get
> missing images.

True - I get missing images (placeholders).
If I delete all the temporary files (about 9 for every song!) I  
sometimes get nothing at all (only placeholders), while normally also  
the Ruby script does create something...

>> And remember: It works with Perl texexec!
>
> Maybe --ifchanged in not honored at all and lilypond is run every
> time, irrespective of whether the snippet has changed or not.

No, it works completely correct, as far as I can tell.
But I don't get references and TOC, so I need a final Ruby run.

> BTW, how slow if lilypond, if you ask it just to create small music
> snippets and not do the page layout etc. If it runs reasonably fast,
> then there may be no need to do all this --ifchanged stuff. Just as
> metapost graphics are included.

I use only small snippets - simple folksongs need seldom more than 3  
lines - but a lot of them...

LilyPond is fast enough, but the startup needs a while (typical for  
Python programs, but it also reads in fonts etc.), so it's really  
important to run only as needed.

I attached the recent version of t-lilypond, perhaps you can find an  
obvious error.

Greetlings from Lake Constance!
Hraban
---
http://www.fiee.net/texnique/
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)

[-- Attachment #2: t-lilypond.tex --]
[-- Type: application/octet-stream, Size: 10585 bytes --]

%D \module
%D	[		 file=t-lilypond,
%D		    version=2007.05.04,
%D		         title=\CONTEXT\ User Modules,
%D		   subtitle=Lilypond Connections (Music Typesetting),
%D		    author=Christopher Creutzig \& Henning Hraban Ramm,
%D	                 date=\currentdate,
%D	          copyright=Christopher Creutzig]

%M \usemodule[lilypond]

%D This module serves to include LilyPond music directly in the
%D \CONTEXT\ source, just as \METAPOST\ code can be.
%D It should work from LilyPond version 2.8 (checked with 2.10).
%D Before starting with the implementation, one or two examples are in order.
%D
%D \startbuffer[sample]
%D \startlilypond
%D % Telemann, TWV 40:11
%D 
%D \relative c' {
%D \set Staff.instrumentName = flute
%D \key fis \minor
%D \time 3/4
%D \partial 4
%D 
%D	 r8 fis'8 | fis4. cis8 a cis | fis, a cis fis a fis |
%D	 b, d fis b d b | eis,, gis cis eis gis b, |
%D	 a fis' gis, fis' cis eis | fis,4 r8
%D	 a' gis fis | e gis, a e' fis cis |
%D	 d fis, gis b e d | cis4 \trill r8
%D	 cis b a | b dis e gis cis, b |
%D	 a e' dis fis b, a | gis4 \trill r8
%D }
%D \stoplilypond
%D \stopbuffer
%D
%D The input
%D
%D \typebuffer[sample]
%D
%D is typeset as
%D
%D \getbuffer[sample]
%D
%D \type{\startlilypond} accepts options, as in\crlf
%D \type{\startlilypond[staffsize=24, linewidth=14cm, indent=5cm, time=no,clef=no]}:
%D 
%D \nobreak
%D \startlilypond[staffsize=24,linewidth=14cm,indent=5cm,time=no,clef=no]
%D \version "2.9.18"
%D \relative c' {
%D \set Staff.instrumentName = flute
%D \key fis \minor
%D \time 3/4
%D \partial 4
%D	 r8 fis'8 | fis4. cis8 a cis | fis, a cis fis a fis |
%D	 b, d fis b d b | eis,, gis cis eis gis b, |
%D	 a fis' gis, fis' cis eis | fis,4 r8
%D	 a' gis fis | e gis, a e' fis cis |
%D	 d fis, gis b e d | cis4 \trill r8
%D	 cis b a | b dis e gis cis, b |
%D	 a e' dis fis b, a | gis4 \trill r8
%D }
%D \stoplilypond
%D
%D It is also possible to mix text and music:
%D \lower 8.2pt\hbox{\lilypond[fragment=true,staffsize=16,time=no]{g'}} is a g.
%D
%D {\bf Complete list of options:}
%D
%D \starttabulate
%D	\NC	option\NC	default\NC	comment\NR\HL
%D	\NC	staffsize\NC	20\NC	 in pt	\NR
%D	\NC	indent\NC	0pt\NC	 first line indent	\NR
%D	\NC	time\NC	yes\NC	 count time? (i.e. show time signature, set bars, split line)	\NR
%D	\NC	clef\NC	yes\NC	 show clef?	\NR
%D	\NC	linewidth\NC	\\localhsize\NC		\NR
%D	\NC	betweensystemspace\NC	54pt\NC	space between systems	\NR
%D	\NC	height\NC	\\textheight\NC		\NR
%D	\NC	align\NC	?\NC	 default depends on fragment=...	\NR
%D	\NC	fragment\NC	no\NC		\NR
%D	\NC	barnumbers\NC	no\NC	 show numbers of measures?	\NR
%D	\NC	seriffont\NC	"Century Schoolbook L"\NC	 font for e.g. lyrics	\NR
%D	\NC	sansfont\NC	"LMSans10"\NC	 font for e.g. chords	\NR
%D	\NC	monofont\NC	"Courier" \NC	 normally not used	\NR
%D \stoptabulate
%D
%D TODO: The \type{\lower} in the example above should not be necessary.
%D
%D TODO: Proper support for multipage results.
%D
%D TODO: lilypond -> \CONTEXT.
%D
%D \page
%D Now for the implementation.	As usual, we use a prefix for buffers,
%D \type{\getparameters} etc.:

\unprotect
\def\??lily{lilypond-}

%D Define the text snippets to be placed around fragments.
%D Since lilypond uses similar syntax to \TeX, we must do some catcode fiddling.
\def\lily!slash{/}

\bgroup
\catcode`\/=\@@escape
/catcode`/\=/@@other
/catcode`/#=/@@other
/catcode`/<=/@@begingroup
/catcode`/>=/@@endgroup
/catcode`/{=/@@other
/catcode`/}=/@@other
/catcode`/%=/@@other
/catcode`/-=/@@letter
/gdef/lily!fragmentprefix<
/string^^J
/string^^J
{/string^^J
% ly snippet contents follows:/string^^J
>

/gdef/lily!fragmentsuffix</string^^J
% end ly snippet/string^^J
}/string^^J
>

/gdef/lily!prefix</string^^J
/string^^J
#(ly:set-option (quote no-point-and-click))/string^^J
/string^^J
\version "2.9.9"/string^^J
#(define version-seen? #t)/string^^J
\layout {/string^^J
/iflily!time/else
% switch off time signature (i.e. only one line, no bars)/string^^J
	ragged-last = ##t/string^^J
	\context {
		\Score
		timing = ##f
	}/string^^J
	\context {/string^^J
		\Staff/string^^J
		 \remove "Time_signature_engraver"/string^^J
	}/string^^J
/string^^J/fi
/iflily!barnumbers/else
% switch off bar numbers/string^^J
	\context {
		\Score
		\remove "Bar_number_engraver"
	}
/fi
/string^^J
/iflily!clef/else
% switch off clef sign/string^^J
	\context {
		\Staff
		\remove "Clef_engraver"
	}
/fi
/string^^J
	#(define fonts
		(make-pango-font-tree
		/lilypond-seriffont/space
		/lilypond-sansfont/space
		/lilypond-monofont/space
	(/lily!slash/space/lilypond-staffsize/space 20)))/string^^J
/string^^J
}/string^^J
\paper {/string^^J
	#(define dump-extents #t)/string^^J
	ragged-right = /iflily!align ##f/else ##t/fi/string^^J
	indent = /withoutpt/the/lily!indent\pt/string^^J
	line-width = /withoutpt/the/lily!linewidth\pt/string^^J
	vsize = /withoutpt/the/lily!vsize\pt/string^^J
	printpagenumber = ##f/string^^J
	oddFooterMarkup=##f/string^^J
	oddHeaderMarkup=##f/string^^J
	bookTitleMarkup = ##f/string^^J
	scoreTitleMarkup = ##f/string^^J
	ragged-bottom=##t/string^^J
	ragged-last-bottom=##t/string^^J
	between-system-padding = #0/string^^J
	between-system-space = /withoutpt/the/lily!betweensystemspace\pt/string^^J
}/string^^J
>

/gdef/lily!hash<#>
/egroup

\newdimen\lily!linewidth
\newdimen\lily!vsize
\newdimen\lily!indent
\newdimen\lily!betweensystemspace
\newif\iflily!align
\newif\iflily!clef
\newif\iflily!time
\newif\iflily!barnumbers

\newcount\lily!figures

%D Again, as usual, there is a \type{\setuplilypond} command
%D that accepts the same parameters as \type{\lilypond} and
%D \type{\startlilypond} do in their optional argument.

\def\setuplilypond{%
  \start\catcode`\#=\@@other%
  \dosingleempty\dosetuplilypond%
}

\def\dosetuplilypond[#1]{%
  \stop% restore \catcode`\#
  \getparameters[\??lily][#1]%
}

%D We set the following defaults:
\setuplilypond
	[staffsize=20,
	indent=0pt,
	betweensystemspace=54pt,
	time=\v!yes,
	clef=\v!yes,
	align=?,% default depends on fragment=...
	fragment=\v!no,
	barnumbers=\v!no,
	seriffont="Century Schoolbook L", % LilyPond default font
	sansfont="LMSans10",
	monofont="Bitstream Vera Sans Mono",
	]

%D If you want to know which fonts of your system LilyPond can see
%D with which names, try \type{lilypond -dshow-available-fonts any}.
%D (The 3rd parameter is necessary, but can be anything.)
%D There are a lot of restrictions, e.g. no fonts from the TeX tree (don't know why),
%D only one face per font file etc.

%D \type{\startlilypond} is a multistage implementation, because
%D end-of-line characters must be treated specially in the
%D \type{\startlilypond}\textellipsis\type{\stoplilypond} range.
\def\startlilypond{%
	\dosingleempty\dostartlilypond%
}

\def\dostartlilypond[#1]{%
 	\bgroup%
	\obeylines%
	\catcode`\#=\@@other%
	\dodostartlilypond[{#1}]%
}

\long\def\dodostartlilypond[#1]#2\stoplilypond{%
	\egroup% from \dostartlilypond
	\bgroup%
%D The default of the \type{linewidth} parameter is the local \type{\hsize}.
	\setlocalhsize
	\getparameters[\??lily][linewidth=\the\localhsize,height=\the\textheight,#1]%
	\lily!linewidth\dimexpr\getvalue{\??lily linewidth}\relax
	\lily!vsize\dimexpr\getvalue{\??lily height}\relax
	\lily!indent\dimexpr\getvalue{\??lily indent}\relax
	\lily!betweensystemspace\dimexpr\getvalue{\??lily betweensystemspace}\relax
%D The default of \type{align} depends on whether we typeset a fragment:
	\@EAEAEA\doifelse\getvalue{\??lily align}{\v!yes}%
		\lily!aligntrue\lily!alignfalse
	\@EAEAEA\doif\getvalue{\??lily fragment}{\v!no}{%
		\@EAEAEA\doif\getvalue{\??lily align}?
			\lily!aligntrue
	}%
	\@EAEAEA\doifelse\getvalue{\??lily time}\v!yes
		\lily!timetrue\lily!timefalse
	\@EAEAEA\doifelse\getvalue{\??lily barnumbers}\v!yes
		\lily!barnumberstrue\lily!barnumbersfalse
	\@EAEAEA\doifelse\getvalue{\??lily clef}\v!yes
		\lily!cleftrue\lily!cleffalse
%D We are using a counter to keep the different lilypond pieces
%D separate.	This allows to typeset them only once, during the
%D first run.
%D
%D TODO: This won't work any longer once we pass the remaining
%D vertical space to lilypond.
	\global\advance\lily!figures\plusone
	\def\lily!filename{\bufferprefix lilypond-\the\lily!figures}
	%\startmode[*\v!first]% 
	\def\obeyedlines{\string^^J}%
	\convertargument#2\to\ascii
	\expanded{%
	\setbuffer[lilypond-\the\lily!figures]%
	\lily!prefix
	\lily!hash(set-global-staff-size \getvalue{\??lily staffsize})\string^^J%
	\ifundefined{\??lily fragment}\else\lily!fragmentprefix\fi
	%% TODO: Option "packed"
	\ascii%
	\ifundefined{\??lily fragment}\else\lily!fragmentsuffix\fi
	}% expanded
	\endbuffer%
%D Generating a pdf directly always creates a whole page, so we generate eps first.
%D
%D If \type{\ifeof18} creates an error for you, your pdfetex is too old.
%D just change it to \iftrue then.	 (\type{\ifeof18} checks whether \type{\write18}
%D is disabled.)
	
	%\def\LP{echo LILYPOND \lily!filename.tmp}
	%\def\PDF{echo PStoPDF \lily!filename.eps}
	\def\LP{texmfstart --ifchanged=\lily!filename.tmp --exec bin:lilypond -b eps -dno-gs-load-fonts -dinclude-eps-fonts \lily!filename.tmp}
	\def\PDF{texmfstart --ifchanged=\lily!filename.eps pstopdf \lily!filename.eps}
	\ifeof18
		\installprogram{\LP}%
		\doif\jobsuffix{pdf}{%
			\installprogram{\PDF}%
		}%
	\else
		\executesystemcommand{\LP}%
		\doif\jobsuffix{pdf}{%
			\executesystemcommand{\PDF}%
		}%
	\fi
	%\stopmode% only first run
	\doifelse\jobsuffix{pdf}
		{\def\lily!img{\lily!filename.pdf}}%
		{\def\lily!img{\lily!filename.eps}}%
%D
%D TODO: Get the relevant dimension directly from lilypond,
%D to place the instrument name into the left margin for
%D short snippets as well.
%D If we are not in the middle of some text, we have to check
%D whether lilypond created an image that is wider than requested:
%D It places the instrument names in the left margin.
%D
	\ifvmode
		\getfiguredimensions[\lily!filename.pdf]%
		\leavevmode%
		\newdimen\FigWidth
		\FigWidth=\figurewidth
		\ifdim\FigWidth>\localhsize
			\!!dimena=\localhsize
			\advance\!!dimena by-\FigWidth
			\noindent\hskip\!!dimena
		\fi
	\fi
	\externalfigure[\lily!img]%
	\egroup%
}%

%D For short snippets, we define an inline alternative to
%D our start/stop pair:
\def\lilypond{\dosingleempty\dolilypond}

\def\dolilypond[#1]#2{\startlilypond[#1]#2\stoplilypond}

\protect
%D End of file

%%% snippet clipboard %%%

% no longer needed:
%%#(set! toplevel-score-handler print-score-with-defaults)/string^^J
%%#(set! toplevel-music-handler 
%	(lambda (p m) 
%	(if (not (eq? (ly:music-property m 'void) #t)) 
%			(print-score-with-defaults 
%			p (scorify-music m p)))))/string^^J

[-- Attachment #3: Type: text/plain, Size: 1 bytes --]



[-- Attachment #4: Type: text/plain, Size: 487 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-05-04 22:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-04 14:54 differences of perl/ruby texexec Henning Hraban Ramm
2007-05-04 18:17 ` Aditya Mahajan
2007-05-04 18:58   ` Henning Hraban Ramm
2007-05-04 19:15     ` Aditya Mahajan
2007-05-04 19:50       ` Henning Hraban Ramm
2007-05-04 20:42         ` Henning Hraban Ramm
2007-05-04 21:03           ` Aditya Mahajan
2007-05-04 22:11             ` Henning Hraban Ramm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).