ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Meer, Hans van der" <H.vanderMeer@uva.nl>
To: NTG ConTeXt <ntg-context@ntg.nl>
Subject: Re: Last version standalone ConTeXt issue.
Date: Mon, 10 Oct 2016 09:48:37 +0000	[thread overview]
Message-ID: <6AB79355-48A5-4922-8A6B-90E97FBCF511@uva.nl> (raw)
In-Reply-To: <56BA3508.2060703@wxs.nl>


[-- Attachment #1.1: Type: text/plain, Size: 1642 bytes --]

This is an interesting feature for handling a call to an undefined macro (as might result from \csnam#1\endcsname, for example.

>
> \starttext
>
> \startluacode
>
> function interfaces.defined(name)
>    return token.get_cmdname(token.create(name)) ~= "undefined_cs"
> end
>
> if interfaces.defined("foo") then
>    context("foo")
> else
>    interfaces.setmacro("foo","bar")
> end
>
> \stopluacode
>
> \foo
>
> \stoptext
>
> I'll add interfaces.defined to the core.
>
> -----------------------------------------------------------------
>                                          Hans Hagen | PRAGMA ADE
>              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>      tel: 038 477 53 69 | www.pragma-ade.com<http://www.pragma-ade.com> | www.pragma-pod.nl<http://www.pragma-pod.nl>
> -----------------------------------------------------------------

As an example I executed the following code:

\starttext
\framed{\ConTeXt-version = \contextversion}\blank

\def\nofoo{This is nofoo}
\startluacode
if interfaces.defined("foo") then
   context("foo")
else
   interfaces.setmacro("foo","nofoo")
end
\stopluacode
\tex{foo} is undefined: "\foo"\crlf
\def\foo{This is foo}
\tex{foo} is defined: "\foo"\crlf
\stoptext

The result of the first call to \foo, however, is not "This is nofoo" but the name of the nofoo macro. I expected that \nofoo would have been executed instead. That would have been beneficial, because the missing macro \foo can then be substituted for something the programmer thinks useful.
Is this correct? Or am I doing something wrong?

Hans van der Meer




[-- Attachment #1.2: Type: text/html, Size: 2843 bytes --]

[-- Attachment #2: tester.pdf --]
[-- Type: application/pdf, Size: 8793 bytes --]

[-- Attachment #3: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

      parent reply	other threads:[~2016-10-10  9:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-09 12:28 Jaroslav Hajtmar
2016-02-09 18:50 ` Hans Hagen
2016-02-09 19:37   ` Jaroslav Hajtmar
2016-10-10  9:48   ` Meer, Hans van der [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6AB79355-48A5-4922-8A6B-90E97FBCF511@uva.nl \
    --to=h.vandermeer@uva.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).