lilypond-user
[Top][All Lists]
Advanced

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

Re: init.ly, what does it do?


From: David Wright
Subject: Re: init.ly, what does it do?
Date: Sun, 8 Jan 2017 21:29:57 -0600
User-agent: Mutt/1.5.21 (2010-09-15)

On Sun 08 Jan 2017 at 21:17:53 (-0500), Br. Samuel Springuel wrote:

> With this file saved to the same folder as my test score,
> `lilypond-dev --init="my_init.ly" test.ly` produces identical
> results to `lilypond-dev test.ly`.  I would, therefore, guess that
> while LilyPond has initialized enough for the code to make sense
> (i.e. not cause errors the way putting this stuff in an `-e`
> argument on the command-line does), my_init.ly is still getting
> executed too early because the settings in it are being overwritten
> by their default values.
> 
> So, unless there is a hook somewhere accessible to either `-e` or
> `--init` that I can use to get the code executed at the right time
> (i.e. after LilyPond is finished setting the default values but
> before she actually starts interpreting test.ly), or some way to
> protect the settings in `my_init.ly` so that LilyPond doesn't/can't
> change them later, I'm going to have to do something that requires
> editing the source file before it can be used.
> 
> Here's hoping someone can prove me wrong.

Well, Simon gave an example where you invoke LP on the
variable-contents file and include the fixed-contents file.
Just as easy is to invert this: invoke LP on the fixed-contents file
(your "source" file) but include a variable-contents file (your
"my_init.ly" file).

How to do this: just put
\include "my_init.ly"
at the start of your source file.

Editing my_init.ly and reinvoking LP on the (unchanged) source file
will produce a new version of the output using whatever is defined in
my_init.ly.

You wrote "With separate files, every time I play with the document
settings, I have to create a new file which has the appropriately
matched settings and redirect the document to the new file (assuming I
want to be able to go back to the original settings at some point)."

If you want to preserve previous settings that you've used in
"my_init.ly" in the past, you can create each my_init.ly in a
directory whose name is a timestamp like 2017-01-08-20-59-30.¹

Your invocation would use   --include="path/to/2017-01-08-20-59-30"
to make LP find and insert the appropriate version from that
directory. Your source would remain unchanged.

Just make sure that you don't put a file called my_init.ly in any
other directory from which you pick up \include files, ie your
repositories of LP/scheme code, so that it will only ever be found
in the timestamped directory.

You also wrote "When borrowing source from other people, however, the
appropriate Scheme variables won't be there." I don't know what you
mean by borrowing source. You'd have to explain how you incorporate
this borrowed code into your projects.

¹ or any other systematic naming of the directories.

Cheers,
David.



reply via email to

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