[NTG-context] Checking existence of a macro (control sequence) by Lua
context at vivaldi.net
context at vivaldi.net
Thu May 28 00:42:58 CEST 2020
Hello,
is it possible to check whether a macro exists (or - is it a
non-\undefined control sequence) with Lua? Suppose:
----
\starttext
\def\MyMacro{Ahoj}
\def\MyMac#1#2{Something}
\startluacode
IsDefined = function(ctl_seq)
print("CS " .. ctl_seq ..
(tex.IsCS(ctl_seq) -- Or what to come
here?
"is defined" or "is
unknown") .. ".")
end
-- So the function should print to the console:
IsDefined("MyMacro") --> "CS MyMacro is defined."
IsDefined("MyMac") --> "CS MyMac is defined."
IsDefined("bf") --> "CS bf is defined."
IsDefined("dummy") --> "CS dummy is unknown."
\stopluacode
\stoptext
----
Is it possible?
Best regards,
Lukas
More information about the ntg-context
mailing list