\input plainpkg \ProvidesPackage{domore}[2015/09/17 v0.32 dowith extended (UL)] %% Copyright (C) 2012 2013 2015 Uwe Lueck, %% http://www.contact-ednotes.sty.de.vu %% -- author-maintained in the sense of LPPL below -- %% %% This file can be redistributed and/or modified under %% the terms of the LaTeX Project Public License; either %% version 1.3c of the License, or any later version. %% The latest version of this license is in %% http://www.latex-project.org/lppl.txt %% We did our best to help you, but there is NO WARRANTY. %% %% Please report bugs, problems, and suggestions via %% %% http://www.contact-ednotes.sty.de.vu %% \PushCatMakeLetterAt %% 2015/09/17 %% == With \LaTeX, extend 'dowith''s \cs{setdo} == %% %% mod. 2012/11/06: %% The original 'dowith' offers |\setdo{}| %% for defining a one-parameter macro `\do' expanding to . %% The present package allows applying a -parameter macro %% (maybe `\do', being 2, 3, or ...) %% to a list of "brace groups" where each brace group %% contains arguments. If \LaTeX\ is present ... \ifltx %% ... the following extension %% \[|\setdo[]{}]|\] %% of the basic 'dowith' version %% can be used to define a -parameter macro `\do'. %% You also can equip `\do' with an initial optional argument by %% \[|\setdo[][]{}]|\] %% The next two moves allow loading the package %% independently of 'dowith' (overriding its definition of `\setdo') %% as well as using the package %% with a format that has not defined `\do' before. %% The first parameter of `\do' may even be \emph{optional.} \let\setdo\relax \let\do\empty \newcommand*{\setdo}[1][1]{\renewcommand\do[#1]} \fi %% %% == Auxiliaries == %% |\@firstsecondoftwo{}{}| \ %% is a variant of \LaTeX's `\@firstofone{}' for %% \emph{two} arguments. It just removes outer braces %% from each of the two arguments (provided it has outer braces), %% resulting in \[\] \long\def\@firstsecondoftwo#1#2{#1#2} %% % |\@secondfirstoftwo| results in %% % where is ... %% % [TODO declare "meta-function removing braces"---in 'dowith' documentation] %% % (, must not contain `\par' tokens so far---TODO): %% |\@secondfirstoftwo{}{}| %% \emph{additionally} interchanges the two arguments %% (after removing braces): \long\def\@secondfirstoftwo#1#2{#2#1} %% Our main application is using it as an extended `\expandafter' %% before `\fi': %% \[`\@secondfirstoftwo{}\fi'\] %% will expand to %% \[`\fi'\] %% This won't work with `\else' in place of `\fi'. %% %% == Enhanced \cs{DoWith} == %% Here comes a more powerful variant of 'dowith''s `\DoWith'. %% Instead of iterating a single "command" %% on an arglist by %% \[`\DoWith{}\StopDoing'\] %% (cf. `dowith.pdf'), the present `\DoWith' can have a %% more complex first argument. If consists %% of some brace groups the first of which is {} %% so that is %% \[`{}'\] %% --- being the remaining arglist--- %% \[|\DoWith{}\StopDoing|\] %% works like %% \[`{}\DoWith{}\StopDoing'\] %% and so on---a recursive explanation. Or if is %% \[`{}{}'\dots`{}'\] %% ($n$ items), the result is like %% \[`{}{}'\dots`{}'\] %% The actual definition is: \def\DoWith#1#2{% \ifx\StopDoing#2\empty %% not \@empty for Plain 2012/11/05 \else\@secondfirstoftwo{#1{#2}\DoWith{#1}}\fi} %% In order to \strong{use} the remaining definitions from \strong{'dowith' %% together with the present package}, %% \strong 2012/11/06 %% load `dowith.sty' before `domore.sty'. %% %% (v0.32:) |\StopDoing| must be provided in case 'dowith' %% is not loaded at all. Being "undefined" is very %% bad when `\DoWithMore' is used for a list of \emph{assignments.} %% As in 'dowith', we assume that no argument starts with something %% that has the same meaning as `\DoWith' itself: \let\StopDoing\DoWith %% %% == Applications of \cs{DoWith} == %% `\DoWith' still is somewhat auxiliary. What I have used in practice, %% are the following definitions. %% %% |\DoWithMore{}\StopDoing| %% was \DoMore 2015/05/22 %% with as above %% "unpacks" each arglist item so that may be a macro %% with more than one argument---say, arguments. %% Then or , as well as $\dots$ , %% should provide an arglist consisting of items. \def\DoWithMore#1{\DoWith{\@firstsecondoftwo{#1}}} %% Now I use metavariable instead of . %% We consider some "separator" material to be inserted %% between instances of applying to an item of . %% We want to get %% \[`{}{}'\dots`{}'\] %% This is achieved simply by starting with %% \[`{}'\] %% and then proceeding as with %% \[`\DoWith{}\StopDoing'\] %% And that's what |\DoSeparateWith{}{}\StopDoing| does: \def\DoSeparateWith#1#2#3{#1{#3}\DoWith{#2#1}} %% |\DoSeparateWithMore{}{}\StopDoing| combines %% the two previous things, inserting separator material %% and unpacking the nested arg\-lists: \def\DoSeparateWithMore#1#2{% %% wieder 2012/06/05 \DoSeparateWith{\@firstsecondoftwo{#1}}{#2}} %% My main application is that is a link macro with arguments %% and and that is \qtdcode{~\string|~} %% (or some tie variant) to get a horizontal list of links like %% \[\def|{$\vert$}\mbox{ | | \dots | }\] %% %% == Without \cs{StopDoing} == %% 2013/03/20, mv. 2013/03/22 %% The following enhancements of 'dowith' are provided by %% 2013/03/22 %% v0.31. %% %% |\DoWithAllOf{}{}| works like %% \[`\DoWith{}\StopDoing'\] %% as in 'dowith', but now with a more general first argument: \def\DoWithAllOf#1#2{\DoWith{#1}#2\StopDoing} %% |\DoWithAllIn{}{}| works as in 'dowith' too %% and needs the enhancement too: %% 2013/03/21 \def\DoWithAllIn#1#2{% \expandafter \@secondfirstoftwo \expandafter {#2}{\DoWith{#1}}% \StopDoing} %% %% == Leaving and History == \PopLetterCatAt \endinput VERSION HISTORY v0.1 2012/01/17 developed in `texblog.fdf' (using \[re]newcommand*) v0.2 2012/08/07 own file `domore.sty', \def's only 2012/08/08 dealing with "more" \setdo v0.3 2012/11/05 using `plainpkg'; removing old % code (see stored v0.2); auxiliaries \long 2012/11/06 doc.: more on \setdo (, opt. arg.), usage with `dowith' \strong 2012/11/18 doc.: adjusted for `catchdq'; reworking for \DoWith; \DoWithMore, \DoSeparateWith 2012/11/19 doc.: \DoSeparateWithMore v0.31 2013/03/20 \DoWithAllOf 2013/03/21 \DoWithAllIn 2013/03/22 moving down new section, mod. doc. v0.32 2015/05/22 doc. fix \DoWithMore; providing \StopDoing 2015/09/17 \PushCatMakeLetterAt!