[NTG-context] filter module: call function before calling the filter command?

Aditya Mahajan adityam at umich.edu
Fri Oct 14 00:41:02 CEST 2016


On Wed, 12 Oct 2016, Henning Hraban Ramm wrote:

> Now, I’d like to overwrite "texsettings.ly", containing the setting of 
> ConTeXt’s text width, each time before I call LilyPond, to adapt its 
> note line width to the current text width. That would automate the line 
> width adaption to e.g. columns.
>
> In the module’s documentation under "Dealing with expansion" I found the example of creating the filter command in a macro.
> Can I use this to call a Lua function first and then LilyPond? Or is there a better way?

There is an internal option: filtersetups that may be useful for what you 
have in mind.

You can create a lua function, say lilypond.initialize(...), that does all 
the initializations, and then write

\startsetups lilypond:initialize
   \ctxlua{lilypond.initialize()}
\stopsetups

\defineexternalfilter[...]
   [ ...
    filtersetups=lilypond:initialize,
    ...
   ]

This is untested, but it should work.

Aditya


More information about the ntg-context mailing list