summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-08-01 20:37:02 +0000
committerKarl Berry <karl@freefriends.org>2021-08-01 20:37:02 +0000
commit9f6f0d1fd20f6010188013cbef1b8a9aa65576df (patch)
tree1a7379689544c8195450f9700f2746ee2e4bdce8 /Master/texmf-dist/source/latex
parent65317a9dc9ff76702305df532d23e0c514b79ed7 (diff)
macrolist (1aug21)
git-svn-id: svn://tug.org/texlive/trunk@60139 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex')
-rw-r--r--Master/texmf-dist/source/latex/macrolist/macrolist.dtx37
1 files changed, 28 insertions, 9 deletions
diff --git a/Master/texmf-dist/source/latex/macrolist/macrolist.dtx b/Master/texmf-dist/source/latex/macrolist/macrolist.dtx
index 5074875ff03..f11af32bfd8 100644
--- a/Master/texmf-dist/source/latex/macrolist/macrolist.dtx
+++ b/Master/texmf-dist/source/latex/macrolist/macrolist.dtx
@@ -16,7 +16,7 @@
%<*package>
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{macrolist}[2021/07/29 v2.0.0 Create lists of macros and perform operations on them]
+\ProvidesPackage{macrolist}[2021/07/31 v2.1.0 Create lists of macros and perform operations on them]
\RequirePackage{pgffor}
%</package>
@@ -123,7 +123,6 @@
% \fi
%
% \DescribeMacro{\macrolistcontains}
-%
% Writing |\macrolistcontains{listname}{element}{true branch}{false branch}| checks whether list \textsf{listname} contains \textsf{element}, executing \textsf{true branch} if it does and \textsf{false branch} if it does not.
%
% \iffalse
@@ -147,7 +146,6 @@
% \fi
%
% \DescribeMacro{\macrolistadd}
-%
% To add something to the list \textsf{listname}, pass in |\macrolistadd{listname}[position]{element}|, where \textsf{position} is an optional argument. If nothing is passed in for \textsf{position}, then by default \textsf{element} will be added to the end of the list.
%
% \iffalse
@@ -175,9 +173,35 @@
\fi
}
% \fi
+% \changes{v2.1.0}{2021/07/31}{Add macrolisteadd}
+% \DescribeMacro{\macrolisteadd}
+% To fully expand |element| before adding it to list |listname|, pass in |\macrolisteadd{listname}[position]{element}|. This behaves similarly to |\edef|.
%
+% \iffalse
+\newcommand{\macrolisteadd}[1]{
+ \macrolist@exists{#1}
+ \def\macrolist@currlist{#1}
+ \macrolist@listeadd
+}
+\newcommand{\macrolist@listeadd}[2][]{
+ \stepcounter{macrolist@list@\macrolist@currlist}
+
+ \if\relax\detokenize{#1}\relax
+ \expandafter\xdef\csname macrolist@list@\macrolist@currlist\macrolistsize{\macrolist@currlist}\endcsname{#2}
+ \else
+ \expandafter\ifnum\csname themacrolist@list@\macrolist@currlist\endcsname=#1
+ \expandafter\gdef\csname macrolist@list@\macrolist@currlist\macrolistsize{\macrolist@currlist}\endcsname{#2}
+ \else
+ \macrolist@inbounds{\macrolist@currlist}{#1}
+ \foreach \macrolist@index in {\macrolistsize{\macrolist@currlist}, ...,\the\numexpr #1+1\relax} {
+ \global\expandafter\let\csname macrolist@list@\macrolist@currlist\macrolist@index\expandafter\endcsname\csname macrolist@list@\macrolist@currlist\the\numexpr\macrolist@index-1\relax\endcsname
+ }
+ \expandafter\xdef\csname macrolist@list@\macrolist@currlist#1\endcsname{#2}
+ \fi
+ \fi
+}
+% \fi
% \DescribeMacro{\macrolistremove}
-%
% To remove an element in a list, write |\macrolistremove{listname}{index}|.
%
% \iffalse
@@ -197,7 +221,6 @@
% \fi
%
% \DescribeMacro{\macrolistremovelast}
-%
% To remove the last element in a list, write |\macrolistremovelast{listname}|. This behaves like C++'s |pop_back|.
%
% \iffalse
@@ -209,7 +232,6 @@
% \fi
%
% \DescribeMacro{\macrolistclear}
-%
% To clear a list, write |\macrolistclear{listname}|.
%
% \iffalse
@@ -225,7 +247,6 @@
% \fi
%
% \DescribeMacro{\macrolistsize}
-%
% To get the size of a list, write |\macrolistsize{listname}|.
%
% \iffalse
@@ -237,7 +258,6 @@
%
% \DescribeMacro{\macrolistforeach}
% \changes{v1.1.1}{2021/07/23}{Fix foreach doc by removing incorrect begin}
-%
% To write a for each loop, write
% \begin{verbatim}
%\macrolistforeach{listname}{\element}[begin][end]{action}
@@ -299,7 +319,6 @@
% \fi
%
% \DescribeMacro{\macrolistjoin}
-%
% Executing |\macrolistjoin{listname}{joiner}| returns all of the elements separated by \textsf{joiner}. This behaves like Javascript's \textsf{arr.join()}.
%
% \iffalse