luametalatex/luametalatex-meaning.lua

30 lines
855 B
Lua
Raw Normal View History

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
local primitive_meaning = {
token.primitive_tokens.expandafter,
token.primitive_tokens.relax,
token.primitive_tokens.meaning,
}
token.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
tex.sprint'->'
end
--[[
if peeked.frozen then
assert(token.scan_keyword'frozen' and token.scan_code(0x400))
tex.sprint(-2, '\\frozen ')
end
if peeked.protected then
assert(token.scan_keyword'protected' and token.scan_code(0x400))
tex.sprint(-2, '\\protected ')
end
]]
end, "force", "global")