[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scheme function and top-level markup
From: |
Jean Abou Samra |
Subject: |
Re: Scheme function and top-level markup |
Date: |
Fri, 27 May 2022 12:34:06 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 |
Le 27/05/2022 à 12:21, Simon Albrecht a écrit :
Hello everyone,
I’m a bit surprised that the following doesn’t work and don’t know
where to look for a solution.
%%%%%%%%%%%%%%%%%%%%%%%%% \version "2.23.9" pieceTitle =
#(define-scheme-function (str) (markup?) #{ \markup \huge $str
\noPageBreak #}) \pieceTitle "I. Kyrie" { c'1 }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Here are the error messages:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Parsing...
/tmp/frescobaldi-0fy0zxi0/tmpkd3e8qov/document.ly:7:6: error: markup
outside of text script or \lyricmode \markup \huge $str
/tmp/frescobaldi-0fy0zxi0/tmpkd3e8qov/document.ly:11:1: error: error
in #{ ... #} \pieceTitle "I. Kyrie"
/tmp/frescobaldi-0fy0zxi0/tmpkd3e8qov/document.ly:11:1: error: bad
expression type \pieceTitle "I. Kyrie" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
What can I do?
Best, Simon
#{ #} is not as close to allowing to write "macros" as it
looks like. When you do
#{
thing 1
thing 2
thing 3
#}
this combines the things into a sequential music expression,
as if it were
#{
{
thing 1
thing 2
thing 3
}
#}
So you can't put several elements of which one is a markup,
just like you can't do
{
\markup x
c'1
}
The solution is not to combine these but to return them separately.
Sadly, this is not currently possible with syntax functions:
https://gitlab.com/lilypond/lilypond/-/issues/6333
The solution for now is to use a plain Scheme function:
\version "2.23.9"
pieceTitle =
#(lambda (str)
(values #{ \markup \huge $str #}
#{ \noPageBreak #}))
$(pieceTitle "I. Kyrie")
{ c'1 }
Best,
Jean