From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/21114 Path: news.gmane.org!not-for-mail From: Taco Hoekwater Newsgroups: gmane.comp.tex.context Subject: Re: How to "\processcommalist"? Date: Fri, 01 Jul 2005 19:54:02 +0200 Message-ID: <42C5833A.3050204@elvenkind.com> References: <6faad9f005070109152f691f61@mail.gmail.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1120241620 22805 80.91.229.2 (1 Jul 2005 18:13:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 1 Jul 2005 18:13:40 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Fri Jul 01 20:13:36 2005 Return-path: Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by ciao.gmane.org with esmtp (Exim 4.43) id 1DoQ0P-0002Kw-OT for gctc-ntg-context-518@m.gmane.org; Fri, 01 Jul 2005 20:12:49 +0200 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 2C9EE127D5; Fri, 1 Jul 2005 20:20:30 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 26927-01; Fri, 1 Jul 2005 20:20:29 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost.localdomain [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 2EEB7127A3; Fri, 1 Jul 2005 19:56:39 +0200 (CEST) Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 23DDE127A3 for ; Fri, 1 Jul 2005 19:56:38 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 26329-08-4 for ; Fri, 1 Jul 2005 19:56:37 +0200 (CEST) Original-Received: from post-22.mail.nl.demon.net (post-22.mail.nl.demon.net [194.159.73.192]) by ronja.ntg.nl (Postfix) with ESMTP id 380B31279F for ; Fri, 1 Jul 2005 19:56:37 +0200 (CEST) Original-Received: from boo.demon.nl ([82.161.175.147]:35328 helo=[192.168.1.3]) by post-22.mail.nl.demon.net with esmtp (Exim 4.43) id 1DoPki-00045u-TF; Fri, 01 Jul 2005 17:56:37 +0000 User-Agent: Mozilla Thunderbird 1.0 (X11/20050215) X-Accept-Language: en-us, en Original-To: Mojca Miklavec , mailing list for ConTeXt users In-Reply-To: <6faad9f005070109152f691f61@mail.gmail.com> X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.5 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 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on smtp.ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:21114 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:21114 Mojca Miklavec wrote: > I would like to define a command, which would be called in the following way: > \TheBossWantsTheWorkToBeDoneOn[monday,wednesday,thursday]{tidy up} > > so that it would be equivalent to: > \WeHaveToDo[monday]{tidy up} > \WeHaveToDo[wednesday]{tidy up} > \WeHaveToDo[thursday]{tidy up} > > I played a bit with different variants of \processcommalist, but I > can't figure out how to use it in this particular case. The trick is to store the tidy up inside the processing command, like so: \def\WeHaveToDo[#1]#2{\message{(#1: #2)}} \def\TheBossWantsTheWorkToBeDoneOn[#1]#2% {\begingroup \def\processitem##1{\WeHaveToDo[##1]{#2}}% \processcommalist[#1]\processitem \endgroup } \TheBossWantsTheWorkToBeDoneOn[monday,wednesday,thursday]{tidy up} > Is there also a possibility to define a command like > \IHaveToDoTheTasks[1-4,7,9-11]{until tomorrow} There was not, but knowing Hans I trust that soon there will be :-). For now, here is my solution. % a few auxiliary core macros are needed to uncompress the list. % % \uncompresslist is the twin of the already existing \compresslist % which works in the other direction (syst-new) % \unprotect % I guess this function is already available but couldnt find it... % \def\apptomac#1#2% {\ifx#1\empty\def#1{#2}\else \@EA\def\@EA#1\@EA{#1,#2}\fi} % the next macro does this: % % \itemwithdash<<9-11>>- => \dorecurse {<<1+11-9>>} % {\apptomac\uncompressedlist<<9-1+\recurselevel>>} % % (the 1+ and -1 are needed to solve a counter offset.) \def\itemwithdash#1-#2-% {\@EA\dorecurse\@EA {\the\numexpr 1+#2-#1\relax}% {\@EA\apptomac\@EA\uncompressedlist\@EA {\the\numexpr #1-1+\recurselevel\relax}}}% % top level. The result will be in \uncompressedlist \def\uncompresslist[#1]% {\def\uncompressedlist{}% \def\processitem##1% {\doifinstringelse{-}{##1} {\itemwithdash##1-} {\apptomac\uncompressedlist{##1}}}% \processcommalist[#1]\processitem } \protect % end support macros. With these, you can do: \def\IHaveToDoTheTask[#1]#2{\message{(#1: #2)}} \def\IHaveToDoTheTasks[#1]#2% {\begingroup \def\processitem##1{\IHaveToDoTheTask[##1]{#2}}% \uncompresslist[#1]% <= Yeah! \processcommacommand[\uncompressedlist]\processitem \endgroup } I hope you understand what I've done, but otherwise, feel free to ask, of course. Greetings, Taco