sile-typesetter / sile

The SILE Typesetter — Simon’s Improved Layout Engine
https://sile-typesetter.org
MIT License
1.62k stars 97 forks source link

Add function scope nesting #1938

Open alerque opened 7 months ago

alerque commented 7 months ago
local old = SILE.Commands.x
SILE.registerCommand("x", ...)
process(...)
SILE.Commands.x = old

This pattern is something we use a lot internally and that gets used a lot externally. It is neither ergonomic nor any other good words.

We provide a SILE.settings:temporarily() to wrap settings and then reset to where we started. We can and should provide a similar wrapper for commands.

Then the only question would be whether to use this by default for anything loaded/defined during document processing or not. That might take some experimentation.

alerque commented 7 months ago

This would go along nicely with #1521.