[latex3-commits] [git/LaTeX3-latex3-latex3] master: Add peek_spaces_remove (we could now deprecate ignore_spaces functions) (7ebea4a)

Bruno Le Floch bruno at le-floch.fr
Mon Oct 1 14:14:43 CEST 2018


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/7ebea4a25048f8ec1f0439de02c6113189787bb2

>---------------------------------------------------------------

commit 7ebea4a25048f8ec1f0439de02c6113189787bb2
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Mon Oct 1 14:12:31 2018 +0200

    Add peek_spaces_remove (we could now deprecate ignore_spaces functions)


>---------------------------------------------------------------

7ebea4a25048f8ec1f0439de02c6113189787bb2
 l3kernel/CHANGELOG.md                   |    1 +
 l3kernel/l3candidates.dtx               |   31 +++++++++++++++++++++++++++++++
 l3kernel/testfiles/m3expl001.luatex.tlg |    2 ++
 l3kernel/testfiles/m3expl001.ptex.tlg   |    2 ++
 l3kernel/testfiles/m3expl001.tlg        |    2 ++
 l3kernel/testfiles/m3expl001.uptex.tlg  |    2 ++
 l3kernel/testfiles/m3expl001.xetex.tlg  |    2 ++
 l3kernel/testfiles/m3expl003.luatex.tlg |    2 ++
 l3kernel/testfiles/m3expl003.ptex.tlg   |    2 ++
 l3kernel/testfiles/m3expl003.tlg        |    2 ++
 l3kernel/testfiles/m3expl003.uptex.tlg  |    2 ++
 l3kernel/testfiles/m3expl003.xetex.tlg  |    2 ++
 l3kernel/testfiles/m3peek001.lvt        |   11 +++++++++++
 l3kernel/testfiles/m3peek001.tlg        |   16 ++++++++++++++++
 14 files changed, 79 insertions(+)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 2b67419..0893eef 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -10,6 +10,7 @@ this project uses date-based 'snapshot' version identifiers.
 ### Added
 
 - `\g_msg_module_documentation_prop` (see #471)
+- `\peek_spaces_remove:n`
 
 ### Fixed
 
diff --git a/l3kernel/l3candidates.dtx b/l3kernel/l3candidates.dtx
index f64f954..c3e4e42 100644
--- a/l3kernel/l3candidates.dtx
+++ b/l3kernel/l3candidates.dtx
@@ -1500,6 +1500,14 @@
 % \end{verbatim}
 % \end{function}
 %
+% \begin{function}[added = 2018-10-01]{\peek_spaces_remove:n}
+%   \begin{syntax}
+%     \cs{peek_spaces_remove:n} \Arg{code}
+%   \end{syntax}
+%   Removes explicit and implicit space tokens (category code~$10$ and
+%   character code~$32$) from the input stream, then inserts \meta{code}.
+% \end{function}
+%
 % \end{documentation}
 %
 % \begin{implementation}
@@ -5334,6 +5342,29 @@
 % \end{macro}
 % \end{macro}
 %
+% \begin{macro}{\peek_spaces_remove:n, \@@_spaces_remove:}
+%   Repeatedly use \cs{@@_true_remove:w} to remove a space and call
+%   \cs{@@_true_aux:w}.
+%    \begin{macrocode}
+\cs_new_protected:Npn \peek_spaces_remove:n #1
+  {
+    \cs_set:Npx \@@_false:w { \exp_not:n {#1} }
+    \group_align_safe_begin:
+    \cs_set:Npn \@@_true_aux:w { \peek_after:Nw \@@_spaces_remove: }
+    \@@_true_aux:w
+  }
+\cs_new_protected:Npn \@@_spaces_remove:
+  {
+    \if_meaning:w \l_peek_token \c_space_token
+      \exp_after:wN \@@_true_remove:w
+    \else:
+      \group_align_safe_end:
+      \exp_after:wN \@@_false:w
+    \fi:
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 %    \begin{macrocode}
 %</initex|package>
 %    \end{macrocode}
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 9df9da5..de3ad4a 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -6092,6 +6092,8 @@ Defining \__peek_collect:NNn on line ...
 Defining \__peek_collect_true:w on line ...
 Defining \__peek_collect:N on line ...
 Defining \__peek_collect_remove:nw on line ...
+Defining \peek_spaces_remove:n on line ...
+Defining \__peek_spaces_remove: on line ...
 Defining \__kernel_deprecation_error:Nnn on line ...
 Defining \__deprecation_primitive:NN on line ...
 Defining \__deprecation_primitive:w on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index 0af0ffe..91a5bdb 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -6129,6 +6129,8 @@ Defining \__peek_collect:NNn on line ...
 Defining \__peek_collect_true:w on line ...
 Defining \__peek_collect:N on line ...
 Defining \__peek_collect_remove:nw on line ...
+Defining \peek_spaces_remove:n on line ...
+Defining \__peek_spaces_remove: on line ...
 Defining \__kernel_deprecation_error:Nnn on line ...
 Defining \__deprecation_primitive:NN on line ...
 Defining \__deprecation_primitive:w on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index c50ba0f..de46308 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -6330,6 +6330,8 @@ Defining \__peek_collect:NNn on line ...
 Defining \__peek_collect_true:w on line ...
 Defining \__peek_collect:N on line ...
 Defining \__peek_collect_remove:nw on line ...
+Defining \peek_spaces_remove:n on line ...
+Defining \__peek_spaces_remove: on line ...
 Defining \__kernel_deprecation_error:Nnn on line ...
 Defining \__deprecation_primitive:NN on line ...
 Defining \__deprecation_primitive:w on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index ea2d624..2b12709 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -6327,6 +6327,8 @@ Defining \__peek_collect:NNn on line ...
 Defining \__peek_collect_true:w on line ...
 Defining \__peek_collect:N on line ...
 Defining \__peek_collect_remove:nw on line ...
+Defining \peek_spaces_remove:n on line ...
+Defining \__peek_spaces_remove: on line ...
 Defining \__kernel_deprecation_error:Nnn on line ...
 Defining \__deprecation_primitive:NN on line ...
 Defining \__deprecation_primitive:w on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 0b538ae..6de4b9d 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -6096,6 +6096,8 @@ Defining \__peek_collect:NNn on line ...
 Defining \__peek_collect_true:w on line ...
 Defining \__peek_collect:N on line ...
 Defining \__peek_collect_remove:nw on line ...
+Defining \peek_spaces_remove:n on line ...
+Defining \__peek_spaces_remove: on line ...
 Defining \__kernel_deprecation_error:Nnn on line ...
 Defining \__deprecation_primitive:NN on line ...
 Defining \__deprecation_primitive:w on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 9df9da5..de3ad4a 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -6092,6 +6092,8 @@ Defining \__peek_collect:NNn on line ...
 Defining \__peek_collect_true:w on line ...
 Defining \__peek_collect:N on line ...
 Defining \__peek_collect_remove:nw on line ...
+Defining \peek_spaces_remove:n on line ...
+Defining \__peek_spaces_remove: on line ...
 Defining \__kernel_deprecation_error:Nnn on line ...
 Defining \__deprecation_primitive:NN on line ...
 Defining \__deprecation_primitive:w on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index 0af0ffe..91a5bdb 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -6129,6 +6129,8 @@ Defining \__peek_collect:NNn on line ...
 Defining \__peek_collect_true:w on line ...
 Defining \__peek_collect:N on line ...
 Defining \__peek_collect_remove:nw on line ...
+Defining \peek_spaces_remove:n on line ...
+Defining \__peek_spaces_remove: on line ...
 Defining \__kernel_deprecation_error:Nnn on line ...
 Defining \__deprecation_primitive:NN on line ...
 Defining \__deprecation_primitive:w on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index c50ba0f..de46308 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -6330,6 +6330,8 @@ Defining \__peek_collect:NNn on line ...
 Defining \__peek_collect_true:w on line ...
 Defining \__peek_collect:N on line ...
 Defining \__peek_collect_remove:nw on line ...
+Defining \peek_spaces_remove:n on line ...
+Defining \__peek_spaces_remove: on line ...
 Defining \__kernel_deprecation_error:Nnn on line ...
 Defining \__deprecation_primitive:NN on line ...
 Defining \__deprecation_primitive:w on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index ea2d624..2b12709 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -6327,6 +6327,8 @@ Defining \__peek_collect:NNn on line ...
 Defining \__peek_collect_true:w on line ...
 Defining \__peek_collect:N on line ...
 Defining \__peek_collect_remove:nw on line ...
+Defining \peek_spaces_remove:n on line ...
+Defining \__peek_spaces_remove: on line ...
 Defining \__kernel_deprecation_error:Nnn on line ...
 Defining \__deprecation_primitive:NN on line ...
 Defining \__deprecation_primitive:w on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 0b538ae..6de4b9d 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -6096,6 +6096,8 @@ Defining \__peek_collect:NNn on line ...
 Defining \__peek_collect_true:w on line ...
 Defining \__peek_collect:N on line ...
 Defining \__peek_collect_remove:nw on line ...
+Defining \peek_spaces_remove:n on line ...
+Defining \__peek_spaces_remove: on line ...
 Defining \__kernel_deprecation_error:Nnn on line ...
 Defining \__deprecation_primitive:NN on line ...
 Defining \__deprecation_primitive:w on line ...
diff --git a/l3kernel/testfiles/m3peek001.lvt b/l3kernel/testfiles/m3peek001.lvt
index 63fcbb9..3d5099b 100644
--- a/l3kernel/testfiles/m3peek001.lvt
+++ b/l3kernel/testfiles/m3peek001.lvt
@@ -203,6 +203,17 @@
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+\char_set_lccode:nn { 32 } { `* }
+\TEST { peek_spaces_remove }
+  {
+    \use:n { \peek_spaces_remove:n { \tl_show:n } ~ \c_space_token } ~ \c_space_tl
+    \if_false: { \fi: \peek_spaces_remove:n { \exp_after:wN \tl_show:n \token_to_str:N }  }
+    \use:x { \peek_spaces_remove:n { \tex_show:D } \c_catcode_other_space_tl }
+    \tex_lowercase:D { \peek_spaces_remove:n { \tex_show:D } ~ }
+  }
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 \END
 
 
diff --git a/l3kernel/testfiles/m3peek001.tlg b/l3kernel/testfiles/m3peek001.tlg
index 4964482..8974b97 100644
--- a/l3kernel/testfiles/m3peek001.tlg
+++ b/l3kernel/testfiles/m3peek001.tlg
@@ -201,3 +201,19 @@ TEST 10: peek collect
 |\c_group_begin_token \c_group_begin_token \c_group_begin_token |\a |
 |\c_group_end_token \c_group_end_token \c_group_end_token |\a |
 ============================================================
+============================================================
+TEST 11: peek_spaces_remove
+============================================================
+> \c_space_tl .
+<recently read> }
+l. ...  }
+> }.
+<recently read> }
+l. ...  }
+> the character  .
+<recently read>  
+l. ...  }
+> blank space *.
+<recently read> *
+l. ...  }
+============================================================





More information about the latex3-commits mailing list