[latex3-commits] [l3svn] r6264 - Improve \GetDocumentCommandArgSpec error message (see #286)
noreply at latex-project.org
noreply at latex-project.org
Sun Nov 15 20:33:17 CET 2015
Author: bruno
Date: 2015-11-15 20:33:16 +0100 (Sun, 15 Nov 2015)
New Revision: 6264
Modified:
trunk/l3packages/xparse/xparse.dtx
Log:
Improve \GetDocumentCommandArgSpec error message (see #286)
I'm not marking #286 as resolved because I haven't added tests yet
for (Get|Show)Document(Command|Environment)ArgSpec.
Modified: trunk/l3packages/xparse/xparse.dtx
===================================================================
--- trunk/l3packages/xparse/xparse.dtx 2015-11-15 18:21:43 UTC (rev 6263)
+++ trunk/l3packages/xparse/xparse.dtx 2015-11-15 19:33:16 UTC (rev 6264)
@@ -3180,29 +3180,44 @@
%
% \subsection{Access to the argument specification}
%
+% \begin{macro}{\@@_get_arg_spec_error:N, \@@_get_arg_spec_error:n}
+% Provide an informative error when trying to get the argument
+% specification of a non-\pkg{xparse} command or environment.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_get_arg_spec_error:N #1
+ {
+ \cs_if_exist:NTF #1
+ { \__msg_kernel_error:nnx { xparse } { non-xparse-command } }
+ { \__msg_kernel_error:nnx { xparse } { unknown-command } }
+ { \token_to_str:N #1 }
+ }
+\cs_new_protected:Npn \@@_get_arg_spec_error:n #1
+ {
+ \cs_if_exist:cTF {#1}
+ { \__msg_kernel_error:nnx { xparse } { non-xparse-environment } }
+ { \__msg_kernel_error:nnx { xparse } { unknown-environment } }
+ { \tl_to_str:n {#1} }
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\@@_get_arg_spec:N}
% \begin{macro}{\@@_get_arg_spec:n}
% \begin{macro}{\ArgumentSpecification}
-% Recovering the argument specification is also trivial, using the
-% \cs{tl_set_eq:cN} function.
+% Recovering the argument specification is trivial, using the
+% branching \cs{prop_get:NnN} function.
% \begin{macrocode}
\cs_new_protected:Npn \@@_get_arg_spec:N #1
{
\prop_get:NnNF \l_@@_command_arg_specs_prop {#1}
\ArgumentSpecification
- {
- \__msg_kernel_error:nnx { xparse } { unknown-document-command }
- { \token_to_str:N #1 }
- }
+ { \@@_get_arg_spec_error:N #1 }
}
\cs_new_protected:Npn \@@_get_arg_spec:n #1
{
\prop_get:NnNF \l_@@_environment_arg_specs_prop {#1}
\ArgumentSpecification
- {
- \__msg_kernel_error:nnx { xparse } { unknown-document-environment }
- { \tl_to_str:n {#1} }
- }
+ { \@@_get_arg_spec_error:n {#1} }
}
\tl_new:N \ArgumentSpecification
% \end{macrocode}
@@ -3220,20 +3235,14 @@
\prop_get:NnNTF \l_@@_command_arg_specs_prop {#1}
\ArgumentSpecification
{ \tl_show:N \ArgumentSpecification }
- {
- \__msg_kernel_error:nnx { xparse } { unknown-document-command }
- { \token_to_str:N #1 }
- }
+ { \@@_get_arg_spec_error:N #1 }
}
\cs_new_protected:Npn \@@_show_arg_spec:n #1
{
\prop_get:NnNTF \l_@@_environment_arg_specs_prop {#1}
\ArgumentSpecification
{ \tl_show:N \ArgumentSpecification }
- {
- \__msg_kernel_error:nnx { xparse } { unknown-document-environment }
- { \tl_to_str:n {#1} }
- }
+ { \@@_get_arg_spec_error:n {#1} }
}
% \end{macrocode}
% \end{macro}
@@ -3354,6 +3363,18 @@
'#1'.~LaTeX~did~not~find~it,~and~will~insert~'#2'~as~the~value~to~be~
processed.
}
+\__msg_kernel_new:nnnn { xparse } { non-xparse-command }
+ { Command~'#1'~not~defined~using~xparse. }
+ {
+ You~have~asked~for~the~argument~specification~for~a~command~'#1',~
+ but~this~is~not~a~command~defined~using~xparse.
+ }
+\__msg_kernel_new:nnnn { xparse } { non-xparse-environment }
+ { Environment~'#1'~not~defined~using~xparse. }
+ {
+ You~have~asked~for~the~argument~specification~for~an~environment~'#1',~
+ but~this~is~not~an~environment~defined~using~xparse.
+ }
\__msg_kernel_new:nnnn { xparse } { not-single-token }
{ Argument~delimiter~should~be~a~single~token:~'#1'. }
{
@@ -3383,17 +3404,17 @@
The~letter~'#1'~does~not~specify~a~known~argument~type.~
LaTeX~will~assume~you~want~a~standard~mandatory~argument~(type~'m').
}
-\__msg_kernel_new:nnnn { xparse } { unknown-document-command }
+\__msg_kernel_new:nnnn { xparse } { unknown-command }
{ Unknown~document~command~'#1'. }
{
You~have~asked~for~the~argument~specification~for~a~command~'#1',~
- but~this~is~not~a~document~command.
+ but~it~is~not~defined.
}
-\__msg_kernel_new:nnnn { xparse } { unknown-document-environment }
+\__msg_kernel_new:nnnn { xparse } { unknown-environment }
{ Unknown~document~environment~'#1'. }
{
- You~have~asked~for~the~argument~specification~for~a~command~'#1',~
- but~this~is~not~a~document~environment.
+ You~have~asked~for~the~argument~specification~for~an~environment~'#1',~
+ but~it~is~not~defined.
}
\__msg_kernel_new:nnnn { xparse } { verbatim-newline }
{ Verbatim~argument~of~'#1'~ended~by~end~of~line. }
More information about the latex3-commits
mailing list