lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about Scheme's syntax


From: Paolo Prete
Subject: Re: Question about Scheme's syntax
Date: Thu, 5 Sep 2024 13:37:18 +0200

I see but the problem remains. I would like to found a way to pass a more structured object to that function, not only a string:

%%%%%%%%%%%%%%%%%%
\version "2.24.1"

floating-markup = #(define-scheme-function (parser location x y obj) (number? number? scheme?)
                                  #{
                                    \markup \with-dimensions #'(0 . 0) #'(0 . 0){
                                      \override #'(baseline-skip . 0)
                                      \translate #(cons x y)
                                      #obj
                                    }
                                  #})


% GOOD
\floating-markup 15 -60 "some string"

% ERROR
\floating-markup 15 -60 #{ \markup { \circle 1 } #}

On Wed, Sep 4, 2024 at 9:56 PM David Kastrup <dak@gnu.org> wrote:
Paolo Prete <paolopr976@gmail.com> writes:

> Hello,
>
> Given:
>
> floating-markup = #(define-scheme-function (parser location x y obj)
> (number? number? scheme?)
>                                   #{
>                                     \markup \with-dimensions #'(0 . 0) #'(0
> . 0){
>                                       \override #'(baseline-skip . 0)
>                                       \translate #(cons x y)
>                                       #obj
>                                     }
>                                   #})

That makes no sense at all.  Obviously #obj cannot be anything but a
markup here but you declare it as scheme? which just asks for obscure
runtime errors.  Then there is no point in not using a markup command
here in the first place.

>
> I can invoke it with:
>
> \floating-markup 15 -60 "some string"
>
> But how can I pass to the same function the following _expression_: { \circle
> 5 } as #obj?

{ \circle 5 } is not a LilyPond _expression_.  It is a fragment of markup.
You can turn it into a LilyPond _expression_ by writing

\markup { \circle 5 }

in which case you'll get out an actual markup.  Outside of markup,
\circle is not defined.

> Something like (pseudo-syntax) :
>
> \floating-markup 15 -60 #{ \circle 5 #}

#{ ... #} is a Scheme construct, not a LilyPond _expression_.  It is used
for using LilyPond syntax inside of a Scheme _expression_.

If you want to use it (in Scheme!) for writing in markup syntax, again
you need to enter markup mode by writing

#{ \markup ... #}

in a Scheme _expression_.  If you are in LilyPond entry mode, you can just
write \markup ... instead.

--
David Kastrup

reply via email to

[Prev in Thread] Current Thread [Next in Thread]