lilypond-user
[Top][All Lists]
Advanced

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

Re: /etc shortcut


From: Jean Abou Samra
Subject: Re: /etc shortcut
Date: Sat, 30 Apr 2022 23:17:38 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1

Le 30/04/2022 à 22:44, Stephan Schöll a écrit :
Hi everybody

A few days ago Lukas-Fabian has pointed me to the existence of the /etc
shortcut. It seems to me that this would easy a lot of everday work
without any further Scheme skills (music-function-... ). Unfortunately
the /etc shortcut is not mentionned in the official docs. The only
information I could find is at
https://extending-lilypond.readthedocs.io/en/latest/music.html#the-etc-shortcut



I'm glad that this resource is showing usefulness. On the other
hand, \etc *is* mentioned in the official docs. Look in the function
index:

https://lilypond.org/doc/v2.23/Documentation/notation/lilypond-command-index

You will find two pages (briefly) explaining its use, one in music
functions and one in markup commands. (The one for markup commands was
added in the 2.23 documentation.)



I tried to create an mve for myself but failed:

boxedMark = \mark \markup { \box \etc }

{

  c1 d \boxedMark "Part II" e f

}

My current (but appearently failing) mental model is that /etc is a kind
of function parameter - here called with value "Part II". (I know how
procedural and oo languages work.) boxedMark is my function, and with
the \etc parameter I am able to pass my value o the functions body.



Well, \etc is not as general as this. For one thing, it works
as a trailing argument. You can have

shortcut = \function a b \etc

but not

shortcut = \function \etc a b

Basically, you should think of \etc as "cutting short" the application
of the function and leaving the remaining arguments to be given
"another time". (Hence its name.)

Also, even if you spell it as \mark \markup \box \etc (without braces),
it still does not work, because \etc cannot mix music and markup contexts.
\mark is a music function. It won't like receiving a partial markup
command.

Thus, in this case, you should revert to a plain old music function
instead:

boxedMark =
#(define-music-function (arg) (markup?)
   #{ \mark \markup \box #arg #})


Note how, by using #{ #} syntax, you can write such functions
without any knowledge of Scheme apart from the names of the
type predicates. The manual calls this "substitution functions",
explained at

https://lilypond.org/doc/v2.23/Documentation/notation/substitution-function-syntax

Type predicates are listed at
https://lilypond.org/doc/v2.23/Documentation/notation/predefined-type-predicates

Best regards,
Jean




reply via email to

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