diff options
Diffstat (limited to 'Master/texmf-dist/source/latex-dev/base/lthooks.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex-dev/base/lthooks.dtx | 121 |
1 files changed, 100 insertions, 21 deletions
diff --git a/Master/texmf-dist/source/latex-dev/base/lthooks.dtx b/Master/texmf-dist/source/latex-dev/base/lthooks.dtx index 97edc2461a8..06a0e8258f6 100644 --- a/Master/texmf-dist/source/latex-dev/base/lthooks.dtx +++ b/Master/texmf-dist/source/latex-dev/base/lthooks.dtx @@ -31,8 +31,8 @@ %%% From File: lthooks.dtx % % \begin{macrocode} -\def\lthooksversion{v1.0s} -\def\lthooksdate{2022/01/06} +\def\lthooksversion{v1.0u} +\def\lthooksdate{2022/05/19} % \end{macrocode} % %<*driver> @@ -1378,7 +1378,7 @@ % in real documents. % % For example, \pkg{babel} may want to provide hooks such as -% \hook{babel/afterextras/\meta{language}}. Language support in +% \hook{babel/\meta{language}/afterextras}. Language support in % \pkg{babel} is often done through external language % packages. Thus doing the activation for all languages inside the % core \pkg{babel} code is not a viable approach. Instead it needs @@ -1946,6 +1946,20 @@ % \end{description} % % +% +% \subsection{Hook provided by the mark mechanism} +% +% See \texttt{ltmarks-doc.pdf} for details. +% \begin{description} +% +% \item[\hook{insertmark}] +% +% This hook allows for a special setup while \cs{InsertMark} +% inserts a mark. It is executed in group so local changes only +% apply to the mark being inserted. +% +% \end{description} +% % \MaybeStop{\setlength\IndexMin{200pt} \PrintIndex } % % @@ -2182,7 +2196,6 @@ % \end{macro} % % -% % \subsection{Providing new hooks} % % \subsubsection{The data structures of a hook} @@ -3442,7 +3455,12 @@ } \tl_const:cn { c_@@_generic_env/./begin_tl } { + } \tl_const:cn { c_@@_generic_env/./end_tl } { + } +% \end{macrocode} +% +% \changes{v1.0t}{2022/04/01}{Support generic \texttt{include/.../excluded} hooks} +% \begin{macrocode} \tl_const:cn { c_@@_generic_include/./end_tl } { - } +\tl_const:cn { c_@@_generic_include/./excluded_tl } { + } % \end{macrocode} % % Deprecated generic hooks: @@ -3608,6 +3626,11 @@ % \end{macrocode} % % \begin{macrocode} +%<latexrelease>\IncludeInRelease{2022/06/01}{\@@_gset_rule:nnnn} +%<latexrelease> {Refuse~setting~rule~for~one-time~hooks} +% \end{macrocode} +% +% \begin{macrocode} \cs_new_protected:Npn \@@_gset_rule:nnnn #1#2#3#4 { \@@_if_deprecated_generic:nT {#1} @@ -3615,7 +3638,13 @@ \@@_deprecated_generic_warn:n {#1} \@@_do_deprecated_generic:Nn \@@_gset_rule:nnnn {#1} {#2} {#3} {#4} - \exp_after:wN \use_none:nnnnnnnnn \use_none:n + \@@_clean_to_scan:w + } + \@@_if_execute_immediately:nT {#1} + { + \msg_error:nnnnnn { hooks } { rule-too-late } + {#1} {#2} {#3} {#4} + \@@_clean_to_scan:w } % \end{macrocode} % First we ensure the basic data structure of the hook exists: @@ -3634,10 +3663,41 @@ {#1} {#2} {#4} \@@_update_hook_code:n {#1} } - { \msg_error:nnnnnn { hooks } { unknown-rule } - {#1} {#2} {#3} {#4} } + { + \msg_error:nnnnnn { hooks } { unknown-rule } + {#1} {#2} {#3} {#4} + } + \s_@@_mark } % \end{macrocode} +% +% \begin{macrocode} +%<latexrelease>\EndIncludeInRelease +%<latexrelease>\IncludeInRelease{2020/10/01}{\@@_gset_rule:nnnn} +%<latexrelease> {Refuse~setting~rule~for~one-time~hooks} +%<latexrelease>\cs_new_protected:Npn \@@_gset_rule:nnnn #1#2#3#4 +%<latexrelease> { +%<latexrelease> \@@_if_deprecated_generic:nT {#1} +%<latexrelease> { +%<latexrelease> \@@_deprecated_generic_warn:n {#1} +%<latexrelease> \@@_do_deprecated_generic:Nn \@@_gset_rule:nnnn {#1} +%<latexrelease> {#2} {#3} {#4} +%<latexrelease> \exp_after:wN \use_none:nnnnnnnnn \use_none:n +%<latexrelease> } +%<latexrelease> \@@_init_structure:n {#1} +%<latexrelease> \@@_rule_gclear:nnn {#1} {#2} {#4} +%<latexrelease> \cs_if_exist_use:cTF { @@_rule_#3_gset:nnn } +%<latexrelease> { +%<latexrelease> {#1} {#2} {#4} +%<latexrelease> \@@_update_hook_code:n {#1} +%<latexrelease> } +%<latexrelease> { +%<latexrelease> \msg_error:nnnnnn { hooks } { unknown-rule } +%<latexrelease> {#1} {#2} {#3} {#4} +%<latexrelease> } +%<latexrelease> } +%<latexrelease>\EndIncludeInRelease +% \end{macrocode} % \end{macro} % \end{macro} % @@ -3815,7 +3875,6 @@ % \end{macro} % % -% % \begin{macro}{\@@_initialize_hook_code:n} % Initializing or reinitializing the fast execution hook code. In % the preamble this is selectively done in case a hook gets used @@ -3824,8 +3883,8 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_initialize_hook_code:n #1 { - \@@_debug:n{ \iow_term:x{^^JUpdate~ code~ for~ hook~ - '#1' \on@line :^^J} } + \@@_debug:n + { \iow_term:x { ^^J Update~code~for~hook~'#1' \on@line :^^J } } % \end{macrocode} % This does the sorting and the updates. % First thing we do is to check if a legacy hook macro exists and @@ -3843,6 +3902,7 @@ % \cs{@@_initialize_single:NNn} and pass to it ready made csnames % as they are needed several times inside. This way we save a bit % on processing time if we do that up front. +% \changes{v1.0u}{2022/05/17}{Refuse sorting one-time hooks (gh/818).} % \begin{macrocode} \@@_if_usable:nT {#1} { @@ -3857,7 +3917,7 @@ { % \end{macrocode} % By default the algorithm sorts the code chunks and then saves the -% result in a token list for fast execution; this is done by adding the code chunks +% result in a token list for fast execution; this is done by adding the code chunks % one after another, using \cs{tl_gput_right:NV}. When we sort code for % a reversed hook, all we have to do is to add the code chunks in % the opposite order into the token list. So all we have to do @@ -3886,8 +3946,8 @@ % i.e., we are only interested in storing the keys and the value is % arbitrary. % \begin{macrocode} - \@@_debug:n{ \exp_args:NNx \prop_gput:Nnn - \g_@@_used_prop {#1}{} } + \@@_debug:n + { \exp_args:NNx \prop_gput:Nnn \g_@@_used_prop {#1} { } } } } } @@ -4304,16 +4364,17 @@ % \@@_apply_-rule_>:nnn, % \@@_apply_-rule_<-:nnn, % \@@_apply_-rule_->:nnn, -% \@@_apply_-rule_x:nnn, +% \@@_apply_-rule_xW:nnn, +% \@@_apply_-rule_xE:nnn, % } % Reversed rules. % \begin{macrocode} -\cs_new_eq:cc { @@_apply_-rule_<:nnn } { @@_apply_rule_>:nnn } -\cs_new_eq:cc { @@_apply_-rule_>:nnn } { @@_apply_rule_<:nnn } +\cs_new_eq:cc { @@_apply_-rule_<:nnn } { @@_apply_rule_>:nnn } +\cs_new_eq:cc { @@_apply_-rule_>:nnn } { @@_apply_rule_<:nnn } \cs_new_eq:cc { @@_apply_-rule_<-:nnn } { @@_apply_rule_<-:nnn } \cs_new_eq:cc { @@_apply_-rule_->:nnn } { @@_apply_rule_->:nnn } -\cs_new_eq:cc { @@_apply_-rule_xE:nnn } { @@_apply_rule_xE:nnn } -\cs_new_eq:cc { @@_apply_-rule_xW:nnn } { @@_apply_rule_xW:nnn } +\cs_new_eq:cc { @@_apply_-rule_xE:nnn } { @@_apply_rule_xE:nnn } +\cs_new_eq:cc { @@_apply_-rule_xW:nnn } { @@_apply_rule_xW:nnn } % \end{macrocode} % \end{macro} % @@ -4831,6 +4892,7 @@ % clears the hook so that any further call to \cs{hook_use:n} or % \cs{hook_use_once:n} will expand to nothing. % \changes{v1.0r}{2021/09/06}{Clean up after \cs{UseOneTimeHook} (gh/606)} +% \changes{v1.0u}{2022/05/13}{Check if prop exists to avoid l3debug error} % \begin{macrocode} \cs_new_protected:Npn \@@_use_once_set:n #1 { \@@_tl_gset:cn { g_@@_#1_reversed_tl } { I } } @@ -4839,7 +4901,7 @@ \@@_tl_gclear:c { @@~#1 } \@@_tl_gclear:c { @@_next~#1 } \@@_tl_gclear:c { @@_toplevel~#1 } - \prop_gclear:c { g_@@_#1_code_prop } + \prop_gclear_new:c { g_@@_#1_code_prop } } % \end{macrocode} % \end{macro} @@ -4856,7 +4918,7 @@ % empty. % \changes{v1.0r}{2021/09/06}{Macro added (gh/606)} % \begin{macrocode} -\prg_new_conditional:Npnn \@@_if_execute_immediately:n #1 { F, TF } +\prg_new_conditional:Npnn \@@_if_execute_immediately:n #1 { T, F, TF } { \@@_if_usable:nTF {#1} { @@ -5097,7 +5159,8 @@ % % \begin{macrocode} \msg_new:nnnn { hooks } { unknown-rule } - { Unknown~ relationship~ '#3'~ + { + Unknown~ relationship~ '#3'~ between~ labels~ '#2'~ and~ '#4'~ \str_if_eq:nnF {#1} {??} { ~in~hook~'#1' }. ~ Perhaps~ a~ misspelling? @@ -5114,6 +5177,22 @@ % \end{macrocode} % % \begin{macrocode} +\msg_new:nnnn { hooks } { rule-too-late } + { + Sorting~rule~for~'#1'~hook~applied~too~late.\\ + Try~setting~this~rule~earlier. + } + { + You~tried~to~set~the~ordering~of~hook~'#1'~using\\ + \ \ \iow_char:N\\DeclareHookRule{#1}{#2}{#3}{#4}\\ + but~hook~'#1'~was~already~used~as~a~one-time~hook,~ + thus~sorting~is\\ + no~longer~possible.~Declare~the~rule~ + before~the~hook~is~used. + } +% \end{macrocode} +% +% \begin{macrocode} \msg_new:nnnn { hooks } { misused-top-level } { Illegal~use~of~\iow_char:N \\AddToHook{#1}[top-level]{...}.\\ |