From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/71295 Path: news.gmane.org!not-for-mail From: Aditya Mahajan Newsgroups: gmane.comp.tex.context Subject: Setting style and color attributes of label in metapost Date: Sat, 24 Sep 2011 20:43:53 -0400 (EDT) Message-ID: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1316911462 28648 80.91.229.12 (25 Sep 2011 00:44:22 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 25 Sep 2011 00:44:22 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sun Sep 25 02:44:18 2011 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1R7cpN-0003XN-Rw for gctc-ntg-context-518@m.gmane.org; Sun, 25 Sep 2011 02:44:17 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id D6FC3CAFC1; Sun, 25 Sep 2011 02:44:16 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id rC8xvxjgyHkg; Sun, 25 Sep 2011 02:44:14 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id D4FEBCAFB7; Sun, 25 Sep 2011 02:44:13 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 73B91CAFB7 for ; Sun, 25 Sep 2011 02:44:11 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Cod+5JBruOMn for ; Sun, 25 Sep 2011 02:43:59 +0200 (CEST) Original-Received: from filter2-nij.mf.surf.net (filter2-nij.mf.surf.net [195.169.124.153]) by balder.ntg.nl (Postfix) with ESMTP id D4523CAF37 for ; Sun, 25 Sep 2011 02:43:59 +0200 (CEST) Original-Received: from tombraider.mr.itd.umich.edu (smtp.mail.umich.edu [141.211.12.86]) by filter2-nij.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p8P0huVl024827 for ; Sun, 25 Sep 2011 02:43:58 +0200 Original-Received: FROM adi-netbook (bas3-montreal02-1096682717.dsl.bell.ca [65.94.12.221]) By tombraider.mr.itd.umich.edu ID 4E7E794B.26AB1.27108 ; Authuser adityam; 24 Sep 2011 20:43:55 EDT User-Agent: Alpine 2.02 (LNX 1266 2009-07-14) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=141.211.12.86; country=US; region=MI; city=Ann Arbor; postalcode=48109; latitude=42.2923; longitude=-83.7145; metrocode=505; areacode=734; http://maps.google.com/maps?q=42.2923,-83.7145&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0aFAMHV8d - 5b47625e1435 - 20110925 X-Scanned-By: CanIt (www . roaringpenguin . com) on 195.169.124.153 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:71295 Archived-At: I am writing a module which uses metapost in the background for drawing. I wanted to create an interface for setting the style and color of metapost labels but using \doset...attributes is not working. Here is an example: \definenamespace [test] [style=yes, name=test, command=yes, setup=yes] \definetest [blue] [color=blue, text=Blue] \definetest [two] [blue] [style=\bold, text=Two] \starttext \edef\currenttest{two} \startMPdrawing label.lft(\sometxt{\dosettestattributes{style}{color} \testparameter{text}}, (0,0)) ; \stopMPdrawing \edef\currenttest{blue} \startMPdrawing label.lft(\sometxt{\dosettestattributes{color}{style} \testparameter{text}}, (2cm,0)) ; \stopMPdrawing \MPdrawingdonetrue\getMPdrawing \stoptext Notice that the first label has the same style as the last label. This is happening because \doset..attributes is defined as an unexpandable macro. I can get around this by setting the value of \currenttest inside the \sometxt{...} argument. Something like: \def\dosometxt#1#2% {\normaldosometxt{#1}% {\def\noexpand\letterbackslash currenttest{\currenttest #2}}} Surely, there should be a more direct way of achieving this? Aditya ___________________________________________________________________________________ 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 ___________________________________________________________________________________