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.dtx152
1 files changed, 123 insertions, 29 deletions
diff --git a/macros/latex-dev/base/ltcmd.dtx b/macros/latex-dev/base/ltcmd.dtx
index 69bd162e56..eccb104bb9 100644
--- a/macros/latex-dev/base/ltcmd.dtx
+++ b/macros/latex-dev/base/ltcmd.dtx
@@ -34,8 +34,8 @@
%%% From File: ltcmd.dtx
%
% \begin{macrocode}
-\def\ltcmdversion{v1.2e}
-\def\ltcmddate{2024-04-17}
+\def\ltcmdversion{v1.2f}
+\def\ltcmddate{2024-07-06}
% \end{macrocode}
%
%<*driver>
@@ -620,31 +620,51 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}{\@@_declare_env:nnnn}
+% \begin{macro}{\@@_declare_env:nnnn, \@@_declare_env:ennn}
+% \changes{v1.2f}{2024/07/06}{Use space-trimmed envname directly (gh/1399)}
% \begin{macro}{\@@_declare_env_internal:nnnn}
+% \begin{macro}{\@@_set_environment_end:n}
% The lead-off to creating an environment is much the same as that for
% creating a command: issue the appropriate message, store the argument
% specification then hand off to an internal function.
% \begin{macrocode}
+%<latexrelease>\IncludeInRelease{2024/11/01}{\@@_declare_env:nnnn}%
+%<latexrelease> {Use~space-trimmed~envname~directly}
\cs_new_protected:Npn \@@_declare_env:nnnn #1#2
{
- \str_set:Nx \l_@@_environment_str {#1}
- \str_set:Nx \l_@@_environment_str
- { \tl_trim_spaces:o { \l_@@_environment_str } }
- \cs_if_exist:cTF { \l_@@_environment_str }
- {
- \msg_info:nnxx { cmd } { redefine-env }
- { \l_@@_environment_str } { \tl_to_str:n {#2} }
- }
- {
- \msg_info:nnxx { cmd } { define-env }
- { \l_@@_environment_str } { \tl_to_str:n {#2} }
- }
+ \str_set:Nn \l_@@_environment_str {#1}
+ \cs_if_exist:cTF { #1 }
+ { \msg_info:nnnn { cmd } { redefine-env } { #1 } { #2 } }
+ { \msg_info:nnnn { cmd } { define-env } { #1 } { #2 } }
\bool_set_false:N \l_@@_expandable_bool
\bool_set_true:N \l_@@_environment_bool
- \exp_args:NV \@@_declare_env_internal:nnnn
- \l_@@_environment_str {#2}
+ \@@_declare_env_internal:nnnn {#1} {#2}
}
+\cs_generate_variant:Nn \@@_declare_env:nnnn { e }
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{2024/06/01}{\@@_declare_env:nnnn}%
+%<latexrelease> {Use~space-trimmed~envname~directly}
+%<latexrelease>\cs_new_protected:Npn \@@_declare_env:nnnn #1#2
+%<latexrelease> {
+%<latexrelease> \str_set:Nx \l_@@_environment_str {#1}
+%<latexrelease> \str_set:Nx \l_@@_environment_str
+%<latexrelease> { \tl_trim_spaces:o { \l_@@_environment_str } }
+%<latexrelease> \cs_if_exist:cTF { \l_@@_environment_str }
+%<latexrelease> {
+%<latexrelease> \msg_info:nnxx { cmd } { redefine-env }
+%<latexrelease> { \l_@@_environment_str } { \tl_to_str:n {#2} }
+%<latexrelease> }
+%<latexrelease> {
+%<latexrelease> \msg_info:nnxx { cmd } { define-env }
+%<latexrelease> { \l_@@_environment_str } { \tl_to_str:n {#2} }
+%<latexrelease> }
+%<latexrelease> \bool_set_false:N \l_@@_expandable_bool
+%<latexrelease> \bool_set_true:N \l_@@_environment_bool
+%<latexrelease> \exp_args:NV \@@_declare_env_internal:nnnn
+%<latexrelease> \l_@@_environment_str {#2}
+%<latexrelease> }
+%<latexrelease>
+%<latexrelease>\EndIncludeInRelease
% \end{macrocode}
% Creating a document environment requires a few more steps than creating
% a single command. In order to pass the arguments of the command to the
@@ -685,6 +705,7 @@
% \end{macrocode}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% \subsection{Structure of \pkg{xparse} commands}
%
@@ -5022,36 +5043,109 @@
%
% \begin{macro}{\NewDocumentEnvironment}
% \changes{v1.0h}{2021/08/27}{Check for end-of-environment command}
+% \changes{v1.2f}{2024/07/06}{Trim spaces from envname first (gh/1399)}
% \begin{macro}{\RenewDocumentEnvironment}
% \begin{macro}{\ProvideDocumentEnvironment}
% \begin{macro}{\DeclareDocumentEnvironment}
-% Very similar for environments.
-% \begin{macrocode}
+% \begin{macro}{\@@_new_env:nnnn, \@@_renew_env:nnnn, \@@_provide_env:nnnn}
+% \begin{macro}{\@@_new_env:ennn, \@@_renew_env:ennn, \@@_provide_env:ennn}
+% Very similar for environments. Trim spaces from user-specified
+% \meta{envname}, do existence check then hand off to
+% \cs{@@_declare_env:nnnn}.
+% \begin{macrocode}
+%<latexrelease>\IncludeInRelease{2024/11/01}{\NewDocumentEnvironment}%
+%<latexrelease> {Trim~spaces~from~envname~first}
\cs_new_protected:Npn \NewDocumentEnvironment #1#2#3#4
{
+ \@@_new_env:ennn { \tl_trim_spaces:e {#1} } {#2} {#3} {#4}
+ }
+\cs_new_protected:Npn \RenewDocumentEnvironment #1#2#3#4
+ {
+ \@@_renew_env:ennn { \tl_trim_spaces:e {#1} } {#2} {#3} {#4}
+ }
+\cs_new_protected:Npn \ProvideDocumentEnvironment #1#2#3#4
+ {
+ \@@_provide_env:ennn { \tl_trim_spaces:e {#1} } {#2} {#3} {#4}
+ }
+\cs_new_protected:Npn \DeclareDocumentEnvironment #1#2#3#4
+ {
+ \@@_declare_env:ennn { \tl_trim_spaces:e {#1} } {#2} {#3} {#4}
+ }
+% \end{macrocode}
+% Each of \cs[no-index]{@@_(new|renew|provide)_env:nnnn} is curried.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_new_env:nnnn #1
+ {
\cs_if_exist:cTF {#1}
- { \msg_error:nnx { cmd } { env-already-defined } {#1} }
+ {
+ \msg_error:nnx { cmd } { env-already-defined } {#1}
+ \use_none:nnn
+ }
{
\cs_if_exist:cTF { end #1 }
- { \msg_error:nnx { cmd } { env-end-already-defined } {#1} }
- { \@@_declare_env:nnnn {#1} {#2} {#3} {#4} }
+ {
+ \msg_error:nnx { cmd } { env-end-already-defined } {#1}
+ \use_none:nnn
+ }
+ { \@@_declare_env:nnnn {#1} }
}
}
-\cs_new_protected:Npn \RenewDocumentEnvironment #1#2#3#4
+\cs_new_protected:Npn \@@_renew_env:nnnn #1
{
\cs_if_exist:cTF {#1}
- { \@@_declare_env:nnnn {#1} {#2} {#3} {#4} }
- { \msg_error:nnx { cmd } { env-undefined } {#1} }
+ { \@@_declare_env:nnnn {#1} }
+ {
+ \msg_error:nnx { cmd } { env-undefined } {#1}
+ \use_none:nnn
+ }
}
-\cs_new_protected:Npn \ProvideDocumentEnvironment #1#2#3#4
- { \cs_if_exist:cF {#1} { \@@_declare_env:nnnn {#1} {#2} {#3} {#4} } }
-\cs_new_protected:Npn \DeclareDocumentEnvironment #1#2#3#4
- { \@@_declare_env:nnnn {#1} {#2} {#3} {#4} }
+\cs_new_protected:Npn \@@_provide_env:nnnn #1
+ {
+ \cs_if_exist:cTF {#1}
+ { \use_none:nnn }
+ { \@@_declare_env:nnnn {#1} }
+ }
+\cs_generate_variant:Nn \@@_new_env:nnnn { e }
+\cs_generate_variant:Nn \@@_renew_env:nnnn { e }
+\cs_generate_variant:Nn \@@_provide_env:nnnn { e }
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{2024/06/01}{\NewDocumentEnvironment}%
+%<latexrelease> {Trim~spaces~from~envname~first}
+%<latexrelease>\cs_new_protected:Npn \NewDocumentEnvironment #1#2#3#4
+%<latexrelease> {
+%<latexrelease> \cs_if_exist:cTF {#1}
+%<latexrelease> { \msg_error:nnx { cmd } { env-already-defined } {#1} }
+%<latexrelease> {
+%<latexrelease> \cs_if_exist:cTF { end #1 }
+%<latexrelease> { \msg_error:nnx { cmd } { env-end-already-defined } {#1} }
+%<latexrelease> { \@@_declare_env:nnnn {#1} {#2} {#3} {#4} }
+%<latexrelease> }
+%<latexrelease> }
+%<latexrelease>\cs_new_protected:Npn \RenewDocumentEnvironment #1#2#3#4
+%<latexrelease> {
+%<latexrelease> \cs_if_exist:cTF {#1}
+%<latexrelease> { \@@_declare_env:nnnn {#1} {#2} {#3} {#4} }
+%<latexrelease> { \msg_error:nnx { cmd } { env-undefined } {#1} }
+%<latexrelease> }
+%<latexrelease>\cs_new_protected:Npn \ProvideDocumentEnvironment #1#2#3#4
+%<latexrelease> { \cs_if_exist:cF {#1} { \@@_declare_env:nnnn {#1} {#2} {#3} {#4} } }
+%<latexrelease>\cs_new_protected:Npn \DeclareDocumentEnvironment #1#2#3#4
+%<latexrelease> { \@@_declare_env:nnnn {#1} {#2} {#3} {#4} }
+%<latexrelease>\cs_undefine:N \@@_new_env:nnnn
+%<latexrelease>\cs_undefine:N \@@_new_env:ennn
+%<latexrelease>\cs_undefine:N \@@_renew_env:nnnn
+%<latexrelease>\cs_undefine:N \@@_renew_env:ennn
+%<latexrelease>\cs_undefine:N \@@_provide_env:nnnn
+%<latexrelease>\cs_undefine:N \@@_provide_env:ennn
+%<latexrelease>
+%<latexrelease>\EndIncludeInRelease
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
+% \end{macro}
%
% \begin{macro}{\NewExpandableDocumentCommand}
% \begin{macro}{\RenewExpandableDocumentCommand}