[latex3-commits] [git/LaTeX3-latex3-latex2e] marks-debug: provide a hook in \InsertMark (3890c4e2)

Frank Mittelbach frank.mittelbach at latex-project.org
Thu Apr 14 12:20:19 CEST 2022


Repository : https://github.com/latex3/latex2e
On branch  : marks-debug
Link       : https://github.com/latex3/latex2e/commit/3890c4e2fcd705297099c05f40819e1980476f96

>---------------------------------------------------------------

commit 3890c4e2fcd705297099c05f40819e1980476f96
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Thu Apr 14 12:20:19 2022 +0200

    provide a hook in \InsertMark


>---------------------------------------------------------------

3890c4e2fcd705297099c05f40819e1980476f96
 base/lthooks.dtx                          | 16 +++++++++++-
 base/ltmarks.dtx                          | 41 ++++++++++++++++++++++++++++---
 base/testfiles-lthooks/ltcmdhooks-001.tlg |  1 +
 base/testfiles-lthooks/lthooks-000.tlg    |  1 +
 base/testfiles-lthooks/lthooks-001.tlg    |  3 +++
 base/testfiles-lthooks/lthooks-002.tlg    |  3 +++
 base/testfiles-lthooks/lthooks-003.tlg    |  2 ++
 base/testfiles-lthooks/lthooks-004.tlg    |  2 ++
 base/testfiles-lthooks/lthooks-005.tlg    |  2 ++
 base/testfiles-lthooks/lthooks-006.tlg    |  2 ++
 base/testfiles-lthooks/lthooks-007.tlg    |  3 +++
 base/testfiles-lthooks/lthooks-008.tlg    |  2 ++
 base/testfiles-lthooks/lthooks-009.tlg    |  1 +
 base/testfiles-lthooks/lthooks-011.tlg    |  4 +++
 base/testfiles-lthooks/lthooks-013.tlg    |  1 +
 base/testfiles-lthooks/lthooks-021.tlg    |  1 +
 base/testfiles-lthooks/lthooks-legacy.tlg |  1 +
 base/testfiles-lthooks2/lthooks2-002.tlg  |  1 +
 base/testfiles-lthooks2/lthooks2-005.tlg  |  2 ++
 19 files changed, 85 insertions(+), 4 deletions(-)

diff --git a/base/lthooks.dtx b/base/lthooks.dtx
index 664867e5..806189ee 100644
--- a/base/lthooks.dtx
+++ b/base/lthooks.dtx
@@ -32,7 +32,7 @@
 %
 %    \begin{macrocode}
 \def\lthooksversion{v1.0t}
-\def\lthooksdate{2022/04/05}
+\def\lthooksdate{2022/04/14}
 %    \end{macrocode}
 %
 %<*driver>
@@ -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  }
 %
 %
diff --git a/base/ltmarks.dtx b/base/ltmarks.dtx
index a076ecd8..fe9e9bc2 100644
--- a/base/ltmarks.dtx
+++ b/base/ltmarks.dtx
@@ -171,6 +171,20 @@
 %   typeset.
 % \end{function}
 %
+% \begin{variable}{insertmark}
+%   \begin{syntax}
+%     \cs{AddToHook} \texttt{\{insertmark\}} \Arg{code}
+%   \end{syntax}
+%  When marks are inserted, the mark content may need some special
+%  treatment, e.g., by default \cs{label}, \cs{index}, and
+%  \cs{glossary} do not expand at this time (but only later if and when the
+%  mark content is actually used.
+%  In order to allow packages to augment or alter this setup there is
+%  a public hook \hook{insertmark} that is executed at this point.  It
+%  runs in a group so local modification to commands are only applied
+%  to the \meta{entry} argument of \cs{InsertMark} or \cs{mark_insert:nn}.
+% \end{variable}
+%
 % \begin{function}[EXP]{\TopMark, \FirstMark, \LastMark,
 %      \mark_use_top:nn,\mark_use_first:nn,\mark_use_last:nn,}
 %   \begin{syntax}
@@ -1017,9 +1031,15 @@
 %    (and a kernel) hook instead of a set of hardwired settings.
 %    \begin{macrocode}
         \group_begin:
-          \cs_set_eq:NN \label    \scan_stop:
-          \cs_set_eq:NN \index    \scan_stop:
-          \cs_set_eq:NN \glossary \scan_stop:
+%    \end{macrocode}
+%    Within the group we alter some comments, e.g, \cs{label} or
+%    \cs{index}, to do the right at this point. This is done in the
+%    kernel hook \cs{@kernel at before@insertmark} which is followed by
+%    the public hook \hook{insertmark} that can be used by packages to
+%    augment or alter that setup as necessary.
+%    \begin{macrocode}
+          \@kernel at before@insertmark
+          \hook_use:n { insertmark }
           \unrestored at protected@xdef \g_@@_tmp_tl {#2}
 %<*trace>
           \@@_debug:n{ \iow_term:x { Marks:~ set~#1~<-~
@@ -1059,6 +1079,21 @@
 %  \end{macro}
 %
 %
+%  \begin{macro}{@kernel at before@insertmark}
+%    By default \cs{label}, \cs{index}, and \cs{glossary} do nothing
+%    when the mark is inserted. 
+%    \begin{macrocode}
+\cs_new:Npn \@kernel at before@insertmark {
+          \cs_set_eq:NN \label    \scan_stop:
+          \cs_set_eq:NN \index    \scan_stop:
+          \cs_set_eq:NN \glossary \scan_stop:
+}
+%    \end{macrocode}
+%    The public hook to augment the setup.
+%    \begin{macrocode}
+\hook_new:n {insertmark}
+%    \end{macrocode}
+%  \end{macro}
 %    
 % \begin{macro}[EXP]{\mark_use_top:nn, \mark_use_first:nn, \mark_use_last:nn}
 %
diff --git a/base/testfiles-lthooks/ltcmdhooks-001.tlg b/base/testfiles-lthooks/ltcmdhooks-001.tlg
index a983beb3..b7263e7f 100644
--- a/base/testfiles-lthooks/ltcmdhooks-001.tlg
+++ b/base/testfiles-lthooks/ltcmdhooks-001.tlg
@@ -94,6 +94,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
diff --git a/base/testfiles-lthooks/lthooks-000.tlg b/base/testfiles-lthooks/lthooks-000.tlg
index 52d60d49..44cc1a5c 100644
--- a/base/testfiles-lthooks/lthooks-000.tlg
+++ b/base/testfiles-lthooks/lthooks-000.tlg
@@ -34,6 +34,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
diff --git a/base/testfiles-lthooks/lthooks-001.tlg b/base/testfiles-lthooks/lthooks-001.tlg
index 64631733..bf993246 100644
--- a/base/testfiles-lthooks/lthooks-001.tlg
+++ b/base/testfiles-lthooks/lthooks-001.tlg
@@ -40,6 +40,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
@@ -153,6 +154,7 @@ The sequence \g__hook_all_seq contains the items (without outer braces):
 >  {enddocument/afteraux}
 >  {enddocument/info}
 >  {enddocument/end}
+>  {insertmark}
 >  {package/before}
 >  {class/before}
 >  {package/after}
@@ -208,6 +210,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
diff --git a/base/testfiles-lthooks/lthooks-002.tlg b/base/testfiles-lthooks/lthooks-002.tlg
index d62cd7a5..c95ecfbb 100644
--- a/base/testfiles-lthooks/lthooks-002.tlg
+++ b/base/testfiles-lthooks/lthooks-002.tlg
@@ -40,6 +40,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
@@ -155,6 +156,7 @@ The sequence \g__hook_all_seq contains the items (without outer braces):
 >  {enddocument/afteraux}
 >  {enddocument/info}
 >  {enddocument/end}
+>  {insertmark}
 >  {package/before}
 >  {class/before}
 >  {package/after}
@@ -210,6 +212,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
diff --git a/base/testfiles-lthooks/lthooks-003.tlg b/base/testfiles-lthooks/lthooks-003.tlg
index 599cc4ac..63d4d222 100644
--- a/base/testfiles-lthooks/lthooks-003.tlg
+++ b/base/testfiles-lthooks/lthooks-003.tlg
@@ -47,6 +47,7 @@ The sequence \g__hook_all_seq contains the items (without outer braces):
 >  {enddocument/afteraux}
 >  {enddocument/info}
 >  {enddocument/end}
+>  {insertmark}
 >  {package/before}
 >  {class/before}
 >  {package/after}
@@ -113,6 +114,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
diff --git a/base/testfiles-lthooks/lthooks-004.tlg b/base/testfiles-lthooks/lthooks-004.tlg
index a15cf9dd..f13ee979 100644
--- a/base/testfiles-lthooks/lthooks-004.tlg
+++ b/base/testfiles-lthooks/lthooks-004.tlg
@@ -37,6 +37,7 @@ The sequence \g__hook_all_seq contains the items (without outer braces):
 >  {enddocument/afteraux}
 >  {enddocument/info}
 >  {enddocument/end}
+>  {insertmark}
 >  {package/before}
 >  {class/before}
 >  {package/after}
@@ -97,6 +98,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
diff --git a/base/testfiles-lthooks/lthooks-005.tlg b/base/testfiles-lthooks/lthooks-005.tlg
index be8f98d7..919dc646 100644
--- a/base/testfiles-lthooks/lthooks-005.tlg
+++ b/base/testfiles-lthooks/lthooks-005.tlg
@@ -54,6 +54,7 @@ The sequence \g__hook_all_seq contains the items (without outer braces):
 >  {enddocument/afteraux}
 >  {enddocument/info}
 >  {enddocument/end}
+>  {insertmark}
 >  {package/before}
 >  {class/before}
 >  {package/after}
@@ -120,6 +121,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
diff --git a/base/testfiles-lthooks/lthooks-006.tlg b/base/testfiles-lthooks/lthooks-006.tlg
index 7fff0b9c..dc4012d3 100644
--- a/base/testfiles-lthooks/lthooks-006.tlg
+++ b/base/testfiles-lthooks/lthooks-006.tlg
@@ -35,6 +35,7 @@ The sequence \g__hook_all_seq contains the items (without outer braces):
 >  {enddocument/afteraux}
 >  {enddocument/info}
 >  {enddocument/end}
+>  {insertmark}
 >  {package/before}
 >  {class/before}
 >  {package/after}
@@ -93,6 +94,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
diff --git a/base/testfiles-lthooks/lthooks-007.tlg b/base/testfiles-lthooks/lthooks-007.tlg
index 4151818d..6a05080f 100644
--- a/base/testfiles-lthooks/lthooks-007.tlg
+++ b/base/testfiles-lthooks/lthooks-007.tlg
@@ -35,6 +35,7 @@ The sequence \g__hook_all_seq contains the items (without outer braces):
 >  {enddocument/afteraux}
 >  {enddocument/info}
 >  {enddocument/end}
+>  {insertmark}
 >  {package/before}
 >  {class/before}
 >  {package/after}
@@ -94,6 +95,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
@@ -213,6 +215,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
diff --git a/base/testfiles-lthooks/lthooks-008.tlg b/base/testfiles-lthooks/lthooks-008.tlg
index e65a0e2d..db8d0259 100644
--- a/base/testfiles-lthooks/lthooks-008.tlg
+++ b/base/testfiles-lthooks/lthooks-008.tlg
@@ -37,6 +37,7 @@ The sequence \g__hook_all_seq contains the items (without outer braces):
 >  {enddocument/afteraux}
 >  {enddocument/info}
 >  {enddocument/end}
+>  {insertmark}
 >  {package/before}
 >  {class/before}
 >  {package/after}
@@ -101,6 +102,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
diff --git a/base/testfiles-lthooks/lthooks-009.tlg b/base/testfiles-lthooks/lthooks-009.tlg
index 061165bd..36198491 100644
--- a/base/testfiles-lthooks/lthooks-009.tlg
+++ b/base/testfiles-lthooks/lthooks-009.tlg
@@ -40,6 +40,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
diff --git a/base/testfiles-lthooks/lthooks-011.tlg b/base/testfiles-lthooks/lthooks-011.tlg
index 4a946d54..8a71008a 100644
--- a/base/testfiles-lthooks/lthooks-011.tlg
+++ b/base/testfiles-lthooks/lthooks-011.tlg
@@ -35,6 +35,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
@@ -152,6 +153,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
@@ -271,6 +273,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
@@ -392,6 +395,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
diff --git a/base/testfiles-lthooks/lthooks-013.tlg b/base/testfiles-lthooks/lthooks-013.tlg
index cd59df91..5ef78f81 100644
--- a/base/testfiles-lthooks/lthooks-013.tlg
+++ b/base/testfiles-lthooks/lthooks-013.tlg
@@ -90,6 +90,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
diff --git a/base/testfiles-lthooks/lthooks-021.tlg b/base/testfiles-lthooks/lthooks-021.tlg
index 971e8bfb..2d2d6137 100644
--- a/base/testfiles-lthooks/lthooks-021.tlg
+++ b/base/testfiles-lthooks/lthooks-021.tlg
@@ -34,6 +34,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
diff --git a/base/testfiles-lthooks/lthooks-legacy.tlg b/base/testfiles-lthooks/lthooks-legacy.tlg
index 30363f35..035c76b3 100644
--- a/base/testfiles-lthooks/lthooks-legacy.tlg
+++ b/base/testfiles-lthooks/lthooks-legacy.tlg
@@ -59,6 +59,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
diff --git a/base/testfiles-lthooks2/lthooks2-002.tlg b/base/testfiles-lthooks2/lthooks2-002.tlg
index 337eccc1..79ce5491 100644
--- a/base/testfiles-lthooks2/lthooks2-002.tlg
+++ b/base/testfiles-lthooks2/lthooks2-002.tlg
@@ -48,6 +48,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
diff --git a/base/testfiles-lthooks2/lthooks2-005.tlg b/base/testfiles-lthooks2/lthooks2-005.tlg
index 98848d2f..b0086970 100644
--- a/base/testfiles-lthooks2/lthooks2-005.tlg
+++ b/base/testfiles-lthooks2/lthooks2-005.tlg
@@ -35,6 +35,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:
@@ -140,6 +141,7 @@ Data structure for label rules:
 Handled code for kernel/filelist
 Handled code for kernel/warnings
 Update code for hook 'enddocument/end' on input line ...:
+Update code for hook 'insertmark' on input line ...:
 Update code for hook 'package/before' on input line ...:
 Update code for hook 'class/before' on input line ...:
 Update code for hook 'package/after' on input line ...:





More information about the latex3-commits mailing list.