[latex3-commits] [git/LaTeX3-latex3-latex3] peek-refactor: Expand undefined tokens as TeX does for \peek_remove_filler:n (f6f24ee5c)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Jan 11 14:32:29 CET 2022


Repository : https://github.com/latex3/latex3
On branch  : peek-refactor
Link       : https://github.com/latex3/latex3/commit/f6f24ee5cb6f3fa81c0360adbc7e6f7d7444aeae

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

commit f6f24ee5cb6f3fa81c0360adbc7e6f7d7444aeae
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Jan 11 13:32:29 2022 +0000

    Expand undefined tokens as TeX does for \peek_remove_filler:n


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

f6f24ee5cb6f3fa81c0360adbc7e6f7d7444aeae
 l3kernel/l3token.dtx             | 15 +++++++++------
 l3kernel/testfiles/m3peek001.lvt |  1 +
 l3kernel/testfiles/m3peek001.tlg | 12 ++++++++++++
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/l3kernel/l3token.dtx b/l3kernel/l3token.dtx
index 0ad12ab9f..76541760b 100644
--- a/l3kernel/l3token.dtx
+++ b/l3kernel/l3token.dtx
@@ -932,9 +932,6 @@
 %     the search for a left brace after for example \tn{everypar}, except that
 %     any non-expandable token cleanly ends the \meta{filler} (i.e.~it does not
 %     lead to a \TeX{} error).
-%
-%     Expansion will be stopped by an undefined control sequence, which is treated
-%     as non-expandable.
 %   \end{texnote}
 % \end{function}
 %
@@ -2906,11 +2903,17 @@ end
       \fi:
     \fi:
   }
+%    \end{macrocode}
+%   To deal with undefined control sequences in the same way \TeX{} does,
+%   we need to check for expansion manually.
+%    \begin{macrocode}
 \cs_new_protected:Npn \@@_remove_filler_expand:w
   {
-    \token_if_expandable:NTF \l_peek_token
-      { \@@_remove_filler:w }
-      { \@@_false:w }
+    \exp_after:wN \if_meaning:w \exp_not:N \l_peek_token \l_peek_token
+      \exp_after:wN \@@_false:w
+    \else:
+      \exp_after:wN \@@_remove_filler:w
+    \fi:
   }
 %    \end{macrocode}
 % \end{macro}
diff --git a/l3kernel/testfiles/m3peek001.lvt b/l3kernel/testfiles/m3peek001.lvt
index 6ed053154..53d2df519 100644
--- a/l3kernel/testfiles/m3peek001.lvt
+++ b/l3kernel/testfiles/m3peek001.lvt
@@ -195,6 +195,7 @@
     \tl_set:Nx \l_tmpa_tl { \use:n { \scan_stop: \c_space_tl } ~ \scan_stop: } 
     \use:n { \peek_remove_filler:n { \tex_show:D } ~ \c_space_token } ~ \c_space_tl
       \l_tmpa_tl _
+    \peek_remove_filler:n { \tex_show:D } \undefined \scan_stop: _
   }
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
diff --git a/l3kernel/testfiles/m3peek001.tlg b/l3kernel/testfiles/m3peek001.tlg
index 622d8d5fb..ad9c4bc0f 100644
--- a/l3kernel/testfiles/m3peek001.tlg
+++ b/l3kernel/testfiles/m3peek001.tlg
@@ -175,4 +175,16 @@ TEST 12: \peek_remove_filler:n
 > the letter _.
 <recently read> _
 l. ...  }
+! Undefined control sequence.
+<argument> ...e_filler:n {\tex_show:D }\undefined 
+                                                  \scan_stop: _
+l. ...  }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+> the letter _.
+<recently read> _
+l. ...  }
 ============================================================





More information about the latex3-commits mailing list.