2021-11-06 09:03:50 +01:00
|
|
|
-- Compatibility layer for \meaning
|
|
|
|
-- This reverts a change rearding the \meaning of user macros:
|
|
|
|
-- LuaMetaTeX does not prefix prefixes in the meaning with a backslash.
|
|
|
|
|
|
|
|
-- Necessary especially for etoolbox's patching commands
|
|
|
|
|
2021-11-06 13:23:29 +01:00
|
|
|
local lmlt = luametalatex
|
2021-11-06 09:03:50 +01:00
|
|
|
local primitive_meaning = {
|
2021-11-06 13:23:29 +01:00
|
|
|
lmlt.primitive_tokens.expandafter,
|
|
|
|
lmlt.primitive_tokens.relax,
|
|
|
|
lmlt.primitive_tokens.meaning,
|
2021-11-06 09:03:50 +01:00
|
|
|
}
|
2021-11-06 13:23:29 +01:00
|
|
|
lmlt.luacmd("meaning", function()
|
2021-11-06 11:38:39 +01:00
|
|
|
local peeked = token.peeknext()
|
2021-11-06 09:03:50 +01:00
|
|
|
token.put_next(primitive_meaning)
|
2021-11-06 11:38:39 +01:00
|
|
|
token.skipnextexpanded()
|
2021-11-06 09:03:50 +01:00
|
|
|
if peeked.parameters == 0 then
|
2021-11-07 12:14:56 +01:00
|
|
|
local stash = ''
|
|
|
|
if peeked.protected then
|
|
|
|
if token.scankeywordcs'protected' then
|
|
|
|
token.skipnext()
|
|
|
|
token.skipnext()
|
|
|
|
stash = stash .. '\\protected '
|
|
|
|
print'protected'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
token.scankeyword'macro:'
|
|
|
|
tex.sprint(-2, stash)
|
|
|
|
tex.sprint(-2, 'macro:->')
|
2021-11-06 09:03:50 +01:00
|
|
|
end
|
|
|
|
end, "force", "global")
|