ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Checking existence of a macro (control sequence) by Lua
@ 2020-05-27 22:42 context
  2020-05-27 22:49 ` luigi scarso
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: context @ 2020-05-27 22:42 UTC (permalink / raw)
  To: ConTeXt

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-05-29 21:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 22:42 Checking existence of a macro (control sequence) by Lua context
2020-05-27 22:49 ` luigi scarso
2020-05-28  7:56   ` Hans Hagen
2020-05-28  6:50 ` Henri Menke
2020-05-28  8:34 ` Hans Hagen
2020-05-28 11:24   ` context
2020-05-28 21:24   ` context
2020-05-29  7:36     ` Hans Hagen
2020-05-29 21:21       ` context

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).