I'd like to use the message facilities of expl3, but the documentation for l3msg only gives the syntax. In particular, it does not explain which commands are only legal after \begin{body}, it does not provide context and it does not explain whether a command calling \msg_line_context will get the context from which it was called or the context in which it called \msg_line_context.
Asked
Active
Viewed 313 times
3
1 Answers
4
Each message in expl3 is given a name to allow the fixed text to be given independently of usage of the message. The idea is that at point-of-use one should not be giving the full text, only the name of the message and any dynamic content. Messages are created using \msg_new:nnnn (or \msg_new:nnn). Here, argument #3 is the text of the message which will be used every time. This text is expanded at point-of-use, so may include expandable material such as \msg_line_context:
\msg_new:nnn { mypkg } { mymsg }
{
You ~ did ~ something ~ wrong ~ \msg_line_context: \ %
The additional ~ detail ~ is ~ '#1'.
}
At point of use, the message can then be called, passing up to four arguments of 'information'. Those can be expanded before they are 'sent', so again can include the context, although normally that I think should be part of the fixed text
\msg_warning:nnn { mypkg } { mymsg } { \msg_line_context: }
\msg_warning:nnn { mypkg } { mymsg } { Some ~ more ~ tokens }
Joseph Wright
- 259,911
- 34
- 706
- 1,036
-
That still leaves my original question: is there a tutorial spelling out the use of the message package, as opposed to the syntax of each macro call? Thanks. – shmuel Jun 20 '19 at 20:21
-
2@shmuel There's no tutorial in the sense we still have no 'Programming
expl3' guide in that sense – Joseph Wright Jun 20 '19 at 20:25
\begin{body}, which is a LaTeX2e document command. Perhaps you misunderstand 'context' here: it's about the location in the input, not any LaTeX2e document structure. – Joseph Wright Jun 18 '19 at 16:32expl3is independent of LaTeX2e document structures – Joseph Wright Jun 19 '19 at 16:36