[latex3-commits] [git/LaTeX3-latex3-latex2e] lthooks2: fix github-0218 for luatex doc corrections lthooks (e2f37cf5)
Frank Mittelbach
frank.mittelbach at latex-project.org
Tue Aug 18 08:59:44 CEST 2020
Repository : https://github.com/latex3/latex2e
On branch : lthooks2
Link : https://github.com/latex3/latex2e/commit/e2f37cf5323bf33684e0797e30a06c2c50072ec1
>---------------------------------------------------------------
commit e2f37cf5323bf33684e0797e30a06c2c50072ec1
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date: Tue Aug 18 08:59:44 2020 +0200
fix github-0218 for luatex
doc corrections lthooks
>---------------------------------------------------------------
e2f37cf5323bf33684e0797e30a06c2c50072ec1
base/lthooks.dtx | 100 ++++++++++++++++++----------------
base/testfiles/github-0218.luatex.tlg | 2 +-
2 files changed, 54 insertions(+), 48 deletions(-)
diff --git a/base/lthooks.dtx b/base/lthooks.dtx
index b7ee9034..c86efe8f 100644
--- a/base/lthooks.dtx
+++ b/base/lthooks.dtx
@@ -1339,14 +1339,6 @@
% \subsection{Loading further extensions}
%
-% \changes{v1.5i}{2020-06-04}{Load \textsf{ltexpl} in \texttt{ltdefns}}
-% Simply load further code: it's deliberately separate.
-% This is done as soon as possible here in \texttt{ltdefns.dtx} so that
-% we have the extensions as soon as possible.
-% \begin{macrocode}
-%\input ltexpl.ltx
-% \end{macrocode}
-%
% \begin{macrocode}
%<@@=hook>
% \end{macrocode}
@@ -1574,6 +1566,10 @@
% The above is all in L3 convention, but we also provide an
% interface to legacy \LaTeXe{} for use in the current kernel. This
% is done in a separate macro.
+% \begin{quote}
+% \textbf{Warning: this support will vanish in future releases!}
+% \end{quote}
+%
% \begin{macrocode}
\@@_provide_legacy_interface:n {#1}
}
@@ -1635,7 +1631,11 @@
% following naming scheme in the code: \cs{@...hook}.
%
% We follow this convention and insert the hook code using this
-% naming scheme in \LaTeXe{}. At least as long as this code is in a
+% naming scheme in \LaTeXe{}.
+% \begin{quote}
+% \textbf{Warning: this support will vanish in future releases!}
+% \end{quote}
+% At least as long as this code is in a
% package, some such hooks are already filled with data when we move
% them over to the new scheme. We therefore insert already existing
% code under the label \texttt{legacy} into the hook management
@@ -1810,20 +1810,21 @@
\cs_generate_variant:Nn \@@_gput_code:nnn { nxv }
% \end{macrocode}
%
-% This macro will unconditionally add a chunk of code to the given hook.
+% This macro will unconditionally add a chunk of code to the given hook.
% \begin{macrocode}
\cs_new_protected:Npn \@@_hook_gput_code_do:nnn #1 #2 #3
{
-% However, first some debugging info if debugging is enabled:
+% \end{macrocode}
+% However, first some debugging info if debugging is enabled:
% \begin{macrocode}
\@@_debug:n{\iow_term:x{****~ Add~ to~
\hook_if_exist:nF {#1} { undeclared~ }
hook~ #1~ (#2)
\on at line\space <-~ \tl_to_str:n{#3}} }
% \end{macrocode}
-% Then try to get the code chunk labeled \verb=#2= from the hook.
-% If there's code already there, then append \verb=#3= to that,
-% otherwise just put \verb=#3=.
+% Then try to get the code chunk labeled \verb=#2= from the hook.
+% If there's code already there, then append \verb=#3= to that,
+% otherwise just put \verb=#3=.
% \begin{macrocode}
\prop_get:cnNTF { g_@@_#1_code_prop } {#2} \l_@@_return_tl
{
@@ -2228,10 +2229,10 @@
% \@@_rule_<_gset:nnn, \@@_rule_>_gset:nnn}
% Then we add the new rule. We need to normalize the rules here to
% allow for faster processing later. Given a pair of labels
-% $l_A$ and $l_B$, the rule $l_A>l_B$ is the same as $l_B<l_A$\fmi{}
-% said differently. But normalizing the
-% forms of the rule to a single representation, say, $l_B<l_A$, then
-% the time spent looking for the rules later is considerably reduced.
+% $l_A$ and $l_B$, the rule $l_A>l_B$ is the same as $l_B<l_A$
+% only presented differently. But bynormalizing the
+% forms of the rule to a single representation, say, $l_B<l_A$, reduces
+% the time spent looking for the rules later considerably.
%
% Here we do that normalization by using \cs[no-index]{(pdf)strcmp} to
% lexically sort labels $l_A$ and $l_B$ to a fixed order. This order
@@ -2384,7 +2385,6 @@
\exp_not:v {g_@@_##1_code_tl}~ }
}
}
-%
% \end{macrocode}
% After all hooks are initialized we change the ``use'' to just
% call the hook code and not initialize it (as it was done in the
@@ -2451,9 +2451,11 @@
% For debug display we want to keep track of those hooks that
% actually got code added to them, so we record that in plist. We
% use a plist to ensure that we record each hook name only once,
-% i.e., we are only interested in storing the keys and the value is arbitrary
+% 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}{} }
}
}
}
@@ -2836,10 +2838,12 @@
% \verb=#3= and carry on. We could do a little better and drop
% everything for that label since it doesn't matter where we sort
% in the empty code. However that would complicate the algorithm a
-% lot with little gain. So we still unnecessarily try to sort it in
-% and depending on the rules that might result in a loop that is
-% otherwise resolved. If that turns out to be a real issue, we can
-% improve the code.
+% lot with little gain.\footnote{This also hase the advantage that
+% the result of the sorting doesn't change which might otherwise
+% (for unrelated chunks) if we aren't careful.} So we still
+% unnecessarily try to sort it in and depending on the rules that
+% might result in a loop that is otherwise resolved. If that turns
+% out to be a real issue, we can improve the code.
%
% Here the code is removed from \cs{l_@@_cur_hook_tl} rather than
% \verb=#3= because the latter may be \verb=??=, and the default
@@ -2852,7 +2856,8 @@
{
\@@_msg_pair_found:nnn {#1} {#2} {#3}
\iow_term:x{--->~ Drop~ '#2'~ code~ from~
- \iow_char:N \\ g_@@_ \l_@@_cur_hook_tl _code_prop ~ because~ of~ '#1' }
+ \iow_char:N \\ g_@@_ \l_@@_cur_hook_tl _code_prop
+ ~ because~ of~ '#1' }
}
\prop_put:Nnn \l_@@_work_prop {#2} { }
}
@@ -2862,7 +2867,8 @@
{
\@@_msg_pair_found:nnn {#1} {#2} {#3}
\iow_term:x{--->~ Drop~ '#1'~ code~ from~
- \iow_char:N \\ g_@@_ \l_@@_cur_hook_tl _code_prop ~ because~ of~ '#2' }
+ \iow_char:N \\ g_@@_ \l_@@_cur_hook_tl _code_prop
+ ~ because~ of~ '#2' }
}
\prop_put:Nnn \l_@@_work_prop {#1} { }
}
@@ -2894,8 +2900,9 @@
\cs_new_protected:Npn \@@_msg_pair_found:nnn #1#2#3
{
\iow_term:x{~ \str_if_eq:nnTF {#3} {??} {default} {~normal} ~
- rule~ \@@_label_pair:nn {#1} {#2}:~
- \use:c { g_@@_#3_rule_ \@@_label_pair:nn {#1} {#2} _tl } ~ found}
+ rule~ \@@_label_pair:nn {#1} {#2}:~
+ \use:c { g_@@_#3_rule_ \@@_label_pair:nn {#1} {#2} _tl }
+ ~ found}
}
% \end{macrocode}
% \end{macro}
@@ -3312,13 +3319,11 @@
Labels~`#1'~and~`#2'~are~incompatible
\str_if_eq:nnF {#3} {??} { ~in~hook~`#3' } .~
\int_compare:nNnTF {#4} = { 1 }
- { The~code~for~both~labels~will~be~dropped. }
+ { The~ code~ for~ both~ labels~ will~ be~ dropped. }
{ You~ may~ see~ errors~ later. }
}
- {
- LaTeX~found~two~incompatible~labels~in~the~same~hook.~
- This~indicates~an~incompatibility~between~packages.
- }
+ { LaTeX~found~two~incompatible~labels~in~the~same~hook.~
+ This~indicates~an~incompatibility~between~packages. }
% \end{macrocode}
%
% \begin{macrocode}
@@ -3421,6 +3426,8 @@
% for each item in that stack. The last item is the \verb|top-level|,
% which also gets an empty entry.
%
+% \fmi{Fix this no longer applies, so it is unnecessary code}
+%
% Also check for the case we're loading \texttt{lthooks} in the
% \LaTeXe{} kernel. In that case, \cs{@currname} isn't \verb|lthooks|
% and just the top-level is added to the stack as an empty entry.
@@ -3487,18 +3494,12 @@
%
%
%
-% \begin{macro}{\UseHook}
+% \begin{macro}{\UseHook,\UseOneTimeHook}
% Avoid the overhead of \pkg{xparse} and its protection that we
% don't want here (since the hook should vanish without trace if empty)!
% \begin{macrocode}
-\newcommand \UseHook { \hook_use:n }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\UseOneTimeHook}
-%
-% \begin{macrocode}
-\cs_new_protected:Npn \UseOneTimeHook { \hook_use_once:n }
+\newcommand \UseHook { \hook_use:n }
+\newcommand \UseOneTimeHook { \hook_use_once:n }
% \end{macrocode}
% \end{macro}
@@ -3514,7 +3515,7 @@
% \begin{macro}{\DebugHooksOn,\DebugHooksOff}
%
% \begin{macrocode}
-\cs_new_protected:Npn \DebugHooksOn { \hook_debug_on: }
+\cs_new_protected:Npn \DebugHooksOn { \hook_debug_on: }
\cs_new_protected:Npn \DebugHooksOff { \hook_debug_off: }
% \end{macrocode}
% \end{macro}
@@ -3525,7 +3526,7 @@
%
% \begin{macrocode}
\NewDocumentCommand \DeclareHookRule { m m m m }
-{ \hook_gset_rule:nnnn {#1}{#2}{#3}{#4} }
+ { \hook_gset_rule:nnnn {#1}{#2}{#3}{#4} }
% \end{macrocode}
% \end{macro}
@@ -3541,7 +3542,7 @@
% \begin{macro}{\ClearHookRule}
% A special setup rule that removes an existing relation.
% Basically {@@_rule_gclear:nnn} plus fixing the property list for debugging.
-% \fmi{Need an L3 interface, or maybe it should get dropped}
+% \fmi{Need an L3 interface, or maybe it should get dropped?}
% \begin{macrocode}
\NewDocumentCommand \ClearHookRule { m m m }
{ \hook_gset_rule:nnnn {#1}{#2}{unrelated}{#3} }
@@ -3549,7 +3550,7 @@
% \end{macro}
%
%
-% \begin{macro}{\IfHooksExistsTF,\IfHookEmptyTF}
+% \begin{macro}{\IfHookExistsTF,\IfHookEmptyTF}
% \begin{macrocode}
\NewExpandableDocumentCommand \IfHookExistsTF { m }
{ \hook_if_exist:nTF {#1} }
@@ -3563,6 +3564,11 @@
% \subsection{Internal commands needed elsewhere}
%
+% Here we set up a few horrible (but consistent) \LaTeXe{} names to
+% allow for internal commands to be used outside this module. We
+% have to unset the \texttt{@\/@} since we want double ``at'' sign
+% in place of double underscores.
+%
% \begin{macro}{\@expl@@initialize at all@,
% \@expl@@hook at curr@name at push@n,
% \@expl@@hook at curr@name at pop@}
diff --git a/base/testfiles/github-0218.luatex.tlg b/base/testfiles/github-0218.luatex.tlg
index 7a98b4b8..98d4aae3 100644
--- a/base/testfiles/github-0218.luatex.tlg
+++ b/base/testfiles/github-0218.luatex.tlg
@@ -4,6 +4,6 @@ Author: Bruno Le Floch
Format: LaTeX2e<2020-10-01>
Main Class: ltxdoc
("./file name.dtx"
-file name.dtx
+file name.dtx (file name.dtx)
) [1
] (github-0218.aux ("./file name.aux"))
More information about the latex3-commits
mailing list.