summaryrefslogtreecommitdiff
path: root/macros/latex-dev/base/ltcmd.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex-dev/base/ltcmd.dtx')
-rw-r--r--macros/latex-dev/base/ltcmd.dtx110
1 files changed, 97 insertions, 13 deletions
diff --git a/macros/latex-dev/base/ltcmd.dtx b/macros/latex-dev/base/ltcmd.dtx
index 78a5a389ae..5f019cdc2a 100644
--- a/macros/latex-dev/base/ltcmd.dtx
+++ b/macros/latex-dev/base/ltcmd.dtx
@@ -1,7 +1,7 @@
% \iffalse meta-comment
%
% Copyright (C) 1999 Frank Mittelbach, Chris Rowley, David Carlisle
-% Copyright (C) 2004-2008 Frank Mittelbach, The LaTeX3 Project
+% Copyright (C) 2004-2008 Frank Mittelbach, The LaTeX Project
% Copyright (C) 2009-2023
% The LaTeX Project and any individual authors listed elsewhere
% in this file.
@@ -34,8 +34,8 @@
%%% From File: ltcmd.dtx
%
% \begin{macrocode}
-\def\ltcmdversion{v1.1b}
-\def\ltcmddate{2022-11-29}
+\def\ltcmdversion{v1.1d}
+\def\ltcmddate{2023-04-13}
% \end{macrocode}
%
%<*driver>
@@ -2123,8 +2123,8 @@
% and possibly another auxiliary
% \cs{\meta{cmd}\textvisiblespace\textvisiblespace}, if the command
% has both long and short arguments. Then, its signature also has
-% several specific bits that are unique to that command; this is in contrast to
-% non-expandable commands, which use a common set of parsing functions.
+% several specific bits that are unique to that command; this is in contrast
+% to non-expandable commands, which use a common set of parsing functions.
%
% We start by copying the basics, then call
% \cs{@@_copy_expandable_signature:NnNNNNnnn} to parse the signature
@@ -2132,7 +2132,24 @@
% then we call \cs{@@_copy_expandable:NnNNNNnnn} that will copy the
% top-level definition of the command, with the proper internal
% renames.
+%
% \begin{macrocode}
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{2020/10/01}{\@@_copy:NN}%
+%<latexrelease> {Support~\NewCommandCopy~in~ltcmd}
+%<latexrelease>\EndIncludeInRelease
+% \end{macrocode}
+%
+% \changes{v1.1c}{2023/03/12}
+% {Distinguish (non-expandable) document commands starting with
+% \cs{@@_start_expandable:nNNNNn}}
+% There's one variant: a command begins with \cs{@@_start_expandable:nNNNNn}
+% may still be un-expandable/protected if it's defined by
+% \cs{NewDocumentCommand} and friends, with empty or only m-type arguments.
+%
+% \begin{macrocode}
+%<latexrelease>\IncludeInRelease{2023/06/01}{\@@_copy_expandable:nnNN}%
+%<latexrelease> {Distinguish~non-expandable~document~commands}
\cs_new_protected:Npn \@@_copy_expandable:nnNN #1 #2 #3 #4
{
\cs_set_eq:cc { #1 ~ code } { #2 ~ code }
@@ -2140,9 +2157,36 @@
\@@_set_eq_if_exist:cc { #1 ~ \c_space_tl } { #2 ~ \c_space_tl }
\@@_set_eq_if_exist:cc { #1 ~ defaults } { #2 ~ defaults }
\exp_after:wN \@@_copy_expandable_signature:NnNNNNnnn #4 {#1} {#2}
- \cs_set_nopar:Npx #3
+ \token_if_protected_macro:NTF #4
+ { \cs_set_protected_nopar:Npx }{ \cs_set_nopar:Npx }
+ #3
{ \exp_after:wN \@@_copy_expandable:NnNNNNnnn #4 {#1} {#2} }
}
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{2021/11/15}{\@@_copy_expandable:nnNN}%
+%<latexrelease> {Support~\NewCommandCopy~in~ltcmd}
+%<latexrelease>\cs_new_protected:Npn \@@_copy_expandable:nnNN #1 #2 #3 #4
+%<latexrelease> {
+%<latexrelease> \cs_set_eq:cc { #1 ~ code } { #2 ~ code }
+%<latexrelease> \@@_set_eq_if_exist:cc { #1 ~ } { #2 ~ }
+%<latexrelease> \@@_set_eq_if_exist:cc { #1 ~ \c_space_tl } { #2 ~ \c_space_tl }
+%<latexrelease> \@@_set_eq_if_exist:cc { #1 ~ defaults } { #2 ~ defaults }
+%<latexrelease> \exp_after:wN \@@_copy_expandable_signature:NnNNNNnnn #4 {#1} {#2}
+%<latexrelease> \cs_set_nopar:Npx #3
+%<latexrelease> { \exp_after:wN \@@_copy_expandable:NnNNNNnnn #4 {#1} {#2} }
+%<latexrelease> }
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{2020/10/01}{\@@_copy_expandable:nnNN}%
+%<latexrelease> {Support~\NewCommandCopy~in~ltcmd}
+%<latexrelease>\EndIncludeInRelease
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<latexrelease>\IncludeInRelease{2021/11/15}{\@@_copy:NN (part 2)}%
+%<latexrelease> {Support~\NewCommandCopy~in~ltcmd}
+% \end{macrocode}
+%
+% \begin{macrocode}
\cs_new:Npn \@@_copy_expandable:NnNNNNnnn #1 #2 #3 #4 #5 #6 #7 #8 #9
{
\exp_not:N #1 \exp_not:n { {#2} }
@@ -2355,7 +2399,7 @@
% worth it.
% \begin{macrocode}
%<latexrelease>\EndIncludeInRelease
-%<latexrelease>\IncludeInRelease{2020/10/01}{\@@_copy:NN}%
+%<latexrelease>\IncludeInRelease{2020/10/01}{\@@_copy:NN (part 2)}%
%<latexrelease> {Support~\NewCommandCopy~in~ltcmd}
%<latexrelease>\EndIncludeInRelease
% \end{macrocode}
@@ -2418,11 +2462,47 @@
}
\cs_new_protected:Npn \@@_show_expandable:N #1
{ \exp_after:wN \@@_show_expandable:NnNNNNnN #1 #1 }
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{2020/10/01}{\@@_show:N}%
+%<latexrelease> {Support~\ShowCommand~in~ltcmd}
+%<latexrelease>\EndIncludeInRelease
+% \end{macrocode}
+%
+% \changes{v1.1c}{2023/03/12}
+% {Distinguish (non-expandable) document commands starting with
+% \cs{@@_start_expandable:nNNNNn}}
+% There's one variant: a command begins with \cs{@@_start_expandable:nNNNNn}
+% may still be un-expandable/protected if it's defined by
+% \cs{NewDocumentCommand} and friends, with empty or only m-type arguments.
+% \begin{macrocode}
+%<latexrelease>\IncludeInRelease{2023/06/01}{\@@_show_expandable:NnNNNNnN}%
+%<latexrelease> {Distinguish~non-expandable~document~commands}
\cs_new_protected:Npn \@@_show_expandable:NnNNNNnN #1 #2 #3 #4 #5 #6 #7 #8
{
- \@@_show_command_aux:NnNNn \tl_show:x
- { expandable~document~command } #8 #5 {#2}
+ \exp_args:NNe \@@_show_command_aux:NnNNn \tl_show:x
+ { \token_if_protected_macro:NF #8 { expandable~ } document~command }
+ #8 #5 {#2}
}
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{2021/11/15}{\@@_show_expandable:NnNNNNnN}%
+%<latexrelease> {Support~\ShowCommand~in~ltcmd}
+%<latexrelease>\cs_new_protected:Npn \@@_show_expandable:NnNNNNnN #1 #2 #3 #4 #5 #6 #7 #8
+%<latexrelease> {
+%<latexrelease> \@@_show_command_aux:NnNNn \tl_show:x
+%<latexrelease> { expandable~document~command } #8 #5 {#2}
+%<latexrelease> }
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{2020/10/01}{\@@_show_expandable:NnNNNNnN}%
+%<latexrelease> {Support~\ShowCommand~in~ltcmd}
+%<latexrelease>\EndIncludeInRelease
+% \end{macrocode}
+%
+% \begin{macrocode}
+%<latexrelease>\IncludeInRelease{2021/11/15}{\@@_show:N (part 2)}%
+%<latexrelease> {Support~\ShowCommand~in~ltcmd}
% \end{macrocode}
%
% Now just print everything in the required format. The auxiliary
@@ -2675,7 +2755,7 @@
% \begin{macrocode}
%<latexrelease>\EndIncludeInRelease
%
-%<latexrelease>\IncludeInRelease{2020/10/01}{\@@_show:N}%
+%<latexrelease>\IncludeInRelease{2020/10/01}{\@@_show:N (part 2)}%
%<latexrelease> {Support~\ShowCommand~in~ltcmd}
%<latexrelease>\EndIncludeInRelease
% \end{macrocode}
@@ -3218,6 +3298,10 @@
% \begin{macro}{\@@_grab_v_long:w}
% \begin{macro}{\@@_grab_v_aux:w}
% \begin{macro}{\@@_grab_v_group_end:}
+% Firstly, it is necessary to change \cs{tex_endlinechar:D} so that
+% newlines in different catcode regimes (e.g., \cs{ExplSyntaxOn}) are
+% not misinterpreted as spaces.
+% \changes{v1.1d}{2023/04/13}{Set \cs{tex_endlinechar:D} earlier (gh/876).}
% The opening delimiter is the first non-space token, and is never
% read verbatim. This is required by consistency with the case where
% the preceding argument was optional and absent: then \TeX{} has
@@ -3251,6 +3335,7 @@
\tl_set:Nn \l_@@_signature_tl {#1}
\group_begin:
\tex_escapechar:D = 92 \scan_stop:
+ \tex_endlinechar:D = `\^^M \scan_stop:
\tl_clear:N \l_@@_v_arg_tl
\peek_remove_spaces:n
{
@@ -3268,8 +3353,8 @@
}
\cs_new_protected:Npn \@@_grab_v_group_end:
{
- \exp_args:NNNo
- \group_end:
+ \exp_args:NNNo
+ \group_end:
\tl_set:Nn \l_@@_v_arg_tl { \l_@@_v_arg_tl }
}
% \end{macrocode}
@@ -3414,7 +3499,6 @@
{
\cs_set_eq:NN \do \char_set_catcode_other:N
\dospecials
- \tex_endlinechar:D = `\^^M \scan_stop:
\bool_if:NTF \l_@@_long_bool
{ \char_set_catcode_other:n { \tex_endlinechar:D } }
{ \char_set_catcode_parameter:n { \tex_endlinechar:D } }