I made some progress, although I'm sure there better and more elegant solution.
Example:
\version "2.19.52"
%Useful definitions
#(define characters.thinSpace (ly:wide-char->utf-8 #x2009))
#(define characters.longDash (ly:wide-char->utf-8 #x2013))
#(define characters.curvyEqual "≈")
%Properties of the customMark
#(define customMark.parenthesized #t)
#(define customMark.tempoEqText "= ca.")
#(define customMark.separator (string-append characters.thinSpace characters.longDash characters.thinSpace))
#(define (ly:duration-or-false? obj)
(if (or (ly:duration? obj) (and (boolean? obj) (not obj)))
#t
#f))
#(define (number-or-false? obj)
(if (or (number? obj) (and (boolean? obj) (not obj)))
#t
#f))
customMark =
#(define-music-function
(text tempo dur val1 val2)
(markup? boolean? ly:duration-or-false? number-or-false? number-or-false?)
#{
\mark \markup { \line { \upright { \fontsize #-2 {
\larger { \bold { #text } }
#(if tempo
#{
\markup \concat { %\markup needed to avoid "unknown escaped string: `\concat'"
#(if customMark.parenthesized "(")
#(if dur
#{
\markup \fontsize #-3 { \general-align #Y #DOWN { \note #(ly:duration->string dur) #1 } }
#}
"") %needed to avoid "not a markup" error when dur is #f
" "
#customMark.tempoEqText
#characters.thinSpace
#(if val1
(number->string val1)
"") %needed to avoid "not a markup" error when val1 is #f
#(if val2
(string-append customMark.separator (number->string val2))
"") %needed to avoid "not a markup" error when val2 is #f
#(if customMark.parenthesized ")")
}
#}
"") %needed to avoid "not a markup" error when tempo is #f
} } } }
#})
allegro = \customMark "Allegro." ##t 4 120 125
ceder = \customMark "ceder..." ##f ##f ##f ##f
metromark = \customMark "" ##t 4 120 ##f
\relative c' {
\allegro c4 d e \ceder f \metromark
}
Now, I can't figure out how to achieve that the last 4 parameters of the function default to ##f, to avoid errors if I don't pass them.
Again, thanks in advance!
Stéfano