summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3seq.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3seq.dtx102
1 files changed, 75 insertions, 27 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx b/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx
index 046f42b8c5e..7b6cc0c857d 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3seq.dtx
@@ -43,7 +43,7 @@
% }^^A
% }
%
-% \date{Released 2021-02-18}
+% \date{Released 2021-05-07}
%
% \maketitle
%
@@ -144,6 +144,29 @@
% (assuming \TeX{}'s normal category code r\'egime).
% If the \meta{delimiter} is empty, the \meta{token list} is split
% into \meta{items} as a \meta{token list}.
+% See also \cs{seq_set_split_keep_spaces:Nnn}, which omits space stripping.
+% \end{function}
+%
+% \begin{function}[added = 2021-03-24]
+% {
+% \seq_set_split_keep_spaces:Nnn , \seq_set_split_keep_spaces:NnV ,
+% \seq_gset_split_keep_spaces:Nnn, \seq_gset_split_keep_spaces:NnV
+% }
+% \begin{syntax}
+% \cs{seq_set_split_keep_spaces:Nnn} \meta{sequence} \Arg{delimiter} \Arg{token list}
+% \end{syntax}
+% Splits the \meta{token list} into \meta{items} separated
+% by \meta{delimiter}, and assigns the result to the \meta{sequence}.
+% One set of outer braces is removed (if any) but any surrounding spaces
+% are retained: any braces \emph{inside} one or more spaces are
+% therefore kept. Empty \meta{items} are preserved by
+% \cs{seq_set_split_keep_spaces:Nnn}, and can be removed afterwards using
+% \cs{seq_remove_all:Nn} \meta{sequence} |{}|.
+% The \meta{delimiter} may not contain |{|, |}| or |#|
+% (assuming \TeX{}'s normal category code r\'egime).
+% If the \meta{delimiter} is empty, the \meta{token list} is split
+% into \meta{items} as a \meta{token list}.
+% See also \cs{seq_set_split:Nnn}, which removes spaces around the delimiters.
% \end{function}
%
% \begin{function}
@@ -512,7 +535,7 @@
% Tests if the \meta{item} is present in the \meta{sequence}.
% \end{function}
%
-% \section{Mapping to sequences}
+% \section{Mapping over sequences}
%
% All mappings are done at the current group level, \emph{i.e.}~any
% local assignments made by the \meta{function} or \meta{code} discussed
@@ -965,14 +988,14 @@
%
% \section{Viewing sequences}
%
-% \begin{function}[updated = 2015-08-01]{\seq_show:N, \seq_show:c}
+% \begin{function}[updated = 2021-04-29]{\seq_show:N, \seq_show:c}
% \begin{syntax}
% \cs{seq_show:N} \meta{sequence}
% \end{syntax}
% Displays the entries in the \meta{sequence} in the terminal.
% \end{function}
%
-% \begin{function}[added = 2014-08-12, updated = 2015-08-01]{\seq_log:N, \seq_log:c}
+% \begin{function}[added = 2014-08-12, updated = 2021-04-29]{\seq_log:N, \seq_log:c}
% \begin{syntax}
% \cs{seq_log:N} \meta{sequence}
% \end{syntax}
@@ -1054,7 +1077,7 @@
% \begin{macrocode}
\cs_new:Npn \@@_item:n
{
- \__kernel_msg_expandable_error:nn { kernel } { misused-sequence }
+ \__kernel_msg_expandable_error:nn { seq } { misused }
\use_none:n
}
% \end{macrocode}
@@ -1210,10 +1233,15 @@
% \seq_set_split:Nnn , \seq_set_split:NnV ,
% \seq_gset_split:Nnn, \seq_gset_split:NnV
% }
+% \begin{macro}
+% {
+% \seq_set_split_keep_spaces:Nnn , \seq_set_split_keep_spaces:NnV ,
+% \seq_gset_split_keep_spaces:Nnn, \seq_gset_split_keep_spaces:NnV
+% }
% \begin{macro}{\@@_set_split:NNnn}
% \begin{macro}
% {
-% \@@_set_split_auxi:w, \@@_set_split_auxii:w,
+% \@@_set_split:Nw, \@@_set_split:w,
% \@@_set_split_end:
% }
% When the separator is empty, everything is very simple, just map
@@ -1238,46 +1266,53 @@
% braces which are outermost after space trimming.
% \begin{macrocode}
\cs_new_protected:Npn \seq_set_split:Nnn
- { \@@_set_split:NNnn \__kernel_tl_set:Nx }
+ { \@@_set_split:NNNnn \__kernel_tl_set:Nx \tl_trim_spaces:n }
\cs_new_protected:Npn \seq_gset_split:Nnn
- { \@@_set_split:NNnn \__kernel_tl_gset:Nx }
-\cs_new_protected:Npn \@@_set_split:NNnn #1#2#3#4
+ { \@@_set_split:NNNnn \__kernel_tl_gset:Nx \tl_trim_spaces:n }
+\cs_new_protected:Npn \seq_set_split_keep_spaces:Nnn
+ { \@@_set_split:NNNnn \__kernel_tl_set:Nx \exp_not:n }
+\cs_new_protected:Npn \seq_gset_split_keep_spaces:Nnn
+ { \@@_set_split:NNNnn \__kernel_tl_gset:Nx \exp_not:n }
+\cs_new_protected:Npn \@@_set_split:NNNnn #1#2#3#4#5
{
- \tl_if_empty:nTF {#3}
+ \tl_if_empty:nTF {#4}
{
\tl_set:Nn \l_@@_internal_a_tl
- { \tl_map_function:nN {#4} \@@_wrap_item:n }
+ { \tl_map_function:nN {#5} \@@_wrap_item:n }
}
{
\tl_set:Nn \l_@@_internal_a_tl
{
- \@@_set_split_auxi:w \prg_do_nothing:
- #4
+ \@@_set_split:Nw #2 \prg_do_nothing:
+ #5
\@@_set_split_end:
}
- \tl_replace_all:Nnn \l_@@_internal_a_tl { #3 }
+ \tl_replace_all:Nnn \l_@@_internal_a_tl {#4}
{
\@@_set_split_end:
- \@@_set_split_auxi:w \prg_do_nothing:
+ \@@_set_split:Nw #2 \prg_do_nothing:
}
\__kernel_tl_set:Nx \l_@@_internal_a_tl { \l_@@_internal_a_tl }
}
- #1 #2 { \s_@@ \l_@@_internal_a_tl }
+ #1 #3 { \s_@@ \l_@@_internal_a_tl }
}
-\cs_new:Npn \@@_set_split_auxi:w #1 \@@_set_split_end:
+\cs_new:Npn \@@_set_split:Nw #1#2 \@@_set_split_end:
{
- \exp_not:N \@@_set_split_auxii:w
- \exp_args:No \tl_trim_spaces:n {#1}
+ \exp_not:N \@@_set_split:w
+ \exp_args:No #1 {#2}
\exp_not:N \@@_set_split_end:
}
-\cs_new:Npn \@@_set_split_auxii:w #1 \@@_set_split_end:
+\cs_new:Npn \@@_set_split:w #1 \@@_set_split_end:
{ \@@_wrap_item:n {#1} }
\cs_generate_variant:Nn \seq_set_split:Nnn { NnV }
\cs_generate_variant:Nn \seq_gset_split:Nnn { NnV }
+\cs_generate_variant:Nn \seq_set_split_keep_spaces:Nnn { NnV }
+\cs_generate_variant:Nn \seq_gset_split_keep_spaces:Nnn { NnV }
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% \begin{macro}{\seq_concat:NNN, \seq_concat:ccc}
% \UnitTested
@@ -1582,7 +1617,7 @@
{
\int_compare:nNnTF { \seq_count:N #2 } > \c_max_register_int
{
- \__kernel_msg_error:nnx { kernel } { shuffle-too-large }
+ \__kernel_msg_error:nnx { seq } { shuffle-too-large }
{ \token_to_str:N #2 }
}
{
@@ -1924,7 +1959,7 @@
% \end{macrocode}
% \end{macro}
%
-% \subsection{Mapping to sequences}
+% \subsection{Mapping over sequences}
%
% \begin{macro}{\seq_map_break:}
% \UnitTested
@@ -2324,25 +2359,38 @@
% \subsection{Viewing sequences}
%
% \begin{macro}{\seq_show:N, \seq_show:c, \seq_log:N, \seq_log:c, \@@_show:NN}
+% \begin{macro}[rEXP]{\@@_show_validate:nn}
% \UnitTested
-% Apply the general \cs{msg_show:nnnnnn}.
+% Apply the general \cs{__kernel_chk_tl_type:NnnT}.
% \begin{macrocode}
-\cs_new_protected:Npn \seq_show:N { \@@_show:NN \msg_show:nnxxxx }
+\cs_new_protected:Npn \seq_show:N { \@@_show:NN \__kernel_msg_show:nnxxxx }
\cs_generate_variant:Nn \seq_show:N { c }
-\cs_new_protected:Npn \seq_log:N { \@@_show:NN \msg_log:nnxxxx }
+\cs_new_protected:Npn \seq_log:N { \@@_show:NN \__kernel_msg_log:nnxxxx }
\cs_generate_variant:Nn \seq_log:N { c }
\cs_new_protected:Npn \@@_show:NN #1#2
{
- \__kernel_chk_defined:NT #2
+ \__kernel_chk_tl_type:NnnT #2 { seq }
{
- #1 { LaTeX/kernel } { show-seq }
+ \s_@@
+ \exp_after:wN \use_i:nn \exp_after:wN \@@_show_validate:nn #2
+ \q_recursion_tail \q_recursion_tail \q_recursion_stop
+ }
+ {
+ #1 { seq } { show }
{ \token_to_str:N #2 }
{ \seq_map_function:NN #2 \msg_show_item:n }
{ } { }
}
}
+\cs_new:Npn \@@_show_validate:nn #1#2
+ {
+ \quark_if_recursion_tail_stop:n {#2}
+ \@@_wrap_item:n {#2}
+ \@@_show_validate:nn
+ }
% \end{macrocode}
% \end{macro}
+% \end{macro}
%
% \subsection{Scratch sequences}
%