|
31 | 31 | %%% From File: lthooks.dtx |
32 | 32 | % |
33 | 33 | % \begin{macrocode} |
34 | | -\def\lthooksversion{v1.0c} |
35 | | -\def\lthooksdate{2020/10/04} |
| 34 | +\def\lthooksversion{v1.0d} |
| 35 | +\def\lthooksdate{2020/10/09} |
36 | 36 | % \end{macrocode} |
37 | 37 | % |
38 | 38 | %<*driver> |
|
256 | 256 | % is used in a package/class, then the current |
257 | 257 | % package/class name is used, otherwise \hook{top-level} is used. |
258 | 258 | % |
| 259 | +% If the code for that \meta{label} wasn't yet added to the |
| 260 | +% \meta{hook}, an order is set so that when some code attempts to add |
| 261 | +% that label, the removal order takes action and the code is not |
| 262 | +% added. |
| 263 | +% |
259 | 264 | % If the optional argument is \texttt{*}, then all code chunks are |
260 | 265 | % removed. This is rather dangerous as it drops code from other |
261 | 266 | % packages one may not know about! |
|
648 | 653 | % |
649 | 654 | % \cs{LogHook} prints the information to the |.log| file, and |
650 | 655 | % \cs{ShowHook} prints them to the terminal/command window and starts |
651 | | -% \TeX's prompt (only if \cs{errorstopmode}) to wait for user action. |
| 656 | +% \TeX's prompt (only in \cs{errorstopmode}) to wait for user action. |
652 | 657 | % |
653 | 658 | % The \meta{hook} can be specified using the dot-syntax to denote |
654 | 659 | % the current package name. See section~\ref{sec:default-label}. |
| 660 | +% |
| 661 | +%^^A % Code for the listing below: |
| 662 | +%^^A \NewHook{example-hook} |
| 663 | +%^^A \AddToHook{example-hook}[foo]{[code from package 'foo']} |
| 664 | +%^^A \AddToHook{example-hook}[bar]{[from package 'bar']} |
| 665 | +%^^A \AddToHook{example-hook}[baz]{[package 'baz' is here]} |
| 666 | +%^^A \AddToHookNext{example-hook}{[one-time code]} |
| 667 | +%^^A \DeclareHookRule{example-hook}{baz}{before}{foo} |
| 668 | +%^^A \DeclareDefaultHookRule{bar}{after}{baz} |
| 669 | +%^^A \ShowHook{example-hook} |
| 670 | +% |
| 671 | +% \def\theFancyVerbLine{\textcolor[gray]{0.5}{%^^A |
| 672 | +% \sffamily\tiny\arabic{FancyVerbLine}}} |
| 673 | +% |
| 674 | +% \bigskip |
| 675 | +% Suppose a hook \texttt{example-hook} whose output of |
| 676 | +% \cs{ShowHook}|{example-hook}| is: |
| 677 | +% \begin{verbatim}[numbers=left] |
| 678 | +% -> The hook 'example-hook': |
| 679 | +% > Code chunks: |
| 680 | +% > foo -> [code from package 'foo'] |
| 681 | +% > bar -> [from package 'bar'] |
| 682 | +% > baz -> [package 'baz' is here] |
| 683 | +% > Extra code for next invocation: |
| 684 | +% > -> [one-time code] |
| 685 | +% > Rules: |
| 686 | +% > foo|baz with relation > |
| 687 | +% > baz|bar with default relation < |
| 688 | +% > Execution order (after applying rules): |
| 689 | +% > bar, baz, foo. |
| 690 | +% \end{verbatim} |
| 691 | +% |
| 692 | +% In the listing above, lines~3 to~5 show the three code chunks added |
| 693 | +% to the hook and their respective labels in the format |
| 694 | +% \begin{quote} |
| 695 | +% \quad \meta{label}\verb| -> |\meta{code} |
| 696 | +% \end{quote} |
| 697 | +% |
| 698 | +% Line~7 shows the code chunk for the next execution of the hook in |
| 699 | +% the format |
| 700 | +% \begin{quote} |
| 701 | +% \quad \verb|-> |\meta{next-code} |
| 702 | +% \end{quote} |
| 703 | +% This code will be used and disappear at the next |
| 704 | +% \verb|\UseHook{example-hook}|, in contrast to the chunks mentioned |
| 705 | +% earlier, which can only be removed from that hook by doing |
| 706 | +% \verb|\RemoveFromHook{|\meta{label}|}[example-hook]|. |
| 707 | +% |
| 708 | +% Lines~9 and~10 show the rules declared that affect this hook in the |
| 709 | +% format |
| 710 | +% \begin{quote} |
| 711 | +% \quad \meta{label-1}\verb+|+\meta{label-2}| with |%^^A |
| 712 | +% \meta{\texttt{default}?}| relation |\meta{relation} |
| 713 | +% \end{quote} |
| 714 | +% which means that the \meta{relation} applies to \meta{label-1} and |
| 715 | +% \meta{label-2}, in that order, as detailed in \cs{DeclareHookRule}. |
| 716 | +% If the relation is \texttt{default} it means that that rule applies |
| 717 | +% to \meta{label-1} and \meta{label-2} in \emph{all} hooks, (unless |
| 718 | +% overrided by a non-default relation). |
| 719 | +% |
| 720 | +% Finally, line~12 lists the labels in the hook after sorting; |
| 721 | +% that is, in the order they will be executed when the hook is used. |
655 | 722 | % \end{function} |
656 | 723 | % |
657 | 724 | % |
|
0 commit comments