| 1 |
\input plainpkg |
| 2 |
% \NeedsTeXFormat{LaTeX2e}[1994/12/01] |
| 3 |
\ProvidesPackage{commado}[2012/11/30 v0.11 iterate on CSL (UL)] |
| 4 |
%% |
| 5 |
%% Copyright (C) 2012 Uwe Lueck, |
| 6 |
%% http://www.contact-ednotes.sty.de.vu |
| 7 |
%% -- author-maintained in the sense of LPPL below -- |
| 8 |
%% |
| 9 |
%% This file can be redistributed and/or modified under |
| 10 |
%% the terms of the LaTeX Project Public License; either |
| 11 |
%% version 1.3c of the License, or any later version. |
| 12 |
%% The latest version of this license is in |
| 13 |
%% http://www.latex-project.org/lppl.txt |
| 14 |
%% We did our best to help you, but there is NO WARRANTY. |
| 15 |
%% |
| 16 |
%% Please report bugs, problems, and suggestions via |
| 17 |
%% |
| 18 |
%% http://www.contact-ednotes.sty.de.vu |
| 19 |
%% |
| 20 |
\PushCatMakeLetterAt |
| 21 |
%% == Auxiliaries == |
| 22 |
\ifltx \else %% unless provided by LaTeX already |
| 23 |
\long\def\@firstoftwo#1#2{#1} |
| 24 |
\long\def\@secondoftwo#1#2{#1} |
| 25 |
\fi |
| 26 |
%% ... 4 less than |
| 27 |
% \long\def\@firstsecondofthree#1#2#3{#1#2} |
| 28 |
% \long\def\@firstthirdofthree#1#2#3{#1#3} |
| 29 |
%% |
| 30 |
%% == Processing a Comma-Separated List == |
| 31 |
%% Most of the following code aims at removing the final |
| 32 |
%% space in the comma-separated list. |
| 33 |
%% % `\<cmd>' usually may either refer to a string starting |
| 34 |
%% % with a backslash or to the \emph{token} with the name |
| 35 |
%% % \qtdcode{<cmd>} |
| 36 |
%% % (cf. "\TeX's Tokens" in the \ctanpkgref{dowith} documentation). |
| 37 |
%% A variant of parsing as in 'fifinddo.sty' |
| 38 |
%% (\ctanpkgdref{nicetext} bundle) and |
| 39 |
%% \ctanpkgstyref{bitelist}\urlfoot{CtanPkgRef}{bitelist} |
| 40 |
%% package is employed %% ^ 2012/11/30 |
| 41 |
%% (while I am about to use different approaches there, |
| 42 |
%% one may see here how, inspired by `\@ifblank' in |
| 43 |
%% \ctanpkgstyref{url}).\urlfoot{CtanPkgRef}{url} |
| 44 |
%% The purpose of the following `\edef' of |
| 45 |
%% |\DoWithCSL{<cmd>}{<list>}| |
| 46 |
%% is to get a space token after `\@firstoftwo' in the parameter text. |
| 47 |
%% \pagebreak[3] |
| 48 |
\let\CD@final@comma\relax |
| 49 |
\edef\DoWithCSL#1#2{% |
| 50 |
\CD@final@comma#2\CD@final@comma %% 2nd \ 2012/11/30 |
| 51 |
\noexpand\@firstoftwo |
| 52 |
% \noexpand\@firstsecondofthree |
| 53 |
\space\CD@final@comma |
| 54 |
\noexpand\@secondoftwo |
| 55 |
% \noexpand\@firstthirdofthree |
| 56 |
\noexpand\end{#1}{#2}} |
| 57 |
\def\CD@final@comma#1 \CD@final@comma#2#3\end#4#5{% |
| 58 |
% \expandafter\@secondfirstoftwo\expandafter{% |
| 59 |
% #2{#1}#5}{\do@with@csl#4}% |
| 60 |
#2{\do@with@csl{#4}#1}{\do@with@csl{#4}#5}% |
| 61 |
%% ... 15 vs.\ 13: |
| 62 |
% #2{\do@with@csl{#4}}{#1}{#5}% |
| 63 |
,\StopDoing,} |
| 64 |
\catcode`\Q=3 %% not in #1 |
| 65 |
\def\do@with@csl#1#2#3,{% |
| 66 |
%% #1 is <cmd>. #2 takes the first token from (remaining) <list> |
| 67 |
%% that is not a space token. Trying to enter a blank |
| 68 |
%% list item would result in using the |
| 69 |
%% \emph{next comma as a list item!}---The following |
| 70 |
%% is an alternative to the analogue in 'domore.sty': |
| 71 |
\unless@stop@doing#2#3\StopDoing |
| 72 |
#1{#2#3}\do@with@csl{#1}\StopDoing Q} |
| 73 |
\def\unless@stop@doing#1\StopDoing#2\StopDoing#3Q{#2} |
| 74 |
%% ... somewhat replaces `\@secondfirstoftwo'---but will the |
| 75 |
%% latter be dropped? `\unless@stop@doing' is specific |
| 76 |
%% for `\StopDoing'---but can be used with `\DoWith' too. |
| 77 |
%% TODO %% 2012/11/24 |
| 78 |
\catcode`\Q=11 |
| 79 |
%% |
| 80 |
%% == Leaving the Package File == |
| 81 |
\PopLetterCatAt |
| 82 |
\endinput |
| 83 |
%% |
| 84 |
%% == \acro{VERSION HISTORY} == |
| 85 |
|
| 86 |
v0.1 2012/11/24f. started |
| 87 |
2012/11/26 code ready |
| 88 |
2012/11/27 documented |
| 89 |
v0.11 2012/11/30 code typo corrected, removing final space, |
| 90 |
doc. \urlfoot's |