diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/base/ltcmd.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/base/ltcmd.dtx | 157 |
1 files changed, 131 insertions, 26 deletions
diff --git a/Master/texmf-dist/source/latex/base/ltcmd.dtx b/Master/texmf-dist/source/latex/base/ltcmd.dtx index 14d6756f5c2..d6322ff3ee8 100644 --- a/Master/texmf-dist/source/latex/base/ltcmd.dtx +++ b/Master/texmf-dist/source/latex/base/ltcmd.dtx @@ -1,8 +1,8 @@ % \iffalse meta-comment % % Copyright (C) 1999 Frank Mittelbach, Chris Rowley, David Carlisle -% Copyright (C) 2004-2008 Frank Mittelbach, The LaTeX3 Project -% Copyright (C) 2009-2022 +% 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.1a} -\def\ltcmddate{2022-08-16} +\def\ltcmdversion{v1.1e} +\def\ltcmddate{2023-05-26} % \end{macrocode} % %<*driver> @@ -725,6 +725,9 @@ { \@@_environment_or_command: } } % \end{macrocode} +% +% \changes{v1.1e}{2023/05/26} +% {Use simpler variant \cs{cs_generate_from_arg_count:NNno}} % To construct \cs{@@_tmp:w}, first go through the arguments % found and the corresponding defaults, building a token list with % |{#|\meta{arg number}|}| for arguments found in the input (whose @@ -738,10 +741,10 @@ \int_zero:N \l_@@_current_arg_int \@@_tl_mapthread_function:NNN \l_@@_args_tl \l_@@_defaults_tl \@@_defaults_def:nn - \cs_generate_from_arg_count:NNVo \@@_tmp:w \cs_set:Npn + \cs_generate_from_arg_count:NNno \@@_tmp:w \cs_set:Npn \l_@@_current_arg_int \l_@@_tmpa_tl } -\cs_generate_variant:Nn \cs_generate_from_arg_count:NNnn { NNVo } +\cs_generate_variant:Nn \cs_generate_from_arg_count:NNnn { NNno } \cs_new_protected:Npn \@@_defaults_def:nn { \int_incr:N \l_@@_current_arg_int @@ -2123,8 +2126,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 +2135,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 +2160,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 +2402,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} @@ -2401,21 +2448,64 @@ % \@@_show_command:NnNNwN, % \@@_show_expandable:N, % \@@_show_expandable:NnNNNNnN, -% \@@_show_command_aux:nNNn, +% \@@_show_command_aux:NnNNn, % \@@_show_environment:N, +% \@@_show:x, % } % These commands just expand the command once to reveal its innards, % then pass the type of command, the control sequence, the signature, -% and the code macro to \cs{@@_show_command_aux:nNNn}. +% and the code macro to \cs{@@_show_command_aux:NnNNn}. % \begin{macrocode} \cs_new_protected:Npn \@@_show_command:N #1 { \exp_after:wN \@@_show_command:NnNNwN #1 \q_@@ #1 } \cs_new_protected:Npn \@@_show_command:NnNNwN #1 #2 #3 #4 #5 \q_@@ #6 - { \@@_show_command_aux:nNNn { document~command } #6 #4 {#2} } + { + \@@_show_command_aux:NnNNn \tl_show:x + { document~command } #6 #4 {#2} + } \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:nNNn { 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 @@ -2423,27 +2513,31 @@ % \cs{l_@@_tmpa_tl}, so we ust use that here: % \changes{v1.0j}{2021/13/31} % {Make \cs{ShowCommand} stop for interaction} +% \changes{v1.1b}{2022/11/30} +% {Don't stop for the \cs{begin} part of an environment} % \begin{macrocode} -\cs_new_protected:Npn \@@_show_command_aux:nNNn #1 #2 #3 #4 +\cs_new_protected:Npn \@@_show_command_aux:NnNNn #1 #2 #3 #4 #5 { - \@@_split_signature:n {#4} - \tl_show:x + \@@_split_signature:n {#5} + #1 { - \token_to_str:N #2 = #1: \iow_newline: + \token_to_str:N #3 = #2: \iow_newline: \tl_use:N \l_@@_tmpa_tl - -> \cs_replacement_spec:N #3 + -> \cs_replacement_spec:N #4 } } % \end{macrocode} % % We can reuse most of the above to show an environment, except that % we need to ensure that the proper \cs[no-index]{environment~\ldots} -% are passed to \cs{@@_show_command_aux:nNNn}. Additionally, when +% are passed to \cs{@@_show_command_aux:NnNNn}. Additionally, when % |\ShowCommand\foo| is used (if |foo| is an environment), we show % |\endfoo| as well, and when |\ShowCommand\endfoo| is used, change % that to |\ShowCommand\foo| and do the same. % \changes{v1.0j}{2021/13/31} % {Make \cs{ShowCommand} stop for interaction} +% \changes{v1.1b}{2022/11/30} +% {Don't stop for the \cs{begin} part of an environment} % \begin{macrocode} \cs_new_protected:Npn \@@_show_environment:N #1 { @@ -2459,12 +2553,14 @@ { \use:x { - \@@_show_command_aux:nNNn { document~environment } + \@@_show_command_aux:NnNNn \@@_show:x { document~environment } { \exp_not:N \begin {#3} } \exp_not:c { environment~ #3 ~ code } {#2} } } +\cs_new_protected:Npn \@@_show:x #1 + { \iow_term:x { > ~ #1 . \iow_newline: } } \cs_new_protected:Npn \@@_show_environment_end:N #1 { \exp_args:NNx \@@_check_end:Nn \l_@@_tmpa_tl { \cs_to_str:N #1 } @@ -2473,10 +2569,15 @@ % \end{macrocode} % % And, of course, add \cs{__kernel_cmd_if_xparse:NTF} and -% \cs{@@_show:N} to \cs{@showcommandlisthook}: +% \cs{@@_show:N} to \cs{@showcommandlisthook} and to +% \cs{@showenvironmentlisthook} (\cs{@@_show:N} takes care of the +% environment case as well, so both entries are identical): +% \changes{v1.1b}{2022-11-29}{Add \cs{@showenvironmentlisthook}} % \begin{macrocode} \tl_gput_right:Nn \@showcommandlisthook { { \__kernel_cmd_if_xparse:NTF \@@_show:N } } +\tl_gput_right:Nn \@showenvironmentlisthook + { { \__kernel_cmd_if_xparse:NTF \@@_show:N } } % \end{macrocode} % \end{macro} % @@ -2657,7 +2758,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} @@ -3200,6 +3301,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 @@ -3233,6 +3338,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 { @@ -3250,8 +3356,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} @@ -3396,7 +3502,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 } } |