lilypond-user
[Top][All Lists]
Advanced

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

Re: Making markup functions parametric


From: Urs Liska
Subject: Re: Making markup functions parametric
Date: Sat, 04 Jul 2020 08:14:02 +0200
User-agent: Evolution 3.36.3-1

Am Samstag, den 04.07.2020, 05:28 +0200 schrieb Urs Liska:
> 
> Am 3. Juli 2020 23:33:42 MESZ schrieb Lukas-Fabian Moser <lfm@gmx.de>
> :
> > > #(define (get-scheme-markup-function func)
> > >    (string->symbol
> > >     (string-append "make-"
> > >                    (symbol->string func)
> > >                    "-markup")))
> > 
> > ... which should be replaced by
> > 
> > #(define (get-scheme-markup-function func)
> >    (symbol-append 'make- func '-markup))
> > 
> 
> That's fantastic, thank you very much.
> (You'll soon see that code again, I assume ;-) ).

Oops, unfortunately it's not enough ...

I have tried various things, but I don't seem to understand how that
primitive-eval actually works here. Your solution does only work when
the input is a simple markup (string), not when it is wrapped in other
markup commands. 
Consider this:

\version "2.20"

#(define (get-scheme-markup-function func)
   (symbol-append 'make- func '-markup))

#(define-markup-command (enclose layout props func content)(symbol?
markup?)
   (ly:message "content: ~a" content)
   (interpret-markup layout props
     (primitive-eval
      (list 'markup
        (list
         (get-scheme-markup-function func)
         content)))))

\markup \enclose #'box "C"
\markup \enclose #'circle \concat { "D" } 
\markup \enclose #'circle \italic "E"


While it works for the first case, both the \concat and the \italic
produce an error like
  Wrong type to apply: "D"

The content entering the markup command is printed as
  (#<procedure concat-markup (layout props args)> (D))
or
  (#<procedure italic-markup (layout props arg)> E)

What will go there in the \enclose is a concatted and potentially
formatted markup expression.

I got one step further accepting a second symbol, which made the
\italic work:

\version "2.20"

#(define (get-scheme-markup-function func)
   (symbol-append 'make- func '-markup))

#(define-markup-command (enclose layout props func func2
content)(symbol? symbol? markup?)
   (ly:message "content: ~a" content)
   (interpret-markup layout props
     (primitive-eval
      (list 'markup
        (list
         (get-scheme-markup-function func)
         (list (get-scheme-markup-function func2)
         content))))))

%\markup \enclose #'box "C"
%\markup \enclose #'circle #'concat \concat { "D" "e" }
\markup \enclose #'circle #'italic "E"


But with the \concat it still doesn't work.
Content prints
  (#<procedure concat-markup (layout props args))

So while being able to nest multiple markup commands I think I should
somehow unpack/serialize/whatever the \concat expression within the
markup command.

What I ultimately need is probably this:

\markup 
\circle    % passed as symbol
\italic    % passed as symbol
\concat { 
  "a"      % various calculated elements (this is a simplified example)
  \flat 
  ":" 
}

I would be thankful for any hints how to proceed here.

Best
Urs

> Best
> Urs
> 
> > Sorry, I had not realized that symbol-append is available in Guile
> > 1.8.
> > 
> > Lukas




reply via email to

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