[latex3-commits] [git/LaTeX3-latex3-latex3] cs-delimited-args: Add \@@_token_if_cs:NTF test (bdfd33edd)

PhelypeOleinik tex.phelype at gmail.com
Wed Feb 26 16:38:50 CET 2020


Repository : https://github.com/latex3/latex3
On branch  : cs-delimited-args
Link       : https://github.com/latex3/latex3/commit/bdfd33eddbd1902c011121cf31d7378e8eef27b4

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

commit bdfd33eddbd1902c011121cf31d7378e8eef27b4
Author: PhelypeOleinik <tex.phelype at gmail.com>
Date:   Wed Feb 26 12:38:50 2020 -0300

    Add \@@_token_if_cs:NTF test


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

bdfd33eddbd1902c011121cf31d7378e8eef27b4
 l3packages/xparse/xparse.dtx | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/l3packages/xparse/xparse.dtx b/l3packages/xparse/xparse.dtx
index 95358b2c4..b36aa5fd6 100644
--- a/l3packages/xparse/xparse.dtx
+++ b/l3packages/xparse/xparse.dtx
@@ -4284,6 +4284,28 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\@@_token_if_cs:NTF}
+%   Based on the definition of \cs{@@_check_definable_aux:nN} above, but
+%   only checks for an actual control sequence (\emph{i.e.},
+%   \cs[no-index]{\meta{anything}}). \cs{tex_escapechar:D} is
+%   temporarily changed to a known value and then it checks if
+%   |\string#1| contains more than one character: if it does, it's a
+%   control sequence.  This test differs from \cs{token_if_cs:NTF} for
+%   example in \verb|\token_if_cs:NTF \c_group_begin_token {T}{F}|,
+%   where \cs{token_if_cs:NTF} returns false.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_token_if_cs:NTF #1
+  {
+    \group_begin:
+      \int_set:Nn \tex_escapechar:D { 92 }
+      \exp_args:Nx \tl_if_empty:nTF
+          { \exp_args:No \str_tail:n { \token_to_str:N #1 } }
+        { \group_end: \use_ii:nn }
+        { \group_end: \use_i:nn }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\@@_tl_mapthread_function:NNN, \@@_tl_mapthread_function:nnN}
 % \begin{macro}{\@@_tl_mapthread_loop:w}
 %   Analogue of \cs{seq_mapthread_function:NNN} for token lists.





More information about the latex3-commits mailing list.