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


Reply via email to