lilypond-user
[Top][All Lists]
Advanced

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

Re: coding question about include-d tweak/function files


From: Urs Liska
Subject: Re: coding question about include-d tweak/function files
Date: Tue, 30 Jan 2018 17:22:07 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2



Am 30.01.2018 um 17:02 schrieb Urs Liska:
...

If this is a regular case I would look for a way to include them only once. Including them multiple times definitely doesn't make sense as the file will be completely parsed again and all the definitions just overwritten.

The approach I would use (doesn't necessarily mean it's the best one) is:
  • replace the \include with a new function
  • have that function add the included filels absolute path to some list
  • check that list before including the file

This is totally improvised, but with oll-core loaded you could do something along the lines of

% provide a storage space
\registerOption kieren.included-files #'()

% in a loading function ('to-include' is the file to check:
#(if (not (getOptionWithFallback `(kieren included-files ,to-include) #f))
     (begin
      (do-include-file to-include)
      (setChildOption '(kieren included-files) to-include #t))

just as a rough idea. Actually I don't know if the syntax of the functions is correct, but ...

Thinking about it, that would be a path to writing an \includeOnce or \require command in oll-core.
The downside with that idea is that coding tools (i.e. Frescobaldi) will be able to help much less than with regular includes: no auto-completion, neither for the include itself nor for variables defined in the included files. Also you can'T open the included file with ctrl-click.

One issue I'm not sure about is whether that include function would properly work with LilyPond's include path or if you'd be forced to use absolute paths or paths relative to the directory (i.e. not paths that are relative to any item from the search path).

What do you think, would that be a worthwile effort?

Urs

reply via email to

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