lilypond-user
[Top][All Lists]

## Re: How to include a file/definition temporarily?

 From: Carl Sorensen Subject: Re: How to include a file/definition temporarily? Date: Sun, 19 Sep 2010 16:52:46 -0600

On 9/19/10 3:46 PM, "Patrick Schmidt" <address@hidden> wrote:

> Hi all,
>
> I have several files with definitions of guitar fret diagrams for
> various chord shapes (e.g. c-shape.ly, a-shape.ly, g-shape.ly, e-
> shape.ly and d-shape.ly). I can't include all of these files at the
> same time in the main file as quite a few chord alternatives start on
> the same pitch. How can I use those definitions only temporarily? I
> tried this:
>
> cShape = { \include "c-shape.ly" }
> aShape = { \include "a-shape.ly"  }
>
> music = \chordmode {
>    \cShape
>    c1
>    \aShape
>    c1
> }
>
> Unfortunately this way the a-shape definitions overrule the c-shape
> definitions. If anybody knows a solution please let me know.

This is probably not possible right now.  With some modifications to the
code, it could be fixed.

Right now, predefined fretboards are all saved in one table with the fixed
name of fretboard-table.  This is seen in ly/predefined-fretboards-init.ly.

It should be possible to adjust the code so that we save predefined
fretboards in a table whose name has been selected in a .ly file.
Once we do that, then we could do something like

#(define a-fretboard-table (make-hash-table 100))

\set predefinedDiagramTable = #a-fretboard-table

\storePredefinedDiagram .....

#(define c-fretboard-table (make-hash-table 100))

\set predefinedDiagramTable = #c-fretboard-table

\storePredefinedDiagram .....

Then, in order to use the a-fretboard-table, we just do

\set predefinedDiagramTable = #a-fretboard-table

and to use the c-fretboard-table, we do

\set predefinedDiagramTable = #c-fretboard-table

I don't have time to make the changes to allow this right now; it might be
next weekend before I can get to it.  I'm not sure exactly the scheme syntax
that will be required, but I'm confident I can get it to work.

If you want to work on it in the meantime, I'd be happy to have you do so
and give you any guidance I can.

Thanks,

Carl