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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to