# Is there a tutorial on writing messages from expl3?

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.

• I'm not at all clear why you mention \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 at 16:32
• I mentioned \begin{body} because I get an error message if \msg_new:nnn precedes it. – shmuel Jun 19 at 16:05
• We are going to need a full example: expl3 is independent of LaTeX2e document structures – Joseph Wright Jun 19 at 16:36
• As an example, does \msg_line_context go in the \msg_new:nnn message text, as a parameter to \msg_error:nnn or somewhere else? – shmuel Jun 20 at 0:04

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 }

• 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 at 20:21
• @shmuel There's no tutorial in the sense we still have no 'Programming expl3' guide in that sense – Joseph Wright Jun 20 at 20:25