[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lilypond-user
Subject:    Re: /etc shortcut
From:       Jean Abou Samra <jean () abou-samra ! fr>
Date:       2022-04-30 21:17:38
Message-ID: 76efcef7-bc25-639b-2d6a-a834bf240ae3 () abou-samra ! fr
[Download RAW message or body]

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic