diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3msg.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3msg.dtx | 67 |
1 files changed, 56 insertions, 11 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3msg.dtx b/Master/texmf-dist/source/latex/l3kernel/l3msg.dtx index 7e23d67b838..635c1a0a827 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3msg.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3msg.dtx @@ -35,7 +35,7 @@ % %<*driver|package> \RequirePackage{l3names} -\GetIdInfo$Id: l3msg.dtx 2551 2011-08-11 22:40:53Z bruno $ +\GetIdInfo$Id: l3msg.dtx 2601 2011-08-16 23:20:27Z bruno $ {L3 Experimental messages} %</driver|package> %<*driver> @@ -624,6 +624,12 @@ % Issues an \enquote{Undefined error} message from \TeX{} itself, % and prints the \meta{error message}. The \meta{error message} % must be short: it is cropped at the end of one line. +% \begin{texnote} +% This function expands to an empty token list after two steps. +% Tokens inserted in response to \TeX{}'s prompt are read with +% the current category code setting, and inserted just after +% the place where the error message was issued. +% \end{texnote} % \end{function} % % \end{documentation} @@ -666,6 +672,7 @@ % \end{variable} % % \begin{macro}{\msg_new:nnnn, \msg_new:nnn} +% \begin{macro}{\msg_gset:nnnn,\msg_gset:nnn} % \begin{macro}{\msg_set:nnnn, \msg_set:nnn} % Setting a message simply means saving the appropriate text % into two functions. A sanity check first. @@ -677,7 +684,7 @@ \msg_kernel_error:nn { msg } { message-already-defined } {#1} {#2} } - \msg_set:nnnn {#1} {#2} + \msg_gset:nnnn {#1} {#2} } \cs_new_protected:Npn \msg_new:nnn #1#2#3 { \msg_new:nnnn {#1} {#2} {#3} { } } @@ -690,9 +697,19 @@ } \cs_new_protected:Npn \msg_set:nnn #1#2#3 { \msg_set:nnnn {#1} {#2} {#3} { } } +\cs_new_protected:Npn \msg_gset:nnnn #1#2#3#4 + { + \cs_gset:cpn { \c_msg_text_prefix_tl #1 / #2 } + ##1##2##3##4 {#3} + \cs_gset:cpn { \c_msg_more_text_prefix_tl #1 / #2 } + ##1##2##3##4 {#4} + } +\cs_new_protected:Npn \msg_gset:nnn #1#2#3 + { \msg_gset:nnnn {#1} {#2} {#3} { } } % \end{macrocode} % \end{macro} % \end{macro} +% \end{macro} % % \subsection{Messages: support functions and text} % @@ -863,8 +880,8 @@ % which is turned into a blank space. % \begin{macrocode} \group_begin: % { - \char_set_lccode:w `\} = `\ \scan_stop: - \char_set_lccode:w `\& = `\! \scan_stop: + \char_set_lccode:nn {`\}} {`\ } + \char_set_lccode:nn {`\&} {`\!} \char_set_catcode_active:N \& \tl_to_lowercase:n { @@ -1574,18 +1591,46 @@ % \subsection{Expandable errors} % % \begin{macro}{\msg_expandable_error:n} -% +% In expansion only context, we cannot use the normal means of +% reporting errors. Instead, we feed \TeX{} an undefined control +% sequence, \cs{LaTeX3 error:}. It is thus interrupted, and shows +% the context, which thanks to the odd-looking \cs{use:n} is +% \begin{verbatim} +% <argument> \LaTeX3 error: +% The error message. +% \end{verbatim} +% In other words, \TeX{} is processing the argument of \cs{use:n}, +% which is \cs{LaTeX3 error:} \meta{error message}. +% Then \cs{msg_expandable_error_aux:w} cleans up. In fact, there +% is an extra subtlety: if the user inserts tokens for error recovery, +% they should be kept. Thus we also use an odd space character +% (with category code $7$) and keep tokens until that space character, +% dropping everything else until \cs{q_stop}. The \cs{c_zero} prevents +% losing braces around the user-inserted text if any, and stops the +% expansion of \cs{tex_romannumeral:D}. % \begin{macrocode} \group_begin: -\cs_new:Npx \msg_expandable_error:n #1 +\char_set_catcode_math_superscript:N \^ +\char_set_lccode:nn {`^} {`\ } +\char_set_lccode:nn {`L} {`L} +\char_set_lccode:nn {`T} {`T} +\char_set_lccode:nn {`X} {`X} +\tl_to_lowercase:n { - \exp_not:n + \cs_new:Npx \msg_expandable_error:n #1 { - \exp_after:wN \exp_after:wN - \exp_after:wN \use_none_delimit_by_q_stop:w + \exp_not:n + { + \tex_romannumeral:D + \exp_after:wN \exp_after:wN + \exp_after:wN \msg_expandable_error_aux:w + \exp_after:wN \exp_after:wN + \exp_after:wN \c_zero + } + \exp_not:N \use:n { \exp_not:c { LaTeX3~error: } ^ #1 } + \exp_not:N \q_stop } - \exp_not:N \use:n { \exp_not:c { LaTeX3 ~ error : } #1 } - \exp_not:N \q_stop + \cs_new:Npn \msg_expandable_error_aux:w #1 ^ #2 \q_stop { #1 } } \group_end: % \end{macrocode} |