ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Wolfgang Schuster <schuster.wolfgang@googlemail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: How to properly handle synonyms in \getparameters?
Date: Sat, 3 Sep 2011 04:45:27 +0200	[thread overview]
Message-ID: <485745FA-6D25-4821-8944-9B7A36410D78@googlemail.com> (raw)
In-Reply-To: <CALBOmsYxPg4YEWn8GrMMQLmcSO_nUaHmu6irvVeMT8BosT1eyw@mail.gmail.com>


Am 03.09.2011 um 02:46 schrieb Mojca Miklavec:

> Dear gurus,
> 
> This question concerns both MKII and MKIV (I need the functionality in
> both, even though I will try to rewrite the MKIV part as soon as I
> have time).
> 
> I have a command:
>    \mycommand[a][newparam=value]
> with more or less the following definition:
>    \def\mycommand[#1][#2]{%
>        \getparameters[@@mycommand@#1@][#2]
>        % ... some extra code ...
>    }
> 
> However I used to use
>    \mycommand[a][oldparam=value]
> and now I would like to switch the syntax to
>    \mycommand[a][newparam=value]
> but I would like the oldparam to keep working normally.
> 
> I will read the value with \@@mycommand@a@newparam.
> 
> My question: what is the most elegant value to do that?
> 
> I can imagine something like
>    \def\mycommand[#1][#2]{%
>        \undefinecommand\@@mycommand@a@oldparam % pseudocode
>        \getparameters[@@mycommand@#1@][#2]
>        \doifdefined{\@@mycommand@a@oldparam}
>            \let\@@mycommand@a@newparam\@@mycommand@a@oldparam
>        % ... some extra code ...
>    }
> 
> but there is most probably some more elegant solution to that?


MkIV:

\definenamespace
  [mojca]
  [type=module,
   name=mojca,
   command=yes,
   setup=yes,
   parent=mojca]

\starttext

\setupmojca
  [oldkey=OLD,
   newkey=\mojcaparameter{oldkey}]

\starttabulate
\NC Old \EQ \mojcaparameter{oldkey} \NC\NR
\NC New \EQ \mojcaparameter{newkey} \NC\NR
\stoptabulate

\setupmojca
  [newkey=NEW]

\starttabulate
\NC Old \EQ \mojcaparameter{oldkey} \NC\NR
\NC New \EQ \mojcaparameter{newkey} \NC\NR
\stoptabulate

\stoptext

Wolfgang
___________________________________________________________________________________
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
___________________________________________________________________________________


      reply	other threads:[~2011-09-03  2:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-03  0:46 Mojca Miklavec
2011-09-03  2:45 ` Wolfgang Schuster [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=485745FA-6D25-4821-8944-9B7A36410D78@googlemail.com \
    --to=schuster.wolfgang@googlemail.com \
    --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).