2017-01-09 4:29 GMT+01:00 David Wright <lily...@lionunicorn.co.uk>: > 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.
Samuel, I'd likely go for --include as David recommended. Nevertheless, you could store the following lines at top of the ly-file #(use-modules (guile-user)) #(if (not (defined? 'my-settings)) (define my-settings '())) #(for-each (lambda (settings) (ly:output-def-set-variable! $defaultpaper (car settings) (cdr settings))) my-settings) Then you can call lilypond with $ lilypond -e='(define my-settings (list (cons (quote indent) 10)(cons (quote short-indent) 10)(cons (quote line-width) 80)))' file.ly On windows use double quotes. Ofcourse you now can use different key-value-pairs in my-settings. Or even no settings: $ lilypond file.ly will still work. Please note (1) In terminal spell-out list, cons, quote don't use '-signs (2) A warning is printed: WARNING: #f: imported module (guile-user) overrides core binding `%module-public-interface' No clue about its severity. Cheers, Harm _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user