summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/listofitems
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-10-23 22:04:26 +0000
committerKarl Berry <karl@freefriends.org>2016-10-23 22:04:26 +0000
commit13f9bddf8ef85b40cf1a764004263014132512e8 (patch)
tree01f94aa4cab6a02a9dafa0029cdf0f4aa051c609 /Master/texmf-dist/tex/generic/listofitems
parent2f255cfc7d1d821ec94ff7a0c1de5f78f381d01c (diff)
listofitems (23oct16)
git-svn-id: svn://tug.org/texlive/trunk@42335 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/listofitems')
-rw-r--r--Master/texmf-dist/tex/generic/listofitems/listofitems.tex68
1 files changed, 42 insertions, 26 deletions
diff --git a/Master/texmf-dist/tex/generic/listofitems/listofitems.tex b/Master/texmf-dist/tex/generic/listofitems/listofitems.tex
index c0c5d1eaa5b..558556286eb 100644
--- a/Master/texmf-dist/tex/generic/listofitems/listofitems.tex
+++ b/Master/texmf-dist/tex/generic/listofitems/listofitems.tex
@@ -3,9 +3,9 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
\def\loiname {listofitems} %
-\def\loiver {1.1} %
+\def\loiver {1.2} %
% %
-\def\loidate {2016/9/01} %
+\def\loidate {2016/10/22} %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
@@ -27,12 +27,10 @@
% Commentaires, suggestions et signalement de bugs bienvenus !
% Comments, bug reports and suggestions are welcome.
% --------------------------------------------------------------------
-% L'extension listofitems est compos\'ee des 11 fichiers suivants :
+% L'extension listofitems est compos\'ee des 7 fichiers suivants :
% - code : listofitems (.tex et .sty)
% - manuel en francais : listofitems-fr (.tex et .pdf)
% - manuel en anglais : listofitems-en (.tex et .pdf)
-% - test (tex) : listofitems-test-tex (.tex et .pdf)
-% - test (latex) : listofitems-test-latex (.tex et .pdf)
% - fichier lisezmoi : README
% --------------------------------------------------------------------
\expandafter\edef\csname loi_restorecatcode\endcsname{\catcode\number`\_=\number\catcode`\_\relax}
@@ -52,8 +50,10 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begingroup
\edef\__tempa{\meaning\eTeXversion}\edef\__tempb{\string\eTeXversion}%
-\ifx\__tempa\__tempb\endgroup
-\else\endgroup
+\ifx\__tempa\__tempb
+ \endgroup
+\else
+ \endgroup
\loi_error{You are not using an eTeX engine, listofitems cannot work.}%
\expandafter\loi_restorecatcode\expandafter\endinput
\fi
@@ -89,8 +89,10 @@
\loi_second% si espace en 1er, faux
{\loi_exparg\loi_ifempty{\loi_gobarg#1}% 1 seul token ?
{\begingroup \escapechar`\_
- \if\expandafter\loi_firsttonil\string#1\_nil\expandafter\loi_firsttonil\string\relax\_nil\endgroup\expandafter\loi_first
- \else\endgroup\expandafter\loi_second
+ \if\expandafter\loi_firsttonil\string#1\_nil\expandafter\loi_firsttonil\string\relax\_nil
+ \endgroup\expandafter\loi_first
+ \else
+ \endgroup\expandafter\loi_second
\fi
}
\loi_second% si plusieurs tokens, faux
@@ -110,7 +112,7 @@
%--- macros retirant les espaces extr\^emes
% Voir codes 320 \`a 324 ici --> http://progtex.fr/wp-content/uploads/2014/09/code.txt
-% et pages 339 \`a 343 de "Appredre \`a programmer en TeX"
+% et pages 339 \`a 343 de "Apprendre \`a programmer en TeX"
\long\def\loi_ifspacefirst#1{\expandafter\loi_ifspacefirst_i\detokenize{#10} \_nil}
\long\def\loi_ifspacefirst_i#1 #2\_nil{\loi_ifempty{#1}}
\expandafter\def\expandafter\loi_gobspace\space{}
@@ -143,6 +145,7 @@
\def\nestdepth{1}%
\loi_argcsname\let{loi_previndex[\number\loi_nestcnt]}\empty
\def\loi_listname{loi_listofsep}%
+ \let\loi_def\def \let\loi_edef\edef \let\loi_let\let
\loi_ifempty{#2}
{\loi_error{Empty list of separators not allowed, "," used}%
\readlist_iv1{,}%
@@ -182,8 +185,14 @@
%%%%%%%%%%%%%%%%%%%%%% macro publique \readlist %%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcount\loi_nestcnt
-
+\def\greadlist{%
+ \let\loi_def\gdef \let\loi_edef\xdef \def\loi_let{\global\let}%
+ \loi_nestcnt1 % niveau initial = 1
+ \loi_argcsname\let{loi_previndex[\number\loi_nestcnt]}\empty
+ \loi_ifstar{\_removeextremespacestrue\readlist_i}{\_removeextremespacesfalse\readlist_i}%
+}
\def\readlist{%
+ \let\loi_def\def \let\loi_edef\edef \let\loi_let\let
\loi_nestcnt1 % niveau initial = 1
\loi_argcsname\let{loi_previndex[\number\loi_nestcnt]}\empty
\loi_ifstar{\_removeextremespacestrue\readlist_i}{\_removeextremespacesfalse\readlist_i}%
@@ -196,14 +205,14 @@
\loi_argcsname\def{\loi_listname[]}{#2}% la liste enti\`ere
\loi_argcsname\def{\loi_listname sep[]}{}% s\'eparateur vide
\loi_ifempty{#2}
- {\def#1[##1]{}%
- \loi_argcsname\def{\loi_listname len}{0}\loi_argcsname\def{\loi_listname len[0]}{0}%
+ {\loi_def#1[##1]{}%
+ \loi_argcsname\def{\loi_listname len}{0}\loi_argcsname\loi_def{\loi_listname len[0]}{0}%
\loi_error{Empty list ignored, nothing to do}%
}
- {\edef#1[##1]{\unexpanded{\romannumeral\expandafter\loi_auxmacrolistitem\romannumeral\loi_normalizeindex}{\loi_listname}{##1}{\csname\loi_listname nest\endcsname}{\loi_listname}}%
- \loi_argcsname\edef{\loi_listname sep}[##1]{\unexpanded{\romannumeral\expandafter\loi_auxmacrolistitem\romannumeral\loi_normalizeindex}{\loi_listname}{##1}{\csname\loi_listname nest\endcsname}{\loi_listname sep}}%
+ {\loi_edef#1[##1]{\unexpanded{\romannumeral\expandafter\loi_auxmacrolistitem\romannumeral\loi_normalizeindex}{\loi_listname}{##1}{\csname\loi_listname nest\endcsname}{\loi_listname}}%
+ \loi_argcsname\loi_edef{\loi_listname sep}[##1]{\unexpanded{\romannumeral\expandafter\loi_auxmacrolistitem\romannumeral\loi_normalizeindex}{\loi_listname}{##1}{\csname\loi_listname nest\endcsname}{\loi_listname sep}}%
\readlist_ii{#2}%
- \loi_argcsname\loi_argcsname\let{\loi_listname len}{\loi_listname len[0]}% longueur du niveau 0
+ \loi_argcsname\loi_argcsname\loi_let{\loi_listname len}{\loi_listname len[0]}% longueur du niveau 0
}%
}%
}
@@ -218,9 +227,9 @@
\long\def\readlist_iii#1||#2\_nil#3{\readlist_iv1{#3#1}}% #1=<sep courant simple> #3=liste -> rajoute un \'el\'ement vide pour le test ifempty ci dessous
\long\def\readlist_iv#1#2{% #1=compteur d'index #2=liste d'\'el\'ements \`a examiner
\loi_ifempty{#2}
- {\loi_argcsname\edef{\loi_listname len[\csname loi_previndex[\number\loi_nestcnt]\endcsname0]}{\number\numexpr#1-1\relax}%
+ {\loi_argcsname\loi_edef{\loi_listname len[\csname loi_previndex[\number\loi_nestcnt]\endcsname0]}{\number\numexpr#1-1\relax}%
\advance\loi_nestcnt-1
- \loi_argcsname\let\loi_currentsep{loi_listofsep[\number\loi_nestcnt]}%
+ \loi_argcsname\loi_let\loi_currentsep{loi_listofsep[\number\loi_nestcnt]}%
}
{\loi_expafternil\readlist_vi{#2}{}\_nil\loi_currentsep||\loi_quark||#2\_nil{#1}}% aller isoler le 1er item
}
@@ -250,8 +259,8 @@
\long\def\readlist_x#1#2#3#4{% #1=compteur d'index #2=liste restante #3=\'el\'ement courant #4=sep utilis\'e
\loi_ifnum{0\if_ignoreemptyitems1\fi\loi_ifempty{#3}1{}=11 }
{\readlist_iv{#1}{#2}}% si l'on n'ignore pas les \'el\'ements vides :
- {\loi_argcsname\def{\loi_listname[\csname loi_previndex[\number\loi_nestcnt]\endcsname#1]}{#3}% assignation de l'item ctuel \`a la macro
- \loi_argcsname\def{\loi_listname sep[\csname loi_previndex[\number\loi_nestcnt]\endcsname#1]}{#4}% assignation du <sep> actuel \`a la macro \<macrolist>sep
+ {\loi_argcsname\loi_def{\loi_listname[\csname loi_previndex[\number\loi_nestcnt]\endcsname#1]}{#3}% assignation de l'item ctuel \`a la macro
+ \loi_argcsname\loi_def{\loi_listname sep[\csname loi_previndex[\number\loi_nestcnt]\endcsname#1]}{#4}% assignation du <sep> actuel \`a la macro \<macrolist>sep
\loi_ifnum{\loi_nestcnt<\nestdepth\relax}% si imbrication max non atteinte
{\advance\loi_nestcnt1
\loi_argcsname\edef{loi_previndex[\number\loi_nestcnt]}{\csname loi_previndex[\number\numexpr\loi_nestcnt-1]\endcsname#1,}%
@@ -327,11 +336,15 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\itemtomacro#1[#2]{% #1[#2]=item non encore lu: #3=macro
\edef\loi_listname{\loi_macroname#1}%
- \loi_exparg{\expandafter\itemtomacro_i\romannumeral\expandafter\loi_normalizeindex\expandafter{\loi_listname}{#2}}{\csname\loi_listname nest\endcsname}%
+ \loi_exparg{\expandafter\itemtomacro_i\romannumeral\expandafter\loi_normalizeindex\expandafter{\loi_listname}{#2}}{\csname\loi_listname nest\endcsname}\let
}
-\def\itemtomacro_i#1#2#3{%
+\def\gitemtomacro#1[#2]{% #1[#2]=item
+ \xdef\loi_listname{\loi_macroname#1}%
+ \loi_exparg{\expandafter\itemtomacro_i\romannumeral\expandafter\loi_normalizeindex\expandafter{\loi_listname}{#2}}{\csname\loi_listname nest\endcsname}{\global\let}%
+}
+\def\itemtomacro_i#1#2#3#4{%
\loi_ifempty{#1}{}{\loi_error{#1}}%
- \loi_argcsname\let#3{\loi_listname[#2]}%
+ \loi_argcsname#3#4{\loi_listname[#2]}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -352,8 +365,11 @@
######################################################################
v1.0 19/8/2016
- - Premi\`ere version publique
+ - Premi\`ere version publique
v1.1 01/09/2016
- - Stockage des s\'eparateurs dans <macrolist>sep
- - bug corrig\'e dans \loi_restorecatcode \ No newline at end of file
+ - Stockage des s\'eparateurs dans <macrolist>sep
+ - bug corrig\'e dans \loi_restorecatcode
+
+v1.2 22/10/2016
+ - macros \greadlist et \gitemtomacro pour la globalit\'e \ No newline at end of file