Debian Codegraph @

texmf-dist/source/latex/silence/silence-doc.dtx

raw
1 % \iffalse meta-comment
2 % $Id:: silence-doc.dtx 10 2012-07-02 12:24:42Z mhp $
3 % ******************************************************************************
4 % ******************************************************************************
5 % ** **
6 % ** silence v1.5b by Michael Pock **
7 % ** See the documentation for a comment on the implementation. **
8 % ** **
9 % ** This set of macros is published under the LaTeX Project Public License. **
10 % ** **
11 % ** Comments, suggestions and bugs: **
12 % ** **
13 % ** mhp77 <at> gmx <dot> at **
14 % ** **
15 % ** Enjoy! **
16 % ** **
17 % ******************************************************************************
18 % ******************************************************************************
19 % \fi
20
21 % \iffalse
22 %<package>\NeedsTeXFormat{LaTeX2e}
23 %<package>\ProvidesPackage{silence}[2012/07/02 v1.5b Selective filtering of warnings and error messages]
24 %<*driver>
25 \documentclass[a4paper]{ltxdoc}
26 \usepackage{lmodern}
27 \usepackage[T1]{fontenc}
28 \usepackage{silence}
29 \usepackage[left=5cm,textwidth=14cm,textheight=23cm]{geometry}
30 \begin{document}
31 \DocInput{silence-doc.dtx}
32 \end{document}
33 %</driver>
34 % \fi
35 %
36 % \def\vbskip{\vskip.5em\noindent}
37 % \WarningFilter{latex}{Marginpar on page}
38 % \MakeShortVerb{"}
39 % \def\vbopt#1{\noindent\llap{\textbf{#1}\enspace}\ignorespaces}
40 % \GetFileInfo{silence.sty}
41 % \title{Filtering messages with "silence"\\\Large\fileversion}
42 % \date{\filedate}
43 % \author{Author: Paul Isambert\\Maintainer: Michael Pock\\"mhp77 <at> gmx <dot> at"}
44 %
45 % \maketitle
46 % \vskip1em
47 % \bgroup
48 % \raggedleft
49 % \small
50 % \textit{`Errare humanum est, perseverare diabolicum.'}\\ Proverb (attributed to Seneca)
51 %
52 % \textit{`Marginpar on page 3 moved.'}\\\LaTeX
53 %
54 % \egroup
55 % \vskip3em
56 %
57 %\begin{abstract}
58 %This package is designed to filter out unwanted warnings
59 %and error messages. Entire packages (including \LaTeX)
60 %can be censored, but very specific messages can be
61 %targeted too. \TeX's messages are left untouched.
62 %\end{abstract}
63 %
64 %
65 % \tableofcontents\clearpage
66 %
67 %\setcounter{section}{-1}
68 %
69 %\section{Changes}
70 %\def\Change#1#2#3{\par\noindent\llap{\textbullet\ }\textbf{#1} (#2)\leaders\hbox{... }\hfill#3\par}
71 %
72 %\Change{v1.1}{2009/03/20}{Initial version}
73 %\Change{v1.2}{2009/04/02}{\texttt{LaTeX Font Warning}s can be filtered}
74 %\Change{v1.3}{2010/02/28}{Compatibility with Lua\TeX}
75 %\Change{v1.4}{2011/12/06}{Fixed the \texttt{\string\@gobbletwo} error}
76 %\Change{v1.4}{2012/01/26}{Fixed the \texttt{\string\@gobble} error (same as before, spotted with biblatex)}
77 %\Change{v1.5}{2012/07/01}{New maintainer: Michael Pock}
78 %\Change{v1.5a}{2012/07/02}{Improved compatibility with the "hyperref" package}
79 %\Change{v1.5b}{2012/07/02}{Improved "debrief" option code}
80 %
81 %\section{Introduction}
82 %When working with \LaTeX, messages are utterly important.
83 %
84 %Ok, this was the well-behaved \LaTeX\ user's offering to
85 %the gods. Now, the fact is, when processing long
86 %documents, repeated messages can really get boring,
87 %especially when there's nothing you can do about them.
88 %For instance, everybody knows the following:
89 %\vbskip
90 %\hfil\emph{Marginpar on page \emph{x} moved.}
91 %\vbskip
92 %When you encounter that message, it means that you
93 %have to keep in mind for the next compilations that
94 %`there is a warning that I can ignore,' which sounds
95 %pretty paradoxical. When your
96 %document is 5 pages long, it doesn't matter, but when
97 %you're typesetting a book-length text, it's different, because
98 %you can have tens of such messages. And if you're
99 %hacking around, error messages might also appear
100 %that you don't want to consider. This package is
101 %meant to filter out those unwanted messages.
102 %
103 %You probably know all there is to know about
104 %warnings and errors, in which case you may want
105 %to skip this paragraph. If you don't, here's some
106 %information. When \LaTeX\ processes your document,
107 %it produces error messages and warnings, and packages
108 %and the class you're using do too. Errors generally
109 %refer to wrong operations such that the desired result
110 %won't be attained, while warnings usually inform you
111 %that there might be unexpected but benign modifications.
112 %Those messages are sent to the "log" file along with
113 %other bits of information. You're probably using
114 %a \LaTeX-oriented text editor to create your document
115 %and at the end of a compilation, it certainly gives you
116 %the number of errors and warnings encountered.
117 %Hopefully, your editor also has a facility to browse
118 %errors and warnings. With "silence", unwanted messages
119 %won't appear anymore.
120 %
121 %Those messages always have one of the following structures:
122 %
123 %\vbskip
124 %"Package" \meta{Name of the package} "Error:" \meta{message text}
125 %\vbskip
126 %or
127 %\vbskip
128 %"Class" \meta{Name of the class} "Error:" \meta{message text}
129 %\vbskip
130 %or
131 %\vbskip
132 %"LaTeX Error:" \meta{message text}
133 %\vbskip
134 %Replace \emph{Error} with \emph{Warning} and you have
135 %warnings. The important part for "silence" is \meta{Name of the
136 %package} or \meta{Name of the class}, because the information
137 %is needed when filtering messages. In case of a \LaTeX\ message,
138 %\meta{Name of the package} is supposed to be "latex". In case
139 %of a `\texttt{LaTeX Font}' message, \meta{Name of the package}
140 %is "latexfont" by convention.
141 %For filters, \meta{message text} will be crucial too.
142 %
143 %If a message doesn't begin as above, but displays its text
144 %immediately, then it has been sent by \TeX; "silence" cannot
145 %filter it out, and anyway it would probably be a very bad
146 %idea. For instance, there's nothing you can do about
147 %something like:
148 %
149 %\vbskip
150 %"Missing number, treated as zero."
151 %\vbskip
152 %and the only thing you want to do is correct your mistake.
153 %
154 %Another very bad idea is to forget the following:
155 %\emph{"silence" does not fix anything}.
156 %
157 %
158 %
159 %\section{Usage}
160 %\subsection{Calling the package}
161 %
162 %The package may be called as any other
163 %package with:
164 %
165 %\vbskip
166 %"\usepackage"\oarg{options}"{silence}"
167 %\vbskip
168 %and as any other package it will be effective only
169 %after it has been called, which means that messages
170 %issued before will not be filtered. So put it at the
171 %very beginning of your preamble. However, if you also
172 %want to catch a message issued by the class when it
173 %is specified with "\documentclass", you can't say
174 %
175 %\vbskip
176 %"\usepackage"\oarg{options}"{silence}"\\
177 %\meta{filters}\\
178 %"\documentclass{article}"
179 %\vbskip
180 %but instead
181 %
182 %\vbskip
183 %"\RequirePackage"\oarg{options}"{silence}"\\
184 %\meta{filters}\\
185 %"\documentclass{article}"
186 %\vbskip
187 %because "\usepackage" is not allowed before
188 %"\documentclass". This way, you can filter for
189 %instance a warning issued by the "memoir" class
190 %according to which you don't have "ifxetex", although
191 %you have it...
192 %
193 %
194 %
195 %
196 %\subsection{The brutal way}
197 %
198 %\DescribeMacro{\WarningsOff\oarg{list}}\DescribeMacro{\WarningsOff*}
199 %\DescribeMacro{\ErrorsOff\oarg{list}}\DescribeMacro{\ErrorsOff*}
200 %There is one very simple and very effective way to
201 %get rid of messages: "\WarningsOff" and "\ErrorsOff". In their
202 %starred versions, no warning or error will make it to your log
203 %file. Without a star, and without argument either, they filter
204 %out all messages except \LaTeX's. Finally, you can specify
205 %a list of comma-separated packages whose messages you don't want.
206 % For that purpose, \LaTeX\ is considered a package whose name is "latex".
207 %For instance "\WarningsOff[superpack,packex]" will remove all
208 %warnings issued by the "superpack" and "packex" packages. Messages
209 %issued by classes are also accessible in the same way, so to
210 %avoid the warning mentioned above, you can say:
211 %
212 %\vbskip
213 %"\RequirePackage"\oarg{options}"{silence}"\\
214 %"\WarningsOff[memoir]"\\
215 %"\documentclass{memoir}"
216 %\vbskip%
217 %If you want to filter out \LaTeX's warnings only, you can
218 %say "\WarningsOff[latex]". Note that issuing "\WarningsOff[mypack]"
219 %after "\WarningsOff", for instance, is useless, because all
220 %warnings are already filtered out. But this won't be mentioned to you.
221 %And "silence" won't check either whether a censored package exists
222 %or not. So if you say "\WarningsOff[mypak]" and mean "\WarningsOff[mypack]",
223 %this will go unnoticed.
224 %
225 %\DescribeMacro{\WarningsOn\oarg{list}}\DescribeMacro{\ErrorsOn\oarg{list}}
226 %These commands allow messages to be output again. If there is no \meta{list},
227 %all packages are affected, otherwise only specified packages are affected.
228 %So, for instance
229 %
230 %\vbskip
231 %"\WarningsOff"\\
232 %"Blah blah blah..."\\
233 %"\WarningsOn[superpack,packex]"\\
234 %"Blah blah blah..."
235 %\vbskip
236 %will have all warnings turned off, except those issued by \LaTeX\ (because
237 %"\WarningsOff" has no star) and by "superpack" and "packex" in the second
238 %part of the document.
239 %
240 %Note that the command described in this section are independant of the
241 %filters described in the following one, and vice-versa. That is,
242 %"\WarningsOn" has no effect on the filters, and if you design a filter
243 %to avoid a specific message issued by, say, "superpack", "\WarningsOn[superpack]"
244 %will not deactivate that filter and that one message will still be
245 %filtered out.
246 %
247 %
248 %
249 %
250 %
251 %
252 %\subsection{The exquisite way}
253 %
254 %Turning off all messages might be enough in many cases, especially if
255 %you turn them on again rapidly, but it is a blunt approach and it can lead
256 %to unwanted results. So "silence" allows you to create filters to target
257 %specific messages.
258 %
259 %\DescribeMacro{\WarningFilter\oarg{family}\\\marg{package}\marg{message}}
260 %\DescribeMacro{\ErrorFilter\oarg{family}\\\marg{package}\marg{message}}
261 %These commands will filter out messages issued by \meta{package} and beginning with \meta{message}.
262 %The optional \meta{family} specification is used to create groups of filters
263 %that will be (de)activated together. If there is no family, the filter will be immediately
264 %active and you won't be able to turn if off. So, for instance:
265 %
266 %\vbskip
267 %"\WarningFilter{latex}{Marginpar on page}"
268 %\vbskip
269 %will filter out all \LaTeX\ warnings beginning with `"Marginpar on page"'. On the other
270 %hand,
271 %
272 %\vbskip
273 %"\WarningFilter[myfam]{latex}{Marginpar on page}"
274 %\vbskip
275 %will filter out those same warnings if and only if "myfam" filters are active (but
276 %see the "immediate" package option below).
277 %
278 %You can be quite specific with the text of the message. For instance,
279 %
280 %\vbskip
281 %"\WarningFilter{latex}{Marginpar on page 2 moved}"
282 %\vbskip
283 %will filter out marginpar warnings issued on page 2.
284 %
285 %In this version (contrary to the starred version below), \meta{message} should
286 %reproduce the (beginning of) the displayed message. For instance, suppose
287 %that you have the following error message:
288 %
289 %\vbskip
290 %"Package superpack Error: The command \foo should not be used here."
291 %\vbskip
292 %To filter it out, you can simply say:
293 %\vbskip
294 %"\ErrorFilter"\oarg{family}"{superpack}{The command \foo should not}"
295 %\vbskip
296 %although you might know that "superpack" didn't produce it so easily,
297 %but instead must have said something like:
298 %\vbskip
299 %"\PackageError{superpack}{The command \string\foo\space should not be used here}{}"
300 %\vbskip
301 %Here, you don't have to know how the message was produced, but simply what
302 %it looks like. The starred versions of those commands below work differently.
303 %
304 %\DescribeMacro{\ActivateWarningFilters\\\oarg{list}}
305 %\DescribeMacro{\ActivateErrorFilters\\\oarg{list}}
306 %These macros activate the filters which belong to the families specified
307 %in \meta{list}. If there is no such list, all filters are activated. Indeed,
308 %unless the "immediate" option is turned on (see below), filters are not active
309 %when created, except those that don't belong to a family. Note that \meta{list}
310 %contains the name of the family specified in "\WarningFilter"\oarg{family}\marg{package}\marg{message}
311 %(and similarly for "\ErrorFilter") and not the name of the package (i.e. \meta{package}),
312 %although you can freely use the same name for both. So for instance:
313 %
314 %\vbskip
315 %"\WarningFilter[myfam]{packex}{You can't do that}"\\
316 %"\ActivateWarningFilters[packex]"
317 %\vbskip
318 %will not activate the desired filter, but instead will try to activate the filters
319 %belonging to the "packex" family. If this family doesn't exist, you won't be warned.\footnote{You
320 %won't be warned either that the \texttt{packex} family will really be active, which
321 %means that if you create (warning) filters with that family name afterwards, they will
322 %take effect immediately, even if you're not in \texttt{immediate} mode.}
323 %So the proper way instead is:
324 %\vbskip
325 %"\WarningFilter[myfam]{packex}{You can't do that}"\\
326 %"\ActivateWarningFilters[myfam]"
327 %\vbskip
328 %Finally, if a filter is created while its family is active, it will be active itself
329 %from its creation.
330 %
331 %\DescribeMacro{\DeactivateWarningFilters\\\oarg{list}}
332 %\DescribeMacro{\DeactivateErrorFilters\\\oarg{list}}
333 %These are self-explanatory. Once again, if there is no list, all filters are
334 %deactivated. Note that the "immediate" option implicitly turns on families
335 %associated with the filters that are created, so:
336 %
337 %\vbskip
338 %"\WarningFilter[myfam]{packex}{You can't do that}"\\
339 %"\DeactivateWarningFilters[myfam]"\\
340 %"\WarningFilter[myfam]{superpack}{This is very bad}"
341 %\vbskip
342 %will make all filters belonging to "myfam" active if "immediate" is on.
343 %In this example, both filters will be active, although one might have
344 %intended only the second one to be.
345 %
346 %\DescribeMacro{\ActivateFilters\oarg{list}}
347 %\DescribeMacro{\DeactivateFilters\oarg{list}}
348 %I bet you know what I'm going to say. These two macros activate
349 %or deactivate all filters, or all filters belonging
350 %to the specified families in case there's an argument. So
351 %you can create error filters and warning filters with the
352 %same family name and control them all at once. Isn't it
353 %amazing? Note that, just like above, "\ActivateFilters[myfam]"
354 %won't complain if there's no "myfam" family, or if there's
355 %just a warning family and no error family, and so on and
356 %so forth.
357 %
358 %\DescribeMacro{\WarningFilter*\oarg{family}\\\marg{name}\marg{message}}
359 %\DescribeMacro{\ErrorFilter*\oarg{family}\\\marg{name}\marg{message}}
360 %These are the same as the starless versions above, except that they
361 %target the message not as it appears in the log file but as it was produced.
362 %For instance, suppose you have an undefined citation, that is you
363 %wrote "\cite{Spinoza1677}" and \LaTeX\ complains as follows:
364 %
365 %
366 %\vbskip
367 %\bgroup
368 %\hfuzz=1cm
369 %"LaTeX Warning: Citation `Spinoza1677' on page 4 undefined on input line 320."
370 %
371 %\egroup
372 %\vbskip
373 %You know you have to bring your bibliography up to date, but right now you're
374 %working on a terrific idea and you don't have time to waste. So you say:
375 %
376 %\vbskip
377 %"\WarningFilter{latex}{Citation `Spinoza1677'}"
378 %\vbskip
379 %and everything's ok (since you've turned on the "save" option---see below---you
380 %will not forget to fix that reference). So you go on but then, as you're
381 %trying to link string theory with german philology, you stumble on that
382 %paper with bold new ideas and tens of fascinating references that you can't
383 %read but definitely have to cite. As expected, \LaTeX\ will start whining,
384 %because it doesn't like undefined citations. How are you going to shut it up?
385 %You might try
386 %
387 %\vbskip
388 %"\WarningFilter{latex}{Citation}"
389 %\vbskip
390 %but that's dangerous because all warnings beginning with "Citation" will
391 %be filtered out, and maybe there are other types of messages which begin with
392 %"Citation" and that you don't want to avoid. So the solution is "\WarningFilter*".
393 %Indeed, you can say:
394 %
395 %\vbskip
396 %"\WarningFilter*{latex}{Citation `\@citeb' on page \thepage \space undefined}"
397 %\vbskip
398 %That is, you target the way the message was produced instead of the way it appears.
399 %Of course, you have to know how the message was produced, but that's easy to figure
400 %out. In case of a \LaTeX\ message, just check the source (available on the web). In
401 %case the message was issued by a package or a class, just give a look at the
402 %corresponding files.
403 %
404 %As a rule of thumb, remember that a command that appears verbatim in the message
405 %was probably prefixed with "\protect", "\noexpand" or "\string", and you can try
406 %them all. Commands that are expanded are likely to be followed by "\space", to avoid unwanted gobbling.
407 %So if a message says `"You can't use \foo here"', it is likely to be produced
408 %with `"You can't use \protect\foo here"'.
409 %
410 %Here's a comparison of starred and starless filters:
411 %
412 %\vbskip
413 %"\WarningFilter{latex}{Marginpar on page 3 moved}" will filter off marginpar
414 %warnings concerning page 3.
415 %\vbskip
416 %"\WarningFilter{latex}{Marginpar on page \thepage\space moved}" will be inefficient
417 %because it will search messages that actually look like the specified text.
418 %\vbskip
419 %"\WarningFilter*{latex}{Marginpar on page \thepage\space moved}" will filter off
420 %all marginpar warnings.
421 %\vbskip
422 %"\WarningFilter*{latex}{Marginpar on page 3 moved}" will miss everything because when
423 %the the warning is produced the page number is not specified.
424 %
425 %\DescribeMacro{\SafeMode}\DescribeMacro{\BoldMode}
426 %As you might have guessed, evaluating messages as they appear means expanding them.
427 %Normally, this should be harmless, but one never knows. So these two commands allow
428 %you to turn that process on and off. When you say "\SafeMode", messages are not
429 %expanded. In that case, starless filters might miss their goal if the message
430 %contains expanded material. Starred filters are unaffected. So if you encounter
431 %an avalanche of unexplained error messages, just try some "\SafeMode". "\BoldMode"
432 %is used to switch back to the default mode.
433 %
434 %This expansion process concerns messages, not filters. That is, there is no need
435 %to protect your filter definitions with "\SafeMode". Instead, use this command when
436 %you suspect that a message is being sent and "silence" gets everything wrong. Use
437 %"\BoldMode" to switch back to normal when messages are not troublesome anymore.
438 %Here's an example:
439 %
440 %\vbskip
441 %"\WarningFilter{latex}{Marginpar on page 3 moved}"\\
442 %"\WarningFilter*{latex}{Citation `\@citeb' undefined}"\\
443 %"..."\\
444 %"\SafeMode"\\
445 %"..."
446 %\bgroup\ttfamily\itshape\obeylines\parindent0pt%
447 %Here a strange message is being sent by the \emph{strangex} package.
448 %If \upshape"\SafeMode"\itshape\ was not active, we would be in big trouble.
449 %The \emph{Marginpar} warnings all go through, because our starless filter
450 %is too specific. Fortunately, the \emph{Citation} warnings are correctly
451 %avoided.
452 %"..."
453 %\egroup
454 %\noindent"\BoldMode"\\
455 %"..."\\
456 %\texttt{\emph{Everything is back to normal.}}
457 %\vbskip
458 %
459 %
460 %\section{Package options}
461 %Here are the options that may be loaded with the package:
462 %
463 %\vbskip
464 %\vbopt{debrief} At the end of the document, "silence" will output a
465 %warning saying how many messages were issued during the compilation
466 %and how many were filtered out. This warning will not appear if
467 %no message was output or if none were filtered out.
468 %
469 %\vbopt{immediate} Makes filters active as soon as they are created.
470 %This does not affect filters created without a family, since they
471 %always behave so. If a filter is created with family "myfam", and
472 %if that family has been previously deactivated, it will be reactivated.
473 %
474 %\vbopt{safe} Makes safe mode the default mode. "\BoldMode" and "\SafeMode"
475 %are still available.
476 %
477 %\vbopt{save} Messages that were filtered out are written to an
478 %external file called "jobname.sil".
479 %
480 %\vbopt{saveall} All messages, including those that were left untouched,
481 %are written to "jobname.sil".
482 %
483 %\vbopt{showwarnings} Warnings are left untouched. That is, "silence"'s
484 %commands become harmless. Note that warnings are not written to
485 %"jobname.sil", even if the "saveall" option is loaded. This command
486 %is useful if you want to recompile your document as usual.
487 %
488 %\vbopt{showerrors} Same as "showwarnings" for errors.
489 %
490 %
491 %
492 %\section{It doesn't work!}
493 %Messages can be tricky. This package was originally designed to take
494 %care of marginpar warnings, and I wanted to do something like:
495 %
496 %\vbskip
497 %"\WarningsOff*"\\
498 %"\marginpar{A marginpar that will move}"\\
499 %"\WarningsOn"
500 %\vbskip
501 %Unfortunately, this doesn't work. Indeed, marginpar warnings are not
502 %issued when the "\marginpar" command is used but at the output routine,
503 %that is when \LaTeX\ builds the page, which happens at some interesting
504 %breakpoint that you're not supposed to know. That's the reason why
505 %those messages must be filtered out with warnings that are always
506 %active. Of course, this means that you can't filter out just one
507 %particular marginpar warning, unless it's the only one on its page.
508 %
509 %
510 %Now, messages aren't always what they seem to be. More precisely,
511 %two attributes do not really belong to them: the final full stop
512 %and the line number (only for some warnings). For instance, the following
513 %message \emph{does not} containt a full stop:
514 %\vbskip
515 %"Package packex Error: You can't do that."
516 %\vbskip
517 %The full stop is added by \LaTeX. So
518 %\vbskip
519 %"\ErrorFilter{packex}{You can't do that.}"
520 %\vbskip
521 %won't do. You have to remove the stop. This goes the same with the
522 %phrase `\texttt{on input line} \meta{number}.' (including the stop once
523 %again). That is, the message
524 %\vbskip
525 %"Package superpack Warning: Something is wrong on input line 352."
526 %\vbskip
527 %was actually produced with
528 %\vbskip
529 %"\PackageWarning{superpack}{Something is wrong}"
530 %\vbskip
531 %The end of it was added by \LaTeX. You know what you have to do.
532 %Unfortunately, this means that warnings can't be filtered according
533 %to the line they refer to.
534 %
535 %Another difficulty concerns line breaking in messages. If a new line
536 %begins in a message, it was either explicitely created or it's a single
537 %line wrapped by your text editor. When properly written, messages use
538 %\LaTeX's "\MessageBreak" command to create new lines, which \LaTeX\
539 %formats as a nicely indented line with the name of the package at the
540 %beginning, between parentheses. So if you encounter such a display,
541 %you know that there's something more behind the scene. You have two
542 %solutions: either you make the text of your filter shorter than
543 %the first line, which in most cases will be accurate enough, or
544 %you use a starred filter and explicitely write "\MessageBreak".
545 %Unfortunately, you can't use "\MessageBreak" in a starless filter.
546 %Note that some stupid people (including the author of this package)
547 %sometimes use "^^J" instead of "\MessageBreak", which is a \TeX\
548 %construct to create a new line. In that case, the line break
549 %will be indistinguishable from a single line wrapped by your text
550 %editor (although no wrapping occur in the log file).
551 %
552 %The most efficient filters are the starred ones (unless
553 %you're aiming at a specific value for a variable) whose text has simply
554 %been pasted from the source. E.g., if "superpack" tells you:
555 %
556 %\vbskip
557 %"Package superpack Error: You can't use \@terrific@command in"\\
558 %"(superpack) a \@fantastic@environment, because"\\
559 %"(superpack) unbelievable@parameter is off".
560 %\vbskip
561 %this was probably produced with:
562 %\vbskip
563 %"\PackageError{superpack}{"\\
564 %" You can't use \protect\@terrific@command in\MessageBreak"\\
565 %" a \protect\@fantastic@environment, because\MessageBreak"\\
566 %" \superparameter\space is off}"\\
567 %" {}"
568 %\vbskip
569 %with "\superparameter" "\def"ined to "unbelievable@parameter"
570 %beforehand. So the simplest way to filter out such a message
571 %is to open "superpack.sty", look for it, and copy it as is
572 %in a starred filter.
573 %
574 %
575 %There remains one problematic case, if a primitive
576 %control sequence appears in the message to be avoided.
577 %Imagine for instance that a package sends the warning
578 %`"You can't use \def here"'. It will not be reachable
579 %with a starless filter, because the package may have
580 %said "\def" without any prefix, since primitive commands
581 %can be used as such in messages, where they appear verbatim.
582 %On the other hand, when you create a starless filter with
583 %a command in it, "silence" considers this command simply as a string
584 %of characters beginning with a backslash devoid of its
585 %usual `escapeness'---as are control sequences prefixed
586 %with "\protect", "\string" and "\noexpand" in messages. So
587 %"\def" won't be reached. A starred filter might do, but
588 %in this case you shouldn't prefix "\def" with any of the
589 %three commands just mentioned. Now if "\def" is the result
590 %of an expansion, you'll be forced to rely on the previous
591 %techniques. Fortunately, this is very rare.
592 %
593 %Now, in case there's a message you really can't reach, although
594 %you pasted it in your filter, just let me know: it's an opportunity
595 %to refine "silence".
596 %
597 %
598 %
599 %
600 %
601 %
602 % \section{Implementation}
603 % \subsection{Basic definitions}
604 % \MacrocodeTopsep.5em
605 % \def\macskip{\par\vskip-17.7pt\vskip0cm}
606 % \let\sldescribemacro\DescribeMacro
607 % \def\DescribeMacro{\noindent\sldescribemacro}
608 % The options only turn on some conditionals, except "save" and
609 % "saveall", which set the count "\sl@save", to be used
610 % in a "\ifcase" statement.
611 % \begin{macrocode}
612 \makeatletter
613
614 \newcount\sl@Save
615 \newif\ifsl@Debrief
616 \newif\ifsl@ShowWarnings
617 \newif\ifsl@ShowErrors
618 \newif\ifsl@Immediate
619 \newif\ifsl@SafeMode
620
621 \DeclareOption{debrief}{\sl@Debrieftrue}
622 \DeclareOption{immediate}{\sl@Immediatetrue}
623 \DeclareOption{safe}{\sl@SafeModetrue}
624 \DeclareOption{save}{\sl@Save1
625 \newwrite\sl@Write
626 \immediate\openout\sl@Write=\jobname.sil}
627 \DeclareOption{saveall}{\sl@Save2
628 \newwrite\sl@Write
629 \immediate\openout\sl@Write=\jobname.sil}
630 \DeclareOption{showwarnings}{\sl@ShowWarningstrue}
631 \DeclareOption{showerrors}{\sl@ShowErrorstrue}
632 \ProcessOptions\relax
633 % \end{macrocode}
634
635 % Here are the counts, token lists and conditionals, that
636 % will be used by warnings and errors.
637 % \begin{macrocode}
638 \newcount\sl@StateNumber
639 \newcount\sl@MessageCount
640 \newcount\sl@Casualties
641
642 \newtoks\sl@Filter
643 \newtoks\sl@Message
644 \newtoks\sl@UnexpandedMessage
645 \newtoks\sl@Mess@ge
646
647 \newif\ifsl@Check
648 \newif\ifsl@Belong
649 \newif\ifsl@KillMessage
650 \newif\ifsl@SafeTest
651 % \end{macrocode}
652
653 % And here are some keywords and further definitions.
654 % "\sl@PackageName" is used to identify the name of the
655 % package, but in case "\GenericError" or "\GenericWarning"
656 % were directly used, it would be undefined (or defined
657 % with the name of the last package that issued a message),
658 % which would lead to some trouble, hence its definition here.
659 % \begin{macrocode}
660 \def\sl@end{sl@end}
661 \def\sl@latex{latex}
662 \def\sl@Terminator{\sl@Terminator}
663 \gdef\sl@active{active}
664 \gdef\sl@safe{safe}
665 \gdef\sl@PackageName{NoPackage}
666 \def\SafeMode{\global\sl@SafeModetrue}
667 \def\BoldMode{\global\sl@SafeModefalse}
668 \def\sl@Gobble#1sl@end,{}
669 % \end{macrocode}
670
671 % \subsection{Warnings}
672 % Now these are the counts, token lists, conditionals and
673 % keywords specific to warnings. "sl@family" is
674 % actually the family of those familyless filters. It
675 % is made active as wanted.
676 % \begin{macrocode}
677 \newcount\sl@WarningCount
678 \newcount\sl@WarningNumber
679 \newcount\sl@WarningCasualties
680
681 \newtoks\sl@TempBOW
682 \newtoks\sl@BankOfWarnings
683
684 \newif\ifsl@WarningsOff
685 \newif\ifsl@NoLine
686
687 \expandafter\gdef\csname sl@family:WarningState\endcsname{active}
688 \def\sl@WarningNames{}
689 \def\sl@UnwantedWarnings{}
690 \def\sl@ProtectedWarnings{}
691 % \end{macrocode}
692
693 % \subsubsection{Brutal commands}
694 % \DescribeMacro{\WarningsOn}
695 % The basic mechanism behind "\WarningsOn" and "\WarningsOff"
696 % is a conditional, namely "\ifsl@WarningsOff". When a warning is sent,
697 % "silence" checks the value of this conditional and acts
698 % accordingly: if it is set to "true", then the warning is
699 % filtered out unless it belongs to the "\sl@ProtectedWarnings"
700 % list; if it is set to "false", the warning is output unless
701 % it belongs to the "\sl@UnwantedWarnings" list.
702 %
703 % Without argument, "\WarningsOn" empties both lists and sets
704 % this conditional to "false". (Emptying "\sl@ProtectedWarnings"
705 % is useless but it keeps the list clean.) If it has an argument,
706 % its behavior depends on the conditional; if it is set to
707 % "true", the argument is added to "\sl@ProtectedWarnings";
708 % otherwise, it is removed from "\sl@UnwantedWarnings".
709 %
710 % \begin{macrocode}
711 \def\WarningsOn{%
712 \@ifnextchar[%
713 {\ifsl@WarningsOff
714 \def\sl@next{\sl@Add\sl@ProtectedWarnings}%
715 \else
716 \def\sl@next{\sl@Remove\sl@UnwantedWarnings}%
717 \fi\sl@next}%
718 {\global\sl@WarningsOfffalse
719 \gdef\sl@ProtectedWarnings{}%
720 \gdef\sl@UnwantedWarnings{}}}
721 % \end{macrocode}
722
723 % \DescribeMacro{\WarningsOff}
724 % "\WarningsOff" does the same as "\WarningsOn", but in
725 % the other way. If it has no star and no argument,
726 % "\sl@ProtectedWarnings" is overwritten with only
727 % "latex" in it.
728 %
729 % \begin{macrocode}
730 \def\WarningsOff{%
731 \@ifstar
732 {\global\sl@WarningsOfftrue
733 \gdef\sl@UnwantedWarnings{}%
734 \gdef\sl@ProtectedWarnings{}}%
735 {\@ifnextchar[{%
736 \ifsl@WarningsOff
737 \def\sl@next{\sl@Remove\sl@ProtectedWarnings}%
738 \else
739 \def\sl@next{\sl@Add\sl@UnwantedWarnings}%
740 \fi\sl@next}%
741 {\global\sl@WarningsOfftrue
742 \gdef\sl@UnwantedWarnings{}%
743 \gdef\sl@ProtectedWarnings{latex,}}}}
744 % \end{macrocode}
745 %
746 % Note that the "\WarningsOn" and "\WarningsOff"
747 % don't really take any argument. If an opening bracket is
748 % present, they launch "\sl@Add" or "\sl@Remove" on the
749 % adequate list.
750
751 % \DescribeMacro{\sl@Add}
752 % "\sl@Add" is no more than an "\xdef" of the list
753 % on itself, plus the new item.
754 %
755 % \begin{macrocode}
756 \def\sl@Add#1[#2]{%
757 \xdef#1{#1#2,}}
758 % \end{macrocode}
759
760 % \DescribeMacro{\sl@Remove}
761 % "\sl@Remove" is slightly more complicated. It stores
762 % the items to be removed and then
763 % launches the recursive "\sl@@Remove" on the expanded list,
764 % with a terminator to stop it.
765 % When "\sl@@Remove" has done its job, the list will
766 % be "\let" to the new one.
767 %
768 % \begin{macrocode}
769 \def\sl@Remove#1[#2]{%
770 \def\sl@Items{#2}%
771 \def\sl@TempNewList{}%
772 \expandafter\sl@@Remove#1sl@end,%
773 \let#1\sl@TempNewList}
774 % \end{macrocode}
775
776 % \DescribeMacro{\sl@@Remove}
777 % This macro takes each element of the list to
778 % be updated, checks it against the items to be
779 % removed, and builds a new list containing the element
780 % currently tested if and only if it has not been
781 % matched with items to be removed.
782 %
783 % First, we check the current element of the list,
784 % and if it's the terminator we end recursion.
785 %
786 % \begin{macrocode}
787 \def\sl@@Remove#1,{%
788 \def\sl@Tempa{#1}%
789 \ifx\sl@Tempa\sl@end
790 \let\sl@next\relax
791 % \end{macrocode}
792 %
793 % \noindent Otherwise, we launch "\sl@ListCheck" on the element.
794 %
795 % \begin{macrocode}
796 \else
797 \sl@Checkfalse
798 \expandafter\sl@ListCheck\sl@Items,sl@end,%
799 % \end{macrocode}
800 %
801 % \noindent If the check is positive, we do nothing. If not,
802 % we add the element to "\sl@TempNewList", which is
803 % itself repeated to keep the former elements.
804 %
805 % \begin{macrocode}
806 \ifsl@Check
807 \else
808 \xdef\sl@TempNewList{\sl@TempNewList#1,}%
809 \fi
810 \let\sl@next\sl@@Remove
811 \fi\sl@next}%
812 % \end{macrocode}
813
814 % \DescribeMacro{\sl@ListCheck}
815 % Here's the internal checking mechanism. It takes an argument
816 % (from the expansion of "\sl@Items" above) and compares
817 % it to the element under scrutiny. In case they match,
818 % the proper conditional is turned to "true", and we
819 % launch "\sl@Gobble" to discard remaining items. Otherwise,
820 % we proceed to the next item.
821 %
822 % First we check for the terminator, as usual, and
823 % the recursion is ended in case we find it.
824 %
825 % \begin{macrocode}
826 \def\sl@ListCheck#1,{%
827 \def\sl@Tempb{#1}%
828 \ifx\sl@Tempb\sl@end
829 \let\sl@next\relax
830 % \end{macrocode}
831 %
832 % \noindent If the item is not the terminator,
833 % we compare it to the current element. If they
834 % match, we confirm the test and gobble.
835 %
836 % \begin{macrocode}
837 \else
838 \ifx\sl@Tempa\sl@Tempb
839 \sl@Checktrue
840 \let\sl@next\sl@Gobble
841 % \end{macrocode}
842 %
843 % \noindent Otherwise we repeat.
844 %
845 % \begin{macrocode}
846 \else
847 \let\sl@next\sl@ListCheck
848 \fi
849 \fi\sl@next}
850 % \end{macrocode}
851
852 % \subsubsection{Filters}
853 % \DescribeMacro{\WarningFilter}
854 % Let's now turn to filters.
855 % When created, each warning filter is associated
856 % with a "\sl@WarningNumber" to retrieve it and to specify its
857 % status. In case of "\WarningFilter*", this status, referred to
858 % with "\csname\the\sl@WarningNumber:WarningMode\endcsname" (i.e.
859 % "\"\meta{number}":WarningMode", where \meta{number} is the unique
860 % number associated with the filter), is
861 % set to ``"safe"''. Otherwise, we don't bother to define it,
862 % because when evaluated the above command will then be
863 % equal to "\relax" (as are all undefined commands called with
864 % "\csname... \endcsname").
865 % This will be checked in due time to know whether
866 % the expanded or the unexpanded version of the target message
867 % must be tested.
868 %
869 % \begin{macrocode}
870 \def\WarningFilter{%
871 \global\advance\sl@WarningNumber1
872 \@ifstar
873 {\expandafter\gdef\csname\the\sl@WarningNumber:WarningMode\endcsname{safe}%
874 \sl@WarningFilter}%
875 {\sl@WarningFilter}}
876 % \end{macrocode}
877
878 % \DescribeMacro{\sl@WarningFilter}
879 % Once the star has been checked, we look for an optional argument.
880 % In case there is none, we assign the "sl@family" to the filter.
881 %
882 % \begin{macrocode}
883 \def\sl@WarningFilter{%
884 \@ifnextchar[%
885 {\sl@@WarningFilter}%
886 {\sl@@WarningFilter[sl@family]}}
887 % \end{macrocode}
888
889 % \DescribeMacro{\sl@@WarningFilter}
890 % Here comes the big part. First, we update the list of
891 % filters associated with a package, stored in "\"\meta{package}"@WarningFilter".
892 % The list itself is a concatenation of comma-separated pairs of
893 % the form \meta{number}":sl@"\meta{family} referring to filters.
894 % When \meta{package} issues a warning, "silence" checks the filters
895 % contained in the associated list. \meta{number} is
896 % used to determine the "WarningMode" ("safe" or undefined, as noted above), so
897 % that the right test will be run, while \meta{family} is used
898 % to ensure that this family is active.
899 %
900 % First we update the list:
901 %
902 % \begin{macrocode}
903 \def\sl@@WarningFilter[#1]#2{%
904 \expandafter\ifx\csname #2@WarningFilter\endcsname\relax
905 \expandafter\xdef\csname #2@WarningFilter\endcsname{\the\sl@WarningNumber:sl@#1}%
906 \else
907 \expandafter\xdef\csname #2@WarningFilter\endcsname{%
908 \csname #2@WarningFilter\endcsname,\the\sl@WarningNumber:sl@#1}%
909 \fi
910 % \end{macrocode}
911 %
912 % \noindent Now, if "\"\meta{family}":WarningState" is undefined, this means
913 % that this is the first time we encounter that family. So we store
914 % its name, which will be useful for "\ActivateWarningFilters" and
915 % its deactivating counterpart.
916 %
917 % \begin{macrocode}
918 \expandafter\ifx\csname #1:WarningState\endcsname\relax
919 \sl@Add\sl@WarningNames[#1]%
920 \fi
921 % \end{macrocode}
922 %
923 % \noindent Next, we check "WarningState" again; if it's not active, we change it,
924 % depending on whether we're in "immediate" mode or not.
925 % \begin{macrocode}
926 \expandafter\ifx\csname #1:WarningState\endcsname\sl@active
927 \else
928 \ifsl@Immediate
929 \expandafter\gdef\csname #1:WarningState\endcsname{active}%
930 \else
931 \expandafter\gdef\csname #1:WarningState\endcsname{inactive}%
932 \fi
933 \fi
934 % \end{macrocode}
935 %
936 % \noindent Finally, we prepare the storage of the filter's message.
937 % We open a group, and if the filter is starred, we turn "@" into
938 % a letter, so that it will be able to form macro names.
939 % If the filter has no star, we turn the escape character into
940 % a normal one, so that control sequences won't be formed. Messages
941 % will then be tested token by token, and if a message contains e.g. "\foo",
942 % then it has (most likely) been "\string"'ed, so it's really a sequence of characters
943 % with "\catcode" 12 (including the escape character) that the starless
944 % filter will match.
945 % \begin{macrocode}
946 \begingroup
947 \expandafter\ifx\csname\the\sl@WarningNumber:WarningMode\endcsname\sl@safe
948 \makeatletter
949 \else
950 \catcode`\\12
951 \fi
952 \sl@AddToBankOfWarnings}
953 % \end{macrocode}
954
955 % \DescribeMacro{\sl@AddToBankOfWarnings}
956 % Now we add the filter to the "\sl@BankOfWarnings" token list,
957 % delimited by "(:sl@"\meta{number}":)", where \meta{number}
958 % is the number assigned to it above. Thus, it might be easily
959 % retrieved. Following a technique explained by Victor Eijkhout
960 % in \emph{\TeX\ by Topic}, we make use of "\edef" to add an item
961 % to a token list. First, we store it in the temporary "\sl@TempBOW"
962 % token list. Then we "\edef" "\sl@act" such that its definition
963 % will be:
964 %
965 % \vbskip
966 % "\sl@BankOfWarnings{"\meta{previous content}"(:sl@"\meta{number}":)"\meta{filter}"(:sl@"\meta{number}":)}"
967 % \vbskip
968 % Thus, the "\sl@BankOfWarnings" token list will add the new filter
969 % to itself. This works because token lists prefixed with "\the" in an "\edef"
970 % expand to their content unexpanded, unlike normal macros. The macro
971 % is made "\long" just in case.
972 %
973 % \begin{macrocode}
974 \long\def\sl@AddToBankOfWarnings#1{%
975 \sl@TempBOW{#1}%
976 \edef\sl@act{%
977 \global\noexpand\sl@BankOfWarnings{%
978 \the\sl@BankOfWarnings
979 (:sl@\the\sl@WarningNumber:)\the\sl@TempBOW(:sl@\the\sl@WarningNumber:)}}%
980 \sl@act
981 \endgroup}
982 % \end{macrocode}
983
984 % \DescribeMacro{\ActivateWarningFilters}
985 % \DescribeMacro{\DeactivateWarningFilters}
986 % This macro launches a recursive redefinition
987 % of its expanded argument, which is either a list
988 % defined by the user or the list containing
989 % all warning families (updated in "\WarningFilter"
990 % above). We set "\sl@StateNumber" to register
991 % what the redefinition should be: activate or deactivate "WarningState",
992 % or activate or deactivate "ErrorState".
993 %
994 % \begin{macrocode}
995 \def\ActivateWarningFilters{%
996 \sl@StateNumber0\relax
997 \@ifnextchar[%
998 {\sl@ChangeState}%
999 {\sl@ChangeState[\sl@WarningNames]}}
1000
1001 \def\DeactivateWarningFilters{%
1002 \sl@StateNumber1\relax
1003 \@ifnextchar[%
1004 {\sl@ChangeState}%
1005 {\sl@ChangeState[\sl@WarningNames]}}
1006 % \end{macrocode}
1007
1008 % \DescribeMacro{\sl@ChangeState}
1009 % \DescribeMacro{\sl@@ChangeState}
1010 % "\sl@ChangeState" only calls "\sl@@ChangeState" on
1011 % the expanded argument, adding a terminator.
1012 % "\sl@@ChangeState" checks whether its argument
1013 % is the terminator, in which case it stops, or else
1014 % it sets its state to the appropriate value, depending
1015 % on "\sl@StateNumber"
1016 %
1017 % \begin{macrocode}
1018 \def\sl@ChangeState[#1]{%
1019 \expandafter\sl@@ChangeState#1,sl@end,}
1020
1021 \def\sl@@ChangeState#1,{%
1022 \def\sl@Tempa{#1}%
1023 \ifx\sl@Tempa\sl@end
1024 \let\sl@next\relax
1025 \else
1026 \ifcase\sl@StateNumber
1027 \expandafter\gdef\csname #1:WarningState\endcsname{active}%
1028 \or
1029 \expandafter\gdef\csname #1:WarningState\endcsname{inactive}%
1030 \or
1031 \expandafter\gdef\csname #1:ErrorState\endcsname{active}%
1032 \or
1033 \expandafter\gdef\csname #1:ErrorState\endcsname{inactive}%
1034 \fi
1035 \let\sl@next\sl@@ChangeState
1036 \fi\sl@next}
1037 % \end{macrocode}
1038
1039 % \DescribeMacro{\ActivateFilters}
1040 % \DescribeMacro{\DeactivateFilters}
1041 % This aren't just shorthands, something more
1042 % is needed in case there's an argument (because we
1043 % have to retrieve it to pass it to two macros).
1044 % However, it's rather straightforward, we're just
1045 % using "\sl@StateNumber" to keep track of what
1046 % is needed.
1047 %
1048 % \DescribeMacro{\sl@RetrieveArgument}
1049 % Here we just rely on the value required for
1050 % "WarningState", i.e. 0 or 1, and the value
1051 % for "ErrorState" follows suit.
1052 %
1053 % \begin{macrocode}
1054 \def\ActivateFilters{%
1055 \@ifnextchar[%
1056 {\sl@StateNumber0
1057 \sl@RetrieveArgument}%
1058 {\sl@StateNumber0
1059 \sl@ChangeState[\sl@WarningNames]%
1060 \sl@StateNumber2
1061 \sl@ChangeState[\sl@ErrorNames]}}
1062
1063 \def\DeactivateFilters{%
1064 \@ifnextchar[%
1065 {\sl@StateNumber1
1066 \sl@RetrieveArgument}%
1067 {\sl@StateNumber1
1068 \sl@ChangeState[\sl@WarningNames]%
1069 \sl@StateNumber3
1070 \sl@ChangeState[\sl@ErrorNames]}}
1071
1072 \def\sl@RetrieveArgument[#1]{%
1073 \def\sl@Argument{#1}%
1074 \ifcase\sl@StateNumber
1075 \sl@ChangeState[\sl@Argument]%
1076 \sl@StateNumber2\relax
1077 \sl@ChangeState[\sl@Argument]%
1078 \or
1079 \sl@ChangeState[\sl@Argument]%
1080 \sl@StateNumber3\relax
1081 \sl@ChangeState[\sl@Argument]%
1082 \fi}
1083 % \end{macrocode}
1084
1085 %
1086 %
1087 % \subsubsection{String testing}
1088 % Now, here comes the crux of the biscuit, as some guitarist from
1089 % California once said. Here are the macros to test the messages.
1090 % They will be used in the redefinition of "\GenericWarning".
1091 %
1092 % \DescribeMacro{\sl@GetNumber}
1093 % When packages send a warning, "silence" launches "\sl@GetNumber"
1094 % on the expanded list of \meta{number}":sl@"\meta{family} pairs associated
1095 % with this package (created in "\WarningFilter" above). Remember that \meta{number}
1096 % refers to a filter and \meta{family} to its family.
1097 %
1098 % If \meta{number} is not 0 (which is associated with the terminator
1099 % added when "\sl@GetNumber" is launched),
1100 % we test whether the family is active. If so, "\sl@GetMessage" is
1101 % called; otherwise, we proceed to the next pair.
1102 %
1103 % The command
1104 % \vbskip
1105 % "\csname #2:\ifcase\sl@StateNumber Warning\or Error\fi State\endcsname"
1106 % \vbskip
1107 % reduces to "\"\meta{family}":WarningState" or "\"\meta{family}":ErrorState",
1108 % depending on the value of "\sl@StateNumber", which is turned
1109 % to 0 if we're testing a warning or to 1 if we're testing an error.
1110 %
1111 % \begin{macrocode}
1112 \def\sl@GetNumber#1:sl@#2,{%
1113 \ifnum#1>0
1114 \expandafter
1115 \ifx\csname #2:\ifcase\sl@StateNumber Warning\or Error\fi State\endcsname\sl@active
1116 \sl@GetMessage{#1}%
1117 \else
1118 \let\sl@next\sl@GetNumber
1119 \fi
1120 \else
1121 \let\sl@next\relax
1122 \fi\sl@next}
1123 % \end{macrocode}
1124
1125 % \DescribeMacro{\sl@GetMessage}
1126 % \noindent Now we're going to retrieve the filter from the "\sl@BankOfWarnings"
1127 % token list. This list has the following structure, as you might remember:
1128 % \vbskip
1129 % "(:sl@1:)"\meta{first filter}"(:sl@1:)(:sl@2:)"\meta{second filter}"(:sl@2:)...(:sl@n:)"\meta{\emph{n}th filter}"(:sl@n:)"
1130 % \vbskip
1131 % To do so, "\sl@GetMessage" defines a new macro on the fly, "\sl@@GetMessage",
1132 % which takes three arguments, delimited by "(:sl@"\meta{number}":)",
1133 % where \meta{numbers} depends on the pair we're in. That is, suppose
1134 % "\sl@GetNumber" is examining the pair "15:sl@myfam" and "myfam"
1135 % is active. Then we feed "15" to "\sl@GetMessage", which in turn
1136 % creates "\sl@@GetMessage" with the arguments delimited by "(:sl@15:)".
1137 % The first and the third arguments are discarded, while the second
1138 % one, which is the message of the filter, is stored in the "\sl@Filter"
1139 % token list, along with a terminator.
1140 %
1141 % \begin{macrocode}
1142 \def\sl@GetMessage#1{%
1143 \def\sl@@GetMessage##1(:sl@#1:)##2(:sl@#1:)##3(:sl@end:){\sl@Filter={##2\sl@Terminator}}%
1144 % \end{macrocode}
1145 %
1146 % \noindent Now we launch this command on the bank of warnings (or errors)
1147 % expanded one step, thanks to the same "\edef" trick as above.
1148 %
1149 % \begin{macrocode}
1150 \ifcase\sl@StateNumber
1151 \edef\sl@act{\noexpand\sl@@GetMessage\the\sl@BankOfWarnings(:sl@end:)}%
1152 \or
1153 \edef\sl@act{\noexpand\sl@@GetMessage\the\sl@BankOfErrors(:sl@end:)}%
1154 \fi
1155 \sl@act
1156 % \end{macrocode}
1157 %
1158 % \noindent When a warning is sent, its message is stored in two forms,
1159 % expanded and unexpanded. Depending on the mode we're currently in
1160 % (safe or bold), we retrieve the right form; in safe mode, we take
1161 % the unexpanded form; in bold mode, we take it too if the "WarningMode"
1162 % of this particular filter is "safe" (i.e. if it was created with
1163 % "\WarningFilter*"), otherwise we take the expanded version.
1164 %
1165 % "\sl@Message" is the token list containing the expanded version,
1166 % "\sl@UnexpandedMessage" contains the unexpanded version, and "\sl@Mess@ge"
1167 % stores the adequate version for the test to come followed by a terminator.
1168 %
1169 % At the end of this macro, we call the string tester.
1170 %
1171 % \begin{macrocode}
1172 \ifsl@SafeMode
1173 \sl@SafeTesttrue
1174 \edef\sl@act{\noexpand\sl@Mess@ge{\the\sl@UnexpandedMessage\noexpand\sl@Terminator}}%
1175 \else
1176 \expandafter
1177 \ifx\csname #1:\ifcase\sl@StateNumber Warning\or Error\fi Mode\endcsname\sl@safe%
1178 \sl@SafeTesttrue
1179 \edef\sl@act{\noexpand\sl@Mess@ge{\the\sl@UnexpandedMessage\noexpand\sl@Terminator}}%
1180 \else
1181 \sl@SafeTestfalse
1182 \edef\sl@act{\noexpand\sl@Mess@ge{\the\sl@Message\noexpand\sl@Terminator}}%
1183 \fi
1184 \fi
1185 \sl@act
1186 \sl@TestStrings}
1187 % \end{macrocode}
1188
1189 % \DescribeMacro{\sl@TestStrings}
1190 % This test is a recursive token by token comparison
1191 % of "\sl@Filter" and "\sl@Message", i.e. it compares
1192 % two strings.
1193 %
1194 % First we take the first token of each token list
1195 % thanks, once again, to an "\edef". They are stored
1196 % in "\sl@FilterToken" and "\sl@MessageToken", which
1197 % are macros, not token lists, by the way (see below
1198 % the definition of "\sl@Slice").
1199 %
1200 % \begin{macrocode}
1201 \def\sl@TestStrings{%
1202 \edef\sl@act{%
1203 \noexpand\sl@Slice\the\sl@Filter(:sl@mid:)\noexpand\sl@Filter\noexpand\sl@FilterToken
1204 \noexpand\sl@Slice\the\sl@Mess@ge(:sl@mid:)\noexpand\sl@Mess@ge\noexpand\sl@MessageToken}%
1205 \sl@act
1206 % \end{macrocode}
1207 %
1208 % \noindent Then we simply run some conditional.
1209 % If we reach the terminator in the filter, this means
1210 % that it matches the warning (otherwise we wouldn't have
1211 % gone so far), so we turn a very sad conditional to "true",
1212 % stop the recursion of "\sl@TestString" (thanks to "\sl@@next")
1213 % and gobble the remaining \meta{number}":sl@"\meta{family} pairs waiting to be evaluated
1214 % by "\sl@GetNumber" (thanks to "\sl@next"). Our job is done,
1215 % and "silence" grins with cruelty.
1216 %
1217 % \begin{macrocode}
1218 \ifx\sl@FilterToken\sl@Terminator
1219 \sl@KillMessagetrue
1220 \let\sl@@next\relax
1221 \let\sl@next\sl@Gobble
1222 % \end{macrocode}
1223 %
1224 % \noindent On the other hand, if we reach the terminator in the warning text,
1225 % this means that it is shorter than the filter (unless we also
1226 % reach the terminator in the filter, but this was taken care of
1227 % in the previous case), so they don't match. We stop recursion
1228 % (there's nothing left to test) and make "\sl@GetNumber" consider
1229 % the following pair.
1230 %
1231 % \begin{macrocode}
1232 \else
1233 \ifx\sl@MessageToken\sl@Terminator
1234 \let\sl@@next\relax
1235 \let\sl@next\sl@GetNumber
1236 % \end{macrocode}
1237 %
1238 % \noindent Now, if none of the tokens is a terminator, then we
1239 % have to compare them. The test will depend on the value
1240 % of "\ifsl@SafeTest" which was turned to "true" in case
1241 % we're in safe mode or the filter is a starred one. In that
1242 % case we run an "\ifx" test, so that even control sequences
1243 % can be properly compared. Since the message is not expanded,
1244 % this is vital. If the tokens match, we proceed to the next
1245 % ones; otherwise, this means that the filter and the message
1246 % are different, so we stop recursion (there's no reason to
1247 % test further), and we call "\sl@GetNumber" on the next pair.
1248 %
1249 % \begin{macrocode}
1250 \else
1251 \ifsl@SafeTest
1252 \ifx\sl@FilterToken\sl@MessageToken
1253 \let\sl@@next\sl@TestStrings
1254 \else
1255 \let\sl@@next\relax
1256 \let\sl@next\sl@GetNumber
1257 \fi
1258 % \end{macrocode}
1259 %
1260 % \noindent If we're in bold mode and the filter is starless,
1261 % then we simply compare character codes with "\if". Thus,
1262 % the letters of, say, "\foo", in the filter, will match
1263 % their counterpart in the warning (where the command has
1264 % probably been "\string"'ed), although their category codes
1265 % are different: it's 11 in the filter (no control sequence
1266 % was ever created: "\" was turned to a normal character
1267 % before the filter was stored) and 12 in the message
1268 % (like all "\string"'ed characters).
1269 %
1270 % \begin{macrocode}
1271 \else
1272 \if\sl@FilterToken\sl@MessageToken
1273 \let\sl@@next\sl@TestStrings
1274 \else
1275 \let\sl@@next\relax
1276 \let\sl@next\sl@GetNumber
1277 \fi
1278 \fi
1279 \fi
1280 \fi\sl@@next}
1281 % \end{macrocode}
1282
1283 % \DescribeMacro{\sl@Slice}
1284 % And here's the final cog in this testing. To put it quite
1285 % unintelligibly, "\sl@Slice" defines its fourth argument
1286 % to expand to the first, while the third, which is a
1287 % token list, is set to the second, and you should not
1288 % forget that the first two arguments are just an expansion
1289 % of the third. Copy that?
1290 %
1291 % Let's get things clear. Remember that "\sl@act" at the
1292 % beginning of "\sl@TestStrings" above was "\edef"ined to:
1293 % \vbskip
1294 % "\noexpand\sl@Slice\the\sl@Filter(:sl@mid:)\noexpand\sl@Filter\noexpand\sl@FilterToken"
1295 % \vbskip
1296 % and similarly for the message. This means that its definition
1297 % text is:
1298 % \vbskip
1299 % "\sl@Slice"\meta{content of $\backslash$\texttt{\emph{sl@Filter}}}"(:sl@mid:)\sl@Filter\sl@FilterToken"
1300 % \vbskip
1301 % The first argument of "\sl@Slice" is undelimited.
1302 % This means that it will be the first token of
1303 % \meta{content of $\backslash$\texttt{\emph{sl@Filter}}}.
1304 % Its second argument will be the rest of this content.
1305 % Now, as explained, "\sl@Slice" defines its fourth argument,
1306 % namely "\sl@FilterToken", to expand to its first one, namely
1307 % the first token in the "\sl@Filter" token list, and
1308 % sets this token list to the second argument, i.e. the to
1309 % rest of itself. In short, we're emptying "\sl@Filter" token by
1310 % token and we compare them along the way, as described above.
1311 %
1312 % \begin{macrocode}
1313 \def\sl@Slice#1#2(:sl@mid:)#3#4{\def#4{#1}#3={#2}}
1314 % \end{macrocode}
1315
1316 % \subsubsection{Redefining warnings}
1317 % \DescribeMacro{\sl@Belong}
1318 % We have two more macros to create before we can redefine
1319 % warnings themselves.
1320 % "\sl@Belong" is used to check whether a package belongs
1321 % to the "\sl@UnwantedWarnings" list or the "\sl@ProtectedWarnings" list
1322 % (correspondingly for errors). Its argument is an item of those lists
1323 % expanded, that is, the name of a package. It is
1324 % compared to "\sl@PackageName", which is defined
1325 % to the name of the package sending the message.
1326 % If they don't match, we relaunch the command on
1327 % the next item. If they do, we turn "\ifsl@Belong"
1328 % to "true" and gobble the following items.
1329 %
1330 % \begin{macrocode}
1331 \def\sl@Belong#1,{%
1332 \def\sl@Tempa{#1}%
1333 \ifx\sl@Tempa\sl@end
1334 \let\sl@next\relax
1335 \else
1336 \ifx\sl@Tempa\sl@PackageName
1337 \sl@Belongtrue
1338 \let\sl@next\sl@Gobble
1339 \else
1340 \let\sl@next\sl@Belong
1341 \fi
1342 \fi\sl@next}
1343 % \end{macrocode}
1344
1345 % \DescribeMacro{\sl@StoreMessage}
1346 % Finally, we need a mechanism to store the message
1347 % being sent. In safe mode, we store it unexpanded.
1348 % In bold mode, we also store it unexpanded for
1349 % starred filters, but we also store an expanded version
1350 % where "\protect" and "\noexpand" are "\let" to
1351 % "\string", so that the control sequences they
1352 % prefix will be turned into sequences of characters
1353 % (remember that no control sequence is formed in the
1354 % text of a starless filter, only strings of characters).
1355 % This expanded version is first stripped of a "\@gobbletwo"
1356 % suffix, if any, thus avoiding error when "\edef"ing.
1357 % (The "\@gobbletwo" occurs in some \LaTeX\ messages for
1358 % some obscure reason.) ... And at least in biblatex "\@gobble"
1359 % was also found, which also ruined everything, so it is removed
1360 % too if found at the end of a message.
1361 % We do this in a group because, well, you know,
1362 % you shouldn't do that...
1363 %
1364 % \begin{macrocode}
1365 \def\sl@RemoveGobble#1\@gobble\sl@Terminator#2\sl@Terminator{%
1366 \def\sl@Tempb{#2}%
1367 \ifx\sl@Tempb\@empty
1368 \else
1369 \def\sl@Tempa{#1}%
1370 \expandafter\@gobble
1371 \fi
1372 }
1373
1374 \def\sl@RemoveGobbletwo#1\@gobbletwo\sl@Terminator#2\sl@Terminator{%
1375 \def\sl@Tempb{#2}%
1376 \ifx\sl@Tempb\@empty
1377 \else
1378 \def\sl@Tempa{#1}%
1379 \expandafter\@gobble
1380 \fi
1381 }
1382
1383 \def\sl@StoreMessage#1{%
1384 \ifsl@SafeMode
1385 \sl@UnexpandedMessage{#1}%
1386 \else
1387 \sl@UnexpandedMessage{#1}%
1388 \begingroup
1389 \let\protect\string
1390 \let\noexpand\string
1391 \def\sl@Tempa{#1}%
1392 \sl@RemoveGobble#1\sl@Terminator\@gobble\sl@Terminator\sl@Terminator
1393 \sl@RemoveGobbletwo#1\sl@Terminator\@gobbletwo\sl@Terminator\sl@Terminator
1394 \edef\sl@Tempa{\sl@Tempa}%
1395 \global\expandafter\sl@Message\expandafter{\sl@Tempa}%
1396 \endgroup
1397 \fi}
1398 % \end{macrocode}
1399
1400 % Now we're ready for the big redefinitions.
1401 % First, if the "showwarnings" option is on, we
1402 % simply redefine nothing, otherwise we begin by retrieving the current definitions
1403 % of the commands used to issue warnings, in order
1404 % to patch them. For instance, we "\let" "\sl@PackageWarning"
1405 % to "\PackageWarning", and thus we'll be able to
1406 % write:
1407 %
1408 % \vbskip
1409 % "\def\PackageWarning#1#2{%"\\
1410 % " "\meta{additional code}\\
1411 % " \sl@PackageWarning{#1}{#2}}"
1412 % \vbskip
1413 % and this will launch "\sl@PackageWarning", i.e. the
1414 % original definition of "\PackageWarning", which will
1415 % do the job it was meant to do in the first place.
1416 %
1417 % For "\GenericWarning",
1418 % this needs some hacking. Indeed "\GenericWarning" is robust,
1419 % which means that it actually does nothing except
1420 % calling "\protect\GenericWarning"\meta{space}, where
1421 % "\GenericWarning"\meta{space} is defined to
1422 % issue the warning as wanted.
1423 % Thus, if we simply
1424 % "\let" "\sl@GenericWarning" to "\GenericWarning" and
1425 % write:
1426 %
1427 % \vbskip
1428 % "\DeclareRobustCommand{\GenericWarning}[2]{%"\\
1429 % " "\meta{additional code}\\
1430 % " \sl@GenericWarning{#1}{#2}}"
1431 % \vbskip
1432 % then, because of the robust declaration, "\GenericWarning"
1433 % will be defined to "\protect" "\GenericWarning"\meta{space},
1434 % whose definition is the additional code followed by
1435 % "\sl@GenericWarning" which, because it was "\let" to
1436 % the older version of "\GenericWarning", expands to
1437 % "\GenericWarning"\meta{space}---that is, we enter an
1438 % infinite loop. The solution is to "\let" "\sl@GenericWarning"
1439 % directly to "\GenericWarning"\meta{space}.
1440 %
1441 % \begin{macrocode}
1442 \ifsl@ShowWarnings
1443 \else
1444 \expandafter\let\expandafter\sl@GenericWarning\csname GenericWarning \endcsname
1445 \let\sl@PackageWarning\PackageWarning
1446 \let\sl@ClassWarning\ClassWarning
1447 \let\sl@latex@warning\@latex@warning
1448 \let\sl@font@warning\@font@warning
1449 % \end{macrocode}
1450
1451 % \DescribeMacro{\PackageWarning}
1452 % We redefine "\PackageWarning" so that it stores
1453 % the name of the package calling it, and the message only
1454 % if a certain conditional is true, that is if it
1455 % has not been sent with "\PackageWarningNoLine"
1456 %
1457 % \begin{macrocode}
1458 \def\PackageWarning#1#2{%
1459 \def\sl@PackageName{#1}%
1460 \ifsl@NoLine
1461 \sl@NoLinefalse
1462 \else
1463 \sl@StoreMessage{#2}%
1464 \fi
1465 \sl@PackageWarning{#1}{#2}}
1466 % \end{macrocode}
1467
1468 % \DescribeMacro{\PackageWarningNoLine}
1469 % For "\PackageWarningNoLine", we simply store the message
1470 % and send it to "\PackageWarning" with an additional "\@gobble"
1471 % to discard the `"on input line..."' phrase added by \LaTeX.
1472 % (This "\@gobble" was already in the original definition, there
1473 % is nothing new here.)
1474 %
1475 % \begin{macrocode}
1476 \def\PackageWarningNoLine#1#2{%
1477 \sl@StoreMessage{#2}%
1478 \sl@NoLinetrue
1479 \PackageWarning{#1}{#2\@gobble}}
1480 % \end{macrocode}
1481
1482 % \DescribeMacro{\ClassWarning}\DescribeMacro{\ClassWarningNoLine}
1483 % \DescribeMacro{\@latex@warning}\DescribeMacro{\@latex@warning@no@line}
1484 % \DescribeMacro{\@font@warning}
1485 % We do exactly the same for class warnings and \LaTeX\ warnings, except
1486 % that in the latter case we manually set "\sl@PackageName" to "latex".
1487 %
1488 % \begin{macrocode}
1489 \def\ClassWarning#1#2{%
1490 \def\sl@PackageName{#1}%
1491 \ifsl@NoLine
1492 \sl@NoLinefalse
1493 \else
1494 \sl@StoreMessage{#2}%
1495 \fi
1496 \sl@ClassWarning{#1}{#2}}
1497
1498 \def\ClassWarningNoLine#1#2{%
1499 \sl@StoreMessage{#2}%
1500 \sl@NoLinetrue
1501 \ClassWarning{#1}{#2\@gobble}}
1502
1503 \def\@latex@warning#1{%
1504 \def\sl@PackageName{latex}%
1505 \ifsl@NoLine
1506 \sl@NoLinefalse
1507 \else
1508 \sl@StoreMessage{#1}%
1509 \fi
1510 \sl@latex@warning{#1}}
1511
1512 \def\@latex@warning@no@line#1{%
1513 \sl@StoreMessage{#1}%
1514 \sl@NoLinetrue
1515 \@latex@warning{#1\@gobble}}
1516
1517 \def\@font@warning#1{%
1518 \def\sl@PackageName{latexfont}%
1519 \sl@StoreMessage{#1}%
1520 \sl@font@warning{#1}}
1521 % \end{macrocode}
1522
1523 % \DescribeMacro{\GenericWarning}
1524 % Now we can redefine "\GenericWarning". Originally, a message
1525 % sent with, for instance, "\PackageWarning", is edited, and sent to
1526 % "\GenericWarning", which edits it further and sends it to
1527 % the log file. None of this is modified here, although
1528 % some names have changed. Indeed, "\PackageWarning"
1529 % now stores the name of the package and the message
1530 % but then calls "\sl@PackageWarning" on them, which has
1531 % been "\let" to the previous value of "\PackageWarning".
1532 % So the message is formatted as usual and sent to
1533 % "\GenericWarning" which, if the message is not filtered out,
1534 % will launch "\sl@GenericWarning" on the same arguments
1535 % and thus \LaTeX's original mechanism will pass unaffected---albeit
1536 % somewhat spied upon... The original command is robust, so
1537 % we make it robust too.
1538 %
1539 % First, we increment "\sl@WarningCount", which will be used
1540 % if the "debrief" option is on. We also restore some conditional
1541 % to their default values.
1542 %
1543 % \begin{macrocode}
1544 \DeclareRobustCommand{\GenericWarning}[2]{%
1545 \global\advance\sl@WarningCount1
1546 \sl@KillMessagefalse
1547 \sl@Belongfalse
1548 % \end{macrocode}
1549 %
1550 % \noindent Next, we launch "\sl@Belong" on the expanded
1551 % list of protected warnings if warnings are off, or on
1552 % the expanded list of unwanted warnings if they're on. Depending
1553 % on the result (see the comment on "\WarningsOn" and "\WarningsOff"
1554 % above), we might sentence the message to death. (Turn on
1555 % the "save" option, please, so it may live a happy afterlife
1556 % in "jobname.sil".)
1557 %
1558 % \begin{macrocode}
1559 \ifsl@WarningsOff
1560 \expandafter\sl@Belong\sl@ProtectedWarnings sl@end,%
1561 \ifsl@Belong
1562 \else
1563 \sl@KillMessagetrue
1564 \fi
1565 \else
1566 \expandafter\sl@Belong\sl@UnwantedWarnings sl@end,%
1567 \ifsl@Belong
1568 \sl@KillMessagetrue
1569 \fi
1570 \fi
1571 % \end{macrocode}
1572 %
1573 % \noindent If the preceding operation is not enough,
1574 % we check whether some filters are associated with the
1575 % package sending the message (in which case "\"\meta{package}"@WarningFilter"
1576 % is defined and contains \meta{number}":sl@"\meta{family} pairs).
1577 % If there are some, we test them with "\sl@GetNumber" as defined above.
1578 %
1579 % \begin{macrocode}
1580 \ifsl@KillMessage
1581 \else
1582 \expandafter\ifx\csname\sl@PackageName @WarningFilter\endcsname\relax
1583 \else
1584 \sl@StateNumber0
1585 \expandafter\expandafter\expandafter
1586 \sl@GetNumber\csname\sl@PackageName @WarningFilter\endcsname,0:sl@sl@end,%
1587 \fi
1588 \fi
1589 % \end{macrocode}
1590 %
1591 % \noindent Now the message's fate is sealed. If it has
1592 % been doomed to filtering, we grimly step a sad sad counter.
1593 % Otherwise, we happily sends everything to "\sl@GenericWarning"
1594 % to enlighten the user's log file.
1595 %
1596 % \begin{macrocode}
1597 \ifsl@KillMessage
1598 \global\advance\sl@WarningCasualties1
1599 \else
1600 \sl@GenericWarning{#1}{#2}%
1601 \fi
1602 % \end{macrocode}
1603 %
1604 % \noindent Finally, we consider saving it. "\sl@Save" is 0
1605 % by default, 1 if the "save" option is on, and 2 if "saveall"
1606 % is on. We act accordingly: case 0 does nothing, case 1 sends
1607 % the message to "jobname.sil" if it has been filtered out,
1608 % and case 2 sends all messages. Instead of writing
1609 % everything out properly, we simply `re-route' "\sl@GenericWarning"
1610 % by "\let"ting "\@unused", \LaTeX's output stream, to "\sl@Write",
1611 % "silence"'s output stream directed to "jobname.sil". We do this
1612 % locally, of course.
1613 %
1614 % \begin{macrocode}
1615 \ifcase\sl@Save
1616 \or
1617 \ifsl@KillMessage
1618 \begingroup
1619 \let\@unused\sl@Write
1620 \sl@GenericWarning{#1}{#2}%
1621 \endgroup
1622 \fi
1623 \or
1624 \begingroup
1625 \let\@unused\sl@Write
1626 \sl@GenericWarning{#1}{#2}%
1627 \endgroup
1628 \fi
1629 % \end{macrocode}
1630 %
1631 % \noindent Before closing, we set "\sl@PackageName" to
1632 % "NoPackage", just in case (very unlikely, to be sure)
1633 % a package uses "\GenericWarning" directly. Thus, the
1634 % former value of "\sl@PackageName" won't interfere. The final
1635 % "\fi" matches "\ifsl@ShowWarnings" some hundred lines
1636 % above.
1637 %
1638 % \begin{macrocode}
1639 \gdef\sl@PackageName{NoPackage}}%
1640 \fi
1641 % \end{macrocode}
1642
1643
1644 % \subsection{Errors}
1645 % Errors are implemented just like warnings, so I don't
1646 % comment the code. See you at the end of the package
1647 % for the last macro.
1648 %
1649 % \begin{macrocode}
1650 \newcount\sl@ErrorCount
1651 \newcount\sl@ErrorNumber
1652 \newcount\sl@ErrorCasualties
1653
1654 \newtoks\sl@TempBOE
1655 \newtoks\sl@BankOfErrors
1656
1657 \newif\ifsl@ErrorsOff
1658
1659 \expandafter\gdef\csname sl@family:ErrorState\endcsname{active}
1660 \expandafter\gdef\csname sl@end:ErrorState\endcsname{active}
1661 \def\sl@ErrorNames{}
1662 \def\sl@UnwantedErrors{}
1663 \def\sl@ProtectedErrors{}
1664 % \end{macrocode}
1665
1666 % \DescribeMacro{\ErrorsOn}
1667 % \macskip
1668 % \begin{macrocode}
1669 \def\ErrorsOn{%
1670 \@ifnextchar[%
1671 {\ifsl@ErrorsOff
1672 \def\sl@next{\sl@Add\sl@ProtectedErrors}%
1673 \else
1674 \def\sl@next{\sl@Remove\sl@UnwantedErrors}%
1675 \fi\sl@next}%
1676 {\global\sl@ErrorsOfffalse
1677 \gdef\sl@ProtectedErrors{}%
1678 \gdef\sl@UnwantedErrors{}}}
1679 % \end{macrocode}
1680
1681 % \DescribeMacro{\ErrorsOff}
1682 % \macskip
1683 % \begin{macrocode}
1684 \def\ErrorsOff{%
1685 \@ifstar
1686 {\global\sl@ErrorsOfftrue
1687 \gdef\sl@UnwantedErrors{}%
1688 \gdef\sl@ProtectedErrors{}}%
1689 {\@ifnextchar[{%
1690 \ifsl@ErrorsOff
1691 \def\sl@next{\sl@Remove\sl@ProtectedErrors}%
1692 \else
1693 \def\sl@next{\sl@Add\sl@UnwantedErrors}%
1694 \fi\sl@next}%
1695 {\global\sl@ErrorsOfftrue
1696 \gdef\sl@UnwantedErrors{}%
1697 \gdef\sl@ProtectedErrors{latex,}}}}
1698 % \end{macrocode}
1699
1700 % \DescribeMacro{\ErrorFilter}
1701 % \DescribeMacro{\sl@ErrorFilter}
1702 % \DescribeMacro{\sl@@ErrorFilter}
1703 % \macskip
1704 % \begin{macrocode}
1705 \def\ErrorFilter{%
1706 \global\advance\sl@ErrorNumber1
1707 \@ifstar
1708 {\expandafter\gdef\csname\the\sl@ErrorNumber:ErrorMode\endcsname{safe}\sl@ErrorFilter}%
1709 {\sl@ErrorFilter}}
1710
1711 \def\sl@ErrorFilter{%
1712 \@ifnextchar[%
1713 {\sl@@ErrorFilter}%
1714 {\sl@@ErrorFilter[sl@family]}}
1715
1716 \def\sl@@ErrorFilter[#1]#2{%
1717 \expandafter\ifx\csname #2@ErrorFilter\endcsname\relax
1718 \expandafter\xdef\csname #2@ErrorFilter\endcsname{\the\sl@ErrorNumber:sl@#1}%
1719 \else
1720 \expandafter\xdef\csname #2@ErrorFilter\endcsname{%
1721 \csname #2@ErrorFilter\endcsname,\the\sl@ErrorNumber:sl@#1}%
1722 \fi
1723 \expandafter\ifx\csname #1:ErrorState\endcsname\relax
1724 \sl@Add\sl@ErrorNames[#1]%
1725 \fi
1726 \expandafter\ifx\csname #1:ErrorState\endcsname\sl@active
1727 \else
1728 \ifsl@Immediate
1729 \expandafter\gdef\csname #1:ErrorState\endcsname{active}%
1730 \else
1731 \expandafter\gdef\csname #1:ErrorState\endcsname{inactive}%
1732 \fi
1733 \fi
1734 \begingroup
1735 \expandafter\ifx\csname\the\sl@ErrorNumber:ErrorMode\endcsname\sl@safe
1736 \makeatletter
1737 \else
1738 \catcode`\\12
1739 \fi
1740 \sl@AddToBankOfErrors}
1741 % \end{macrocode}
1742
1743 % \DescribeMacro{\sl@AddToBankOfErrors}
1744 % \macskip
1745 % \begin{macrocode}
1746 \long\def\sl@AddToBankOfErrors#1{%
1747 \sl@TempBOE{#1}%
1748 \edef\sl@act{%
1749 \global\noexpand\sl@BankOfErrors{%
1750 \the\sl@BankOfErrors
1751 (:sl@\the\sl@ErrorNumber:)\the\sl@TempBOE(:sl@\the\sl@ErrorNumber:)}}%
1752 \sl@act
1753 \endgroup}
1754 % \end{macrocode}
1755
1756 % \DescribeMacro{\ActivateErrorFilters}
1757 % \macskip
1758 % \begin{macrocode}
1759 \def\ActivateErrorFilters{%
1760 \sl@StateNumber2
1761 \@ifnextchar[%
1762 {\sl@ChangeState}%
1763 {\sl@ChangeState[\sl@ErrorNames]}}
1764 % \end{macrocode}
1765
1766 % \DescribeMacro{\DeactivateErrorFilters}
1767 % \macskip
1768 % \begin{macrocode}
1769 \def\DeactivateErrorFilters{%
1770 \sl@StateNumber3
1771 \@ifnextchar[%
1772 {\sl@ChangeState}%
1773 {\sl@ChangeState[\sl@ErrorNames]}}
1774
1775 \ifsl@ShowErrors
1776 \else
1777 \expandafter\let\expandafter\sl@GenericError\csname GenericError \endcsname
1778 \let\sl@PackageError\PackageError
1779 \let\sl@ClassError\ClassError
1780 \let\sl@latex@error\@latex@error
1781 % \end{macrocode}
1782
1783 % \DescribeMacro{\PackageError}
1784 % \DescribeMacro{\ClassError}
1785 % \DescribeMacro{\@latex@error}
1786 % \macskip
1787 % \begin{macrocode}
1788 \def\PackageError#1#2#3{%
1789 \def\sl@PackageName{#1}%
1790 \sl@StoreMessage{#2}%
1791 \sl@PackageError{#1}{#2}{#3}}
1792
1793 \def\ClassError#1#2#3{%
1794 \def\sl@PackageName{#1}%
1795 \sl@StoreMessage{#2}%
1796 \sl@ClassError{#1}{#2}{#3}}
1797
1798 \def\@latex@error#1#2{%
1799 \def\sl@PackageName{latex}%
1800 \sl@StoreMessage{#1}%
1801 \sl@latex@error{#1}{#2}}
1802 % \end{macrocode}
1803
1804 % \DescribeMacro{\GenericError}
1805 % \macskip
1806 % \begin{macrocode}
1807 \DeclareRobustCommand{\GenericError}[4]{%
1808 \global\advance\sl@ErrorCount1
1809 \sl@KillMessagefalse
1810 \sl@Belongfalse
1811 \ifsl@ErrorsOff
1812 \expandafter\sl@Belong\sl@ProtectedErrors,sl@end,%
1813 \ifsl@Belong
1814 \else
1815 \sl@KillMessagetrue
1816 \fi
1817 \else
1818 \expandafter\sl@Belong\sl@UnwantedErrors,sl@end,%
1819 \ifsl@Belong
1820 \sl@KillMessagetrue
1821 \fi
1822 \fi
1823 \ifsl@KillMessage
1824 \else
1825 \expandafter\ifx\csname\sl@PackageName @ErrorFilter\endcsname\relax
1826 \else
1827 \sl@StateNumber1
1828 \expandafter\expandafter\expandafter
1829 \sl@GetNumber\csname\sl@PackageName @ErrorFilter\endcsname,0:sl@sl@end,%
1830 \fi
1831 \fi
1832 \ifsl@KillMessage
1833 \global\advance\sl@ErrorCasualties1
1834 \else
1835 \sl@GenericError{#1}{#2}{#3}{#4}%
1836 \fi
1837 \ifcase\sl@Save
1838 \or
1839 \ifsl@KillMessage
1840 \begingroup
1841 \let\@unused\sl@Write
1842 \sl@GenericError{#1}{#2}{#3}{#4}%
1843 \endgroup
1844 \fi
1845 \or
1846 \begingroup
1847 \let\@unused\sl@Write
1848 \sl@GenericError{#1}{#2}{#3}{#4}%
1849 \endgroup
1850 \fi
1851 \gdef\sl@PackageName{NoPackage}}%
1852 \fi
1853 % \end{macrocode}
1854 %
1855 % \subsection{Debrief}
1856 % Finally, at the end of the document, we
1857 % issue a debrief if the user requested it.
1858 %
1859 % A "\clearpage" is needed because we want
1860 % the final output routine to be processed so
1861 % we don't miss the last messages if there are
1862 % some.
1863 %
1864 % \begin{macrocode}
1865 \AtBeginDocument{%
1866 \AtEndDocument{%
1867 \ifsl@Debrief
1868 \clearpage
1869 % \end{macrocode}
1870 %
1871 % \noindent Then we do some arithmetics and if messages
1872 % appeared and some of them were filtered out,
1873 % we output the warning.
1874 %
1875 % And we say goodbye.
1876 %
1877 % \begin{macrocode}
1878 \sl@MessageCount\sl@WarningCount
1879 \advance\sl@MessageCount\sl@ErrorCount
1880 \sl@Casualties\sl@WarningCasualties
1881 \advance\sl@Casualties\sl@ErrorCasualties
1882 \ifnum\sl@MessageCount>0
1883 \ifnum\sl@Casualties>0
1884 \advance\sl@WarningCount-1
1885 \PackageWarningNoLine{silence}{%
1886 There were \the\sl@WarningCount\space warning(s)
1887 and \the\sl@ErrorCount\space error(s).\MessageBreak
1888 \ifnum\sl@Casualties=\sl@MessageCount
1889 None survived. This is a violent world%
1890 \else
1891 I've killed \the\sl@WarningCasualties\space warning(s)
1892 and \the\sl@ErrorCasualties\space error(s)%
1893 \fi}%
1894 \fi
1895 \fi
1896 \fi}}
1897
1898 \makeatother
1899 % \end{macrocode}