From deda1937c52481b2259e1061840b99e18e8ca361 Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Fri, 15 Sep 2023 03:02:43 +0000
Subject: CTAN sync 202309150302

---
 .../required/latex-lab/latex-lab-footnotes.dtx     | 985 ++++++++++++---------
 1 file changed, 584 insertions(+), 401 deletions(-)

(limited to 'macros/latex-dev/required/latex-lab/latex-lab-footnotes.dtx')

diff --git a/macros/latex-dev/required/latex-lab/latex-lab-footnotes.dtx b/macros/latex-dev/required/latex-lab/latex-lab-footnotes.dtx
index 4c8c9b73a6..f62d12bfd9 100644
--- a/macros/latex-dev/required/latex-lab/latex-lab-footnotes.dtx
+++ b/macros/latex-dev/required/latex-lab/latex-lab-footnotes.dtx
@@ -17,6 +17,9 @@
 %
 % for those people who are interested or want to report an issue.
 %
+\def\ltlabfootnotedate{2023-09-04}
+\def\ltlabfootnoteversion{0.8c}
+
 %<*driver>
 \documentclass{l3doc}
 \EnableCrossrefs
@@ -38,7 +41,14 @@
 % \newcommand\NEW[1]{\marginpar{\mbox{}\hfill\fbox{New: #1}}}
 % \providecommand\class[1]{\texttt{#1.cls}}
 % \providecommand\pkg[1]{\texttt{#1}}
-% \providecommand\hook[1]{\texttt{#1}}
+%
+% \providecommand\hook[1]{\texttt{#1\DescribeHook[noprint]{#1}}}
+% \providecommand\socket[1]{\texttt{#1\DescribeSocket[noprint]{#1}}}
+% \providecommand\plug[1]{\texttt{#1\DescribePlug[noprint]{#1}}}
+%
+% \NewDocElement[printtype=\textit{socket},idxtype=socket,idxgroup=Sockets]{Socket}{socketdecl}
+% \NewDocElement[printtype=\textit{hook},idxtype=hook,idxgroup=Hooks]{Hook}{hookdecl}
+% \NewDocElement[printtype=\textit{plug},idxtype=plug,idxgroup=Plugs]{Plug}{plugdecl}
 %
 % \begin{abstract}
 %   \emph{to be written}
@@ -56,7 +66,7 @@
 %    some adjustments are mutually exclusive). This is achieved by
 %    providing a larger number of hooks (for areas where different
 %    packages/classes can easily coexist with their adjustments) and a
-%    number of configuration points to which only one class or package
+%    number of sockets to which only one class or package
 %    can write to successfully (in case of multiple changes the
 %    last one wins). The latter are for special functionality, e.g.,
 %    if footnote text is typeset as a single paragraph, it can't be configured
@@ -67,7 +77,7 @@
 %    for this to work, all packages altering the footnote setup should
 %    use the interfaces provided here and not do it through the
 %    legacy methods (though there is some support for the latter as
-%    well, but if will not work in a cases).
+%    well, but it will not work in all cases).
 %
 % \subsection{Configuration methods}
 %
@@ -103,11 +113,14 @@
 %
 %
 %
-% \section{Hooks and configuration points}
+% \section{Sockets and hooks}
+%
+%    We use sockets for those parts that can be controlled only by one
+%    package or by the kernel and hooks for places where it may be
+%    possible that several packages or the document class adds code
+%    (typically declarations such as font changes, etc.).
 %
-%    Note: the configuration points do not have an interface mechanism
-%    yet and all their names are temporary right now.
-%    Also note that configuration points are of interest only to very
+%    Note that sockets are of interest only to very
 %    few specialized packages, mainly \pkg{footmisc}, and packages
 %    providing similar functionality---the current documentation is
 %    therefore fairly sketchy.
@@ -124,7 +137,7 @@
 %    in the same place, etc.
 %
 %
-% \subsubsection{Configuration points}
+% \subsubsection{Sockets}
 %
 %    None: everything is implemented through a single definition for
 %    \cs{@footnotemark} that offers a number of hooks that can be used
@@ -132,12 +145,14 @@
 %    formatting of marks.
 %
 %
-% \subsubsection{Hooks}
+% \subsubsection{Hooks for formatting the footnote mark in text}
 %
 %    The hooks to customize the marks in the text are the following:
 %    \begin{description}
 %    \item[\hook{fnmark/before}]
 %
+%      \DescribeHook[noprint]{fnmark/before}
+%
 %      Executed at the very beginning of \cs{footnotemark}. Currently
 %      there are two packages (\pkg{bibarts} and \pkg{chextras}) that
 %      prepend material at this point (not necessarily correctly, e.g.,
@@ -147,6 +162,8 @@
 %
 %    \item[\hook{fnmark}]
 %
+%      \DescribeHook[noprint]{fnmark}
+%
 %      Executed in horizontal mode and after the current space factor
 %      has been saved away for reuse. This is where currently code for multiple
 %      marks does its preparation (as done by \pkg{footmisc} and
@@ -156,12 +173,14 @@
 %      generated in math --- maybe that means the multiple handling
 %      should happen later?
 %
-%      After the hook \cs{nobreak} is executed, so any
+%      After the hook a \cs{nobreak} is executed, so any
 %      ``material'' added in the hook is tied to the following mark
 %      unless it contains its own permissible penalty.
 %
 %    \item[\hook{fnmark/begin}]
 %
+%      \DescribeHook[noprint]{fnmark/begin}
+%
 %      This hook is executed directly in front of the typeset mark.
 %      This is the place where \pkg{hyperref} would have added
 %      part of its code, i.e., after the \cs{nobreak} mentioned above.
@@ -170,6 +189,8 @@
 %
 %    \item[\hook{fnmark/end}]
 %
+%      \DescribeHook[noprint]{fnmark/end}
+%
 %      This hook is executed directly after the typeset mark. It is
 %      used by \pkg{memhfixc}, \pkg{scrlttr2}, and
 %      \pkg{footmisc}. Used, for example, to implement support for
@@ -180,6 +201,8 @@
 %
 %    \item[\hook{fnmark/after}]
 %
+%      \DescribeHook[noprint]{fnmark/after}
+%
 %      This hook is executed at the very end of the \cs{footnotemark} command.
 %
 %      It is a reversed  hook to pair with \hook{fnmark/before}
@@ -201,78 +224,114 @@
 %    appears at the bottom of the page (default case), or possibly
 %    elsewhere, e.g. in the margin.
 %
-% \subsubsection{Configuration points}
+% \subsubsection{Sockets}
 %
 %    To cater for different layout configurations there are four
-%    configuration points which can be set only by one package or
-%    class, if two packages/classes set them they are mutually
-%    incompatible.
+%    sockets that can be set by a package or 
+%    class but there should be only one per document setting them, i.e., if two packages/classes set them they are mutually
+%    incompatible (or rather the last one wins most likely).
 %    These are:
 %    \begin{description}
-%    \item[\cs{@footnotetext@cfgpoint} (1 argument)]
+%    \item[\socket{fntext/process} (1 argument)]
+%
+%      \DescribeSocket[noprint]{fntext/process}
+%
+%      This socket receives all material that is to be processed (or
+%      stored) including color protection code and what have you.
+%      The \plug{default} executes \cs{insert}\cs{footins}.
+%
+%      Available plugs are \plug{default}, \plug{side} (side notes), and \plug{mp} (minipage).
+%
+%
+%    \item[\socket{fntext/make}  (1 argument)]
 %
-%      This receives all material that is to be processed (or stored)
-%      including color protection code and what have you.  The default
-%      definition is to run \cs{insert}\cs{footins}.
+%      \DescribeSocket[noprint]{fntext/make}
 %
-%    \item[\cs{@footnotetext@cfgpointii}  (1 argument)]
+%      This socket receives the \meta{text} as given in \cs{footnote}
+%      or \cs{footnotetext} in the document and adds formatting
+%      instructions to it.
 %
-%      The default definition runs \cs{@makefntext} which contains
+%      The \plug{default} plug runs \cs{@makefntext} which contains
 %      various hooks for customization. For most scenarios this is
 %      sufficient. However, when running all footnotes as a single
 %      paragraph at the bottom, then each footnote needs to be
-%      prepared prior to storing in the insert and this configuration
-%      point allows running extra code to do that.
+%      prepared prior to storing it with \cs{insert} and this socket
+%      allows running extra code to do that.
 %
-%    \item[\cs{@footnotetext@cfgpointiii} (no argument)]
+%      Available plugs are \plug{default} and \plug{para}.
 %
-%      By default this configuration point adds a strut to the
-%      footnote material so that consecutive footnotes are properly
-%      spaced vertically. In some use cases this is not appropriate
-%      (e.g., when running all footnotes as a single paragraph) and so
-%      this configuration point can cancel the action or do something
-%      else instead.
+%    \item[\socket{fntext/begin} (no argument)]
 %
-%      The configuration point is executed near the start of the
-%      argument for the configuration point
-%      \cs{@footnotetext@cfgpointii}.
+%      \DescribeSocket[noprint]{fntext/begin}
 %
-%    \item[\cs{@footnotetext@cfgpointiv} (no argument)]
+%      The socket is executed near the start of the
+%      argument for the \socket{fntext/make} socket.
+%      By \plug{default} it adds a strut to the footnote
+%      material so that consecutive footnotes are properly spaced
+%      vertically. In some use cases this is not appropriate (e.g.,
+%      when running all footnotes as a single paragraph) and so with
+%      this socket one can cancel the action or do something else
+%      instead.
 %
-%      This configuration point is executed at the very end of the
-%      argument passed to  \cs{@footnotetext@cfgpointii}.
-%      By default it adds a final strut as long as we are still in
-%      horizontal mode (i.e., processing the footnote text paragraph.
-%      When running several footnotes in one paragraph some additional
-%      material (some horizontal glue) needs adding at this point.
+%      Available plugs are \plug{default} and \plug{noop}.
 %
+%
+%    \item[\socket{fntext/end} (no argument)]
+%
+%      \DescribeSocket[noprint]{fntext/end}
+%
+%      This socket is executed at the very end of the argument passed
+%      to socket \socket{fntext/make}.  By \plug{default} it
+%      adds a final strut as long as we are still in horizontal mode
+%      (i.e., processing the footnote text paragraph).  When running
+%      several footnotes in one paragraph some additional material
+%      (some horizontal glue) needs adding at this point which is done
+%      with the plug \plug{para}.
+%
+%      Available plugs are \plug{default}, \plug{para}, and
+%      \plug{noop}.
 %    \end{description}
-%    The configuration point \cs{@footnotetext@cfgpointii} runs
+%
+%
+%    All standard plugs for the socket \socket{fntext/make} run
 %    \cs{@makefntext} and this command contains two further
-%    configuration points (and a few hooks):
+%    sockets (unless it is overwritten by a legacy class):
 %    \begin{description}
-%    \item[\cs{@makefntext@cfgpoint} (1 argument)]
+%    \item[\socket{fntext/mark} (0 arguments)]
+%
+%      \DescribeSocket[noprint]{fntext/mark}
 %
-%      This configuration point receives the material to typeset the
-%      footnote mark. By default, all it does is running \cs{indent}
-%      to get a paragraph indentation (if one is set up---in most
-%      layouts it is 0~points)  and then typesets the mark, but in
-%      some designs it executes more elaborate code.
+%      This socket has no input arguments but uses \cs{@makefnmark} to
+%      typeset the mark in front of the footnote text. Its
+%      \plug{default} uses code that examines the value of
+%      \cs{footnotemargin} and based on its setting typeset the mark
+%      in different ways:
+%      \begin{itemize}
+%      \item positive: typeset the mark in a box of that size
+%      \item zero: use \cs{llap} around the mark
+%      \item negative: use \cs{llap} but with a box of the given size
+%      negated inside
+%      \item \texttt{-}\cs{maxdimen}: just use \cs{@makefnmark} 
+%      \end{itemize}
+%      For most cases this would be flexible enough, but if not then a
+%      class can define its own plug to specify the placement of the mark.
 %
-%      If tagging is produced this configuration point is also
-%      responsible for surrounding the mark with the appropriate tags
-%      marking the mark as an Lbl. It does this using the command
-%      \cs{tag@FENoteLbl}.
+%      Available plugs are \plug{default} and \plug{noop} (no mark is produced).
 %
-%    \item[\cs{@makefntext@cfgpointii} (1 argument)]
 %
-%      This configuration point manages the formatting of the footnote
-%      text once the mark has been typeset.
+%    \item[\socket{fntext/text} (1 argument)]
 %
-%      If tagging is produced this configuration point is also
-%      responsible for surrounding the mark with the appropriate tags
-%      marking the mark as an MC of type FENote. It does this using
-%      the command \cs{tag@FENotetext}.
+%      \DescribeSocket[noprint]{fntext/text}
+%
+%      This socket manages the formatting of the footnote text
+%      (presented as an argument) once the mark has been typeset.  In
+%      all cases we can think of this formatting is better configured
+%      via the available hooks described below, so the \plug{default}
+%      just grabs the argument and processes it without any other
+%      action. It is really only there to allow for some fancy stuff
+%      that some design comes up with.
+%
+%      Available plugs are \plug{identity} (default) and \plug{noop}.
 %
 %    \end{description}
 %
@@ -284,19 +343,23 @@
 %
 %
 %
-% \subsubsection{Hooks}
+% \subsubsection{Hooks for formatting the footnote text}
 %
 %    \begin{description}
 %    \item[\hook{fntext/before}]
 %
+%      \DescribeHook[noprint]{fntext/before}
+%
 %      Executed at the very beginning of \cs{footnotetext}. Currently
-%      there is on package (\pkg{linguex}) that
+%      there is one package (\pkg{linguex}) that
 %      prepends material at this point.
 %
 %      This hook is paired with hook \hook{fnmark/after}.
 %
 %    \item[\hook{fntext}]
 %
+%      \DescribeHook[noprint]{fntext}
+%
 %      Executed at the beginning of the material passed to the first
 %      configuration point.  Typically used to set any baseline
 %      stretch for the footnote text, e.g., by \pkg{setspace},
@@ -308,32 +371,42 @@
 %
 %    \item[\hook{fntext/para}]
 %
-%      After the font is set default paragraph parameters are set up
+%      \DescribeHook[noprint]{fntext/para}
+%
+%      After the font is set (after the previous hook), some default
+%      paragraph parameters
+%       are set up
 %      including \cs{interlinepenalty}, \cs{hsize}, \cs{parindent} and
 %      a number of others, as some of them depend on the font
-%      size. Then the \hook{fntext/para} is run. If one wants to
+%      size. Then the \hook{fntext/para} is run which can overwrite
+%      the default. If one wants to
 %      change the font size, it is probably necessary to reset these
 %      other parameters too, e.g., \cs{parindent}, which can be done
 %      here.
 %
-%      The configuration point \cs{@footnotetext@cfgpointii} normally
+%      Note: the socket \socket{fntext/make} normally
 %      runs the command \cs{@makefntext} or some code that eventually
-%      runs this command, and this then produces the footnote mark (in
-%      front of the footnote text) and the formatted footnote text. In
+%      runs this command, and this then produces the footnote mark in
+%      front of the  formatted footnote text. In
 %      front of both the mark and the footnote text some classes have
 %      placed paragraph parameter adjustments in their redefinition of
 %      \cs{@makefntext}. However, there is no need to place it there
 %      it could equally well go into the \hook{fntext/para} hook. We
-%      therefore do not provide another hook at this point.
+%      therefore do not provide another hook at this other point.
 %
 %    \item[\hook{fntext/begin} \& \hook{fntext/end}]
 %
+%      \DescribeHook[noprint]{fntext/begin}
+%      \DescribeHook[noprint]{fntext/end}
+%
 %      The footnote text itself is surrounded by the hooks
 %      \hook{fntext/begin} and \hook{fntext/end}. The two hooks are
 %      not paired as they are typically used independently.
 %
 %    \item[\hook{fntext/after}]
 %
+%      \DescribeHook[noprint]{fntext/after}
+%
 %      At the very end of \cs{footnotetext} we execute the hook
 %      \hook{fntext/after} which is a reversed hook paired with
 %      \hook{fntext/before}. Some packages, e.g., \pkg{linguex}, have
@@ -384,6 +457,8 @@
 %
 % \section{Tagging and hyperlinking support}
 %
+% \fmi{this section needs work (and probably csname changes)}
+%
 % Footnotes consist of a \emph{footnotemark} (short: mark) that is typically placed in the text
 % as a superscript number like this\footnotemark[1], and a \emph{footnotetext}
 % (short: note) that is placed at the bottom of the page.
@@ -407,6 +482,38 @@
 %
 % \subsection{Technical details for the tagging}
 %
+% The following sockets are set up for kernel use, when doing tagging:
+% \begin{description}
+%    \item[\socket{tagsupport/fnmark} (1 argument)]
+%
+%      \DescribeSocket[noprint]{tagsupport/fnmark}
+%
+%      \fmi{describe and decide on names}
+%
+%
+%    \item[\socket{tagsupport/fntext/begin} (no argument)]
+%
+%      \DescribeSocket[noprint]{tagsupport/fntext/begin}
+%
+%
+%    \item[\socket{tagsupport/fntext/end} (no argument)]
+%
+%      \DescribeSocket[noprint]{tagsupport/fntext/end}
+%
+%
+%    \item[\socket{tagsupport/fntext/mark} (1 argument)]
+%
+%      \DescribeSocket[noprint]{tagsupport/fntext/mark}
+%
+%
+%    \item[\socket{tagsupport/fntext/text} (1 argument)]
+%
+%      \DescribeSocket[noprint]{tagsupport/fntext/text}
+%
+%
+% \end{description}
+%
+%
 % The \emph{footnotemark} should create a \texttt{/Lbl} structure\footnote{to make it easier
 % to identify the role we use \texttt{/footnotemark} which we rolemap to \texttt{/Lbl}} that should contain a \texttt{/Ref} entry pointing
 % to the structure of the \emph{footnotetext}.
@@ -475,36 +582,36 @@
 % as long as nothing unusual is done to \cs{@thefnmark}.
 % It also works if a document uses more than one footnote series as long as they have distinct numbering
 % systems, but in case a distinction is needed it is possible to define
-% a new data structure and to switch locally to use this
-% container. The following three commands are used for this.
+% a new class with its own data structure and to switch locally to use this
+% class. The following three commands are used for this.
 %
-% The default property uses the name \texttt{default}
+% The default class uses the name \texttt{default}
 %
-% \begin{function}{\fnote_new:nn}
+% \begin{function}{\fnote_class_new:nn}
 % \begin{syntax}
-% \cs{fnote_new:nn}\Arg{name}\Arg{key/value option}
+% \cs{fnote_class_new:nn}\Arg{name}\Arg{key/value option}
 % \end{syntax}
-%
-% This commands set up the needed data structure. Currently this only
-% consists of a property which is used to store and manage the mark values.
-% There are no options yet.
+%   This declaration sets up the needed data structure. Currently this only
+%   consists of a property list which is used to store and manage the mark values.
+%   There are no options yet.
 % \end{function}
 %
 % \begin{function}{\fnote_mark_gput:nn,\fnote_mark_gput:no,\fnote_mark_gput:oo}
 % \begin{syntax}
-% \cs{fnote_mark_gput:nn}\Arg{mark}\Arg{footnote type name}
+% \cs{fnote_mark_gput:nn}\Arg{mark}\Arg{class name}
 % \end{syntax}
-% This command stores the current structure number as key and the \meta{mark} as
-% value in the property associated with the \meta{footnote type name}
+%   This command stores the current structure number as key and the \meta{mark} as
+%   value in the property list associated with the \meta{class name}.
 % \end{function}
 %
-% \begin{function}{\fnote_mark_gpop:nnN}
+% \begin{function}{\fnote_mark_gpop_all:nnN}
 % \begin{syntax}
-% \cs{fnote_mark_gpop:nnN}\Arg{mark}\Arg{footnote type name}\meta{sequence}
+% \cs{fnote_mark_gpop_all:nnN}\Arg{mark}\Arg{class name}\meta{sequence}
 % \end{syntax}
-% This command stores the keys/structure numbers whose value are \meta{mark} in the
-% property associated with \meta{footnote type name} in the \meta{sequence}
-% and then remove them from the property. The content of the sequence can then be
+% This command stores all the keys/structure numbers whose value in the
+% property list for \meta{class name} are equal to \meta{mark}
+% into the sequence \meta{sequence} and then removes them from the property list. 
+% The content of the sequence can then be
 % used to create link targets and references.
 % \end{function}
 %
@@ -516,7 +623,7 @@
 % above, as it contains a reference command it can't be used to match a note, also \cs{footref} can
 % be used after the note has already been set. \cs{footref} disables therefore the automatic detection.
 %
-% Instead the \cs{label} command is (currently with the help of a hook from the \texttt{nameref} package)
+% Instead the \cs{label} command is 
 % extended in the \cs{footnotetext} command to also store the structure number and \cs{footref} retrieves this
 % number to setup the reference and the link.
 %
@@ -560,28 +667,33 @@
 % by the mark commands) and one for the structure number of the footnotetest itself
 % (used as target by \cs{footref}s commands).
 %
-% \subsection{Implementation details}
+% \subsection{Implementation details regarding tagging}
 %
 % \subsection{Handling the mark}
 %
-% The mark in the text is handled by redefining the kernel configuration point
-% \cs{@kernel@process@makefnmark} to \cs{tag@FEMark}.
-% It takes one argument, \cs{@makefnmark}, the command which formats the
-% mark, and surrounds it by link and tagging commands.
-% At the point where \cs{@kernel@process@makefnmark} is issued \cs{@thefnmark} has already been
-% defined and can be used to setup the reference detections.
+% The mark in the text is handled by assigning an appropriate
+% plug to the socket \socket{tagsupport/fnmark}.
+%  It takes one argument, \cs{@makefnmark}, the
+% command which formats the mark, and surrounds it by link and tagging
+% commands.  At the point where the socket is
+% executed, \cs{@thefnmark} has already been defined and can be used to
+% setup the reference detections.
 %
 %
 % \subsection{Handling the footnotetext}
 %
-% The main part is done by redefining \cs{@kernel@process@footnotetext}. This configuration point takes two arguments, \cs{@footnotetext@cfgpoint} (by default \verb+\insert\footins+) and as second argument lots of code related to typesetting the notemark and the footnote text with the actual content of the footnote text somewhere in the middle.
+% The main part is done by assigning a different plug to socket \socket{tagsupport/fntext/begin}
+% and \socket{tagsupport/fntext/end}
+% surrounding the footnote text.
+% These sockets are used to start and end the structure and
+% attempt to detect to which mark the note is related.
 %
-% The redefinition of \cs{@kernel@process@footnotetext} surrounds the content with the structure command
-% and tries to detect to which mark the note is related.
-%
-% The actual typesetting of the note text is done
-% by \cs{@makefntext}/\cs{fnote_makefntext:n}. In the new implementation this contains two configuration
-% points, \cs{@makefntext@cfgpoint} and \cs{@makefntext@cfgpointii}. These are redefined to add the tagging commands around note mark and note text.
+% The actual typesetting of the note text is done by
+% \cs{fnote_makefntext:n} (or its \LaTeXe{} name \cs{@makefntext}). In
+% the new implementation this contains two further kernel sockets for tagging:
+% \socket{tagsupport/fntext/mark} and
+% \socket{tagsupport/fntext/text}. They get plugs assigned that add the
+% tagging commands around note mark and note text.
 %
 % \subsection{Footnotes in minipages}
 %
@@ -603,13 +715,6 @@
 %
 % \begin{itemize}
 %
-% \item tagging destroys footnotes directly following the text with pdflatex.
-%
-% \item there is a dependency on nameref as it provides the hook in \cs{label}
-% used by the \cs{footref} code.
-%
-% \item there is a dependency to etoolbox as we patch \cs{\@iiiminipage}
-%
 % \item Special formatting of footnote marks in the text, e.g. if ranges or commas are
 % used require special care as they should normally mark up such text as artifacts and
 % perhaps have to insert empty structures to represent an invisible mark. This must be coordinated
@@ -617,9 +722,6 @@
 %
 % \item manyfoot doesn't work correctly and must be analyzed.
 %
-% \item Check if additional kernel configuration points are needed/possible
-% to avoid the redefinitions of \cs{@makefntext@cfgpoint} and \cs{@makefntext@cfgpointii}.
-%
 % \item \pkg{memoir} is not supported at all and errors when the code tries to patch
 % \cs{@makefntext}.
 % \end{itemize}
@@ -644,7 +746,8 @@
 % \subsection{File declaration}
 %    \begin{macrocode}
 \ProvidesFile{latex-lab-footnotes.ltx}
-        [2023-02-04 v0.7 changes to the footnote interfaces]
+             [\ltlabfootnotedate\space v\ltlabfootnoteversion\space
+               changes to the footnote interfaces]
 %    \end{macrocode}
 %
 % \subsection{code not fully handled yet}
@@ -796,7 +899,6 @@
 % \subsection{Variants}
 %
 %    \begin{macrocode}
-\cs_generate_variant:Nn \ref_label:nn { Vn }
 \cs_generate_variant:Nn \ref_value:nn { Vn }
 \cs_generate_variant:Nn \prop_gput:Nnn {cxn}
 \cs_generate_variant:Nn \hook_gput_code:nnn{nne}
@@ -852,14 +954,22 @@
 %
 % \subsection{Hooks}
 %
-% Hooks in the footnotemark command.
+% \begin{hookdecl}{fnmark/before,fnmark/after,
+%              fnmark,
+%              fnmark/begin,fnmark/end}
+%    Hooks in the footnotemark command.
 %    \begin{macrocode}
 \NewMirroredHookPair{fnmark/before}{fnmark/after}
 \NewHook{fnmark}
 \NewHook{fnmark/begin}
 \NewHook{fnmark/end}
 %    \end{macrocode}
-% Hooks in the footnotetext command
+% \end{hookdecl}
+%
+% \begin{hookdecl}{fntext/before,fntext/after,
+%              fntext,
+%              fntext/begin,fntext/end,fntext/para}
+%     Hooks in the footnotetext command:
 %    \begin{macrocode}
 \NewMirroredHookPair{fntext/before}{fntext/after}
 \NewHook{fntext}
@@ -867,6 +977,7 @@
 \NewHook{fntext/begin}
 \NewHook{fntext/end}
 %    \end{macrocode}
+% \end{hookdecl}
 %
 % \subsection{Debugging code}
 % the debugging code is just temporary
@@ -882,11 +993,11 @@
   {
     \bool_if:NT \g_fnote_debug_bool
        {
-         \LogHook{fnmark/before}
-         \LogHook{fnmark}
-         \LogHook{fnmark/begin}
-         \LogHook{fnmark/end}
-         \LogHook{fnmark/after}
+         \hook_log:n {fnmark/before}
+         \hook_log:n {fnmark}
+         \hook_log:n {fnmark/begin}
+         \hook_log:n {fnmark/end}
+         \hook_log:n {fnmark/after}
          \cs_gset_eq:NN \@@_debug_footnotemark: \prg_do_nothing:
        }
   }
@@ -897,18 +1008,32 @@
   {
     \bool_if:NT \g_fnote_debug_bool
        {
-         \cs_log:N\@footnotetext@cfgpoint
-         \cs_log:N\@footnotetext@cfgpointii
-         \cs_log:N\@footnotetext@cfgpointiii
-         \cs_log:N\@footnotetext@cfgpointiv
-         \cs_log:N\@makefntext@cfgpoint
-         \cs_log:N\@makefntext@cfgpointii
-         \LogHook{fntext/before}
-         \LogHook{fntext}
-         \LogHook{fntext/para}
-         \LogHook{fntext/begin}
-         \LogHook{fntext/end}
-         \LogHook{fntext/after}
+         \socket_log:n {fntext/process}
+         \socket_log:n {fntext/make}
+         \socket_log:n {fntext/begin}
+         \socket_log:n {fntext/end}
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+         \socket_log:n {fntext/mark}
+         \socket_log:n {fntext/text}
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+         \socket_log:n {tagsupport/fnmark}
+         \socket_log:n {tagsupport/fntext/begin}
+         \socket_log:n {tagsupport/fntext/end}
+         \socket_log:n {tagsupport/fntext/mark}
+         \socket_log:n {tagsupport/fntext/text}
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+         \hook_log:n {fntext/before}
+         \hook_log:n {fntext}
+         \hook_log:n {fntext/para}
+         \hook_log:n {fntext/begin}
+         \hook_log:n {fntext/end}
+         \hook_log:n {fntext/after}
 %    \end{macrocode}
 %    Show the info only once (if at all).
 %    \begin{macrocode}
@@ -926,7 +1051,7 @@
 %-------
 % bibarts
 % chextras  --- actually in the wrong place does an \unskip
-  \UseHook{fnmark/before}
+  \hook_use:n {fnmark/before}
 %-------
   \leavevmode
   \ifhmode
@@ -936,21 +1061,24 @@
 %                         (a bit less efficient)
 % memhfixc.sty
 % footmisc.sty
-    \UseHook{fnmark}
+    \hook_use:n {fnmark}
 %-------
     \nobreak
   \fi
 %-------
 % hyperref.sty
-  \UseHook{fnmark/begin}
+  \hook_use:n {fnmark/begin}
 %-------
-  \@kernel@process@makefnmark
-     \@makefnmark
+%    \end{macrocode}
+%    The kernel socket for tagging. It picks up \cs{@makefnmark} as its
+%    argument and if tagging is not active it contains the \plug{identity} plug.
+%    \begin{macrocode}
+  \socket_use:nn {tagsupport/fnmark} \@makefnmark
 %-------
 %    \end{macrocode}
 %    If a footnote mark is placed by its own then it should finish by
-%    executing \hook{fnmark/end}, resetting the space  factor, and
-%    finishing with \hook{fnmark/after}. However, in a complete
+%    executing the hook \hook{fnmark/end}, resetting the space  factor, and
+%    finishing with the  hook \hook{fnmark/after}. However, in a complete
 %    footnote these actions have to happen only after we have handled
 %    the footnote text (e.g., by placing it into an \cs{insert}). In
 %    such a situation \cs{_@@_footmark_finish:} below does nothing
@@ -961,9 +1089,10 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\@@_finish:,\@@_footnotemark_finish:}
+% \begin{macro}{\@@_footnotemark_default_finish:,\@@_footnotemark_finish:}
+%    The default definition for \cs{@@_footnotemark_finish:} is called \cs{@@_footnotemark_default_finish:}
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_finish: {
+\cs_new_protected:Npn \@@_footnotemark_default_finish: {
 % hyperref.sty
 % memhfixc.sty  --- could move fnmark/after
 % scrlttr2.cls  --- could vanish if footmisc uses a hook
@@ -978,20 +1107,24 @@
   \UseHook{fnmark/after}
 %-------
 }
-
-\cs_new_eq:NN \@@_footnotemark_finish: \@@_finish:
 %    \end{macrocode}
-% \end{macro}
 %
-% \begin{macro}{\@kernel@process@makefnmark}
-% Not a public config point but the kernel hook to add tagging
 %    \begin{macrocode}
-\def \@kernel@process@makefnmark { }
+\cs_new_eq:NN \@@_footnotemark_finish: \@@_footnotemark_default_finish:
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{socketdecl}{tagsupport/fnmark}
+%    Not a public socket but reserved for  tagging. By
+%    default it contains \plug{identity} and is reassigned if tagging is active.
+%    \begin{macrocode}
+\NewSocket{tagsupport/fnmark}{1}
+%    \end{macrocode}
+% \end{socketdecl}
+%
 % \begin{macro}{\@footnotemark}
-% At last provide the name \LaTeXe{} is used to.
+%    Here we provide the traditional \LaTeXe{} name in case it is directly used
+%    in some legacy class.
 %    \begin{macrocode}
 \cs_set_eq:NN  \@footnotemark \fnote_footnotemark:
 %    \end{macrocode}
@@ -1007,16 +1140,23 @@
   \@@_debug_footnotetext:
 %-------
 % ./linguex/linguex.sty
-  \UseHook{fntext/before}
+  \hook_use:n {fntext/before}
 %-------
-  \@kernel@process@footnotetext
-  \@footnotetext@cfgpoint {  % config point
+%    \end{macrocode}
+%    Execute a kernel socket for tagging.
+%    \begin{macrocode}
+  \socket_use:n {tagsupport/fntext/begin}
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+  \socket_use:nn {fntext/process}
+    {
 %-------
 % resetting baselinestretch ... (could be done further down)
 % ./uafthesis/uafthesis.cls
 % ./setspace/setspace.sty
 % ./footmisc/footmisc.sty (normal)
-    \UseHook{fntext}
+    \hook_use:n {fntext}
 %-------
     \reset@font
     \footnotesize
@@ -1046,84 +1186,144 @@
 % and \cs{@currentlabel} is that is necessary.
 %
 % ./resphilosophica/resphilosophica.cls
-    \UseHook{fntext/para}
+    \hook_use:n {fntext/para}
 %-------
     \color@begingroup
 %-------
-% fnpara wants to replace \@makefntext{...} and para and side option of footmisc etc too ...
-% so we make this a config point
+% fnpara wants to replace \@makefntext{...} and para and side
+% option of footmisc etc too ...
+% so we make this a socket, because only one action can be active:
 %-------
-      \@footnotetext@cfgpointii       % config point
+      \socket_use:nn {fntext/make}
         {
 %-------
 % ./resphilosophica/resphilosophica.cls
 %-------
-          \@footnotetext@cfgpointiii  % config point
+          \socket_use:n {fntext/begin}%
 %-------
 % bibarts
 % fnbreak.sty
-          \UseHook{fntext/begin}
+          \hook_use:n {fntext/begin}
 %-------
           \ignorespaces
           #1
 %-------
 % bibarts
 % fnbreak.sty
-          \UseHook{fntext/end}
+          \hook_use:n {fntext/end}
 %-------
-          \@footnotetext@cfgpointiv   % config point
+%    \end{macrocode}
+%    The socket code (by default adding a strut) has to come
+%    \emph{after} everything added into the hook above.
+%    \begin{macrocode}
+          \socket_use:n {fntext/end}
         }
       \par
     \color@endgroup
   }
 %-------
+%    \end{macrocode}
+%    The corresponding kernel hook that ends the tagging structure if
+%    tagging is active.
+%    \begin{macrocode}
+  \socket_use:n{tagsupport/fntext/end}
+%-------
 % ./linguex/linguex.sty
-  \UseHook{fntext/after}
+  \hook_use:n {fntext/after}
 %-------
 }
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\@footnotetext@cfgpoint}
-% default for config point (1 arg)
+% \begin{socketdecl}{fntext/process}
+%
 %    \begin{macrocode}
-\cs_new_protected:Npn \@footnotetext@cfgpoint    { \insert\footins }
+\NewSocket    {fntext/process}{1}
+\NewSocketPlug{fntext/process}{default}{ \insert\footins {#1} }
+\NewSocketPlug{fntext/process}{side}   { \marginpar {#1} }
 %    \end{macrocode}
-% \end{macro}
+%    
+%    \begin{macrocode}
+\AssignSocketPlug{fntext/process}{default}
+%    \end{macrocode}
+% \end{socketdecl}
 %
 %
-% \begin{macro}{\@footnotetext@cfgpointii}
-% default for config point (1 arg)
+%
+% \begin{socketdecl}{fntext/make}
+%    This socket receives the \meta{text} from the \cs{footnote} or
+%    \cs{footnotetext} and formats it.
 %    \begin{macrocode}
-\cs_new_protected:Npn \@footnotetext@cfgpointii  { \@makefntext }
+\NewSocket    {fntext/make}{1}
+\NewSocketPlug{fntext/make}{default}{ \@makefntext {#1} }
+%    \end{macrocode}
+%    When running several footnotes together as a paragraph some
+%    additional work is necessary to unbox the individual footnotes
+%    recursively (see \TeX{}book algorithm in appendix~D).
+%    \begin{macrocode}
+\NewSocketPlug{fntext/make}{para}
+{
+  \setbox\FN@tempboxa\hbox{\@makefntext{#1}}%
+  \dp\FN@tempboxa\z@
+  \ht\FN@tempboxa
+  \dimexpr\wd\FN@tempboxa *%
+             \footnotebaselineskip /\columnwidth\relax
+  \box\FN@tempboxa
+}
 %    \end{macrocode}
-% \end{macro}
 %
-% \begin{macro}{\@footnotetext@cfgpointiii}
-% default for config point (0 args)
 %    \begin{macrocode}
-\cs_new_protected:Npn \@footnotetext@cfgpointiii { \rule\z@\footnotesep }
+\AssignSocketPlug{fntext/make}{default}
 %    \end{macrocode}
-% \end{macro}
+% \end{socketdecl}
 %
-% \begin{macro}{\@footnotetext@cfgpointiv}
-% default for config point (0 args)
+% \begin{socketdecl}{fntext/begin}
+%    By default adds a strut at the start of the footnote text.
 %    \begin{macrocode}
-\cs_new_protected:Npn \@footnotetext@cfgpointiv  { \@finalstrut\strutbox }
+\NewSocket    {fntext/begin}{0}
+\NewSocketPlug{fntext/begin}{default}{ \rule\z@\footnotesep }
 %    \end{macrocode}
-% \end{macro}
 %
-% \begin{macro}{\@kernel@process@footnotetext}
-% kernel hook for tagging (2 args)
 %    \begin{macrocode}
-\cs_new_protected:Npn \@kernel@process@footnotetext {}
+\AssignSocketPlug{fntext/begin}{default}
 %    \end{macrocode}
-% \end{macro}
+% \end{socketdecl}
+%
+% \begin{socketdecl}{fntext/end}
+%    By default adds a strut at the end of the footnote text unless we
+%    are no longer in hmode.
+%    \begin{macrocode}
+\NewSocket    {fntext/end}{0}
+\NewSocketPlug{fntext/end}{default}{ \@finalstrut\strutbox }
+%    \end{macrocode}
+%    When running several footnotes together as a paragraph some
+%    additional glue has to be added between them.
+%    \begin{macrocode}
+\NewSocketPlug{fntext/end}{para}
+  {%
+           \strut
+           \penalty-10\relax
+           \hskip\footglue
+  }
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\AssignSocketPlug{fntext/end}{default}
+%    \end{macrocode}
+% \end{socketdecl}
+%
+% \begin{socketdecl}{tagsupport/fntext/begin,tagsupport/fntext/end}
+%    Kernel sockets for tagging.
+%    \begin{macrocode}
+\NewSocket{tagsupport/fntext/begin}{0}
+\NewSocket{tagsupport/fntext/end}{0}
+%    \end{macrocode}
+% \end{socketdecl}
 %
 % Provide the name \LaTeXe{} is used to and do this unconditionally
-%   (no patching of class code if any). This means that if a class provides it own
-%    definition that gets lost and if necessary needs to be handled
-%    with firstaid (or updating of the class).
+% (no patching of class code if any). This means that if a class
+% provides it own definition that gets lost and if necessary needs to
+% be handled with firstaid (or updating of the class).
 %    \begin{macrocode}
 \AddToHook{begindocument}
   {
@@ -1131,6 +1331,9 @@
   }
 %    \end{macrocode}
 %
+%
+%
+%
 % \subsection{The new \cs{@makefntext} command}
 %
 % \cs{footnotemargin} is the logic implemented by footmisc. Perhaps we
@@ -1147,57 +1350,85 @@
     \fi
   }
 %    \end{macrocode}
-
+%
+%
+%
+% 
 % \begin{macro}{\fnote_makefntext:n}
 %    \begin{macrocode}
 \cs_new_protected:Npn \fnote_makefntext:n #1 {
 %    \end{macrocode}
 %    Some classes in their redefinition for \cs{@makefntext} have
-%    places some paragraph parameters at this point, but those can
+%    placed some paragraph parameters at this point, but those can
 %    equally well go into the hook \hook{fntext/para}. We therefore do
 %    not provide a further hook at this point.
 %    \begin{macrocode}
-  \@makefntext@cfgpoint
-      {
-        \ifdim\footnotemargin>\z@
-          \hb@xt@ \footnotemargin{\hss\@makefnmark}
-        \else
-          \ifdim\footnotemargin=\z@
-            \llap{\@makefnmark}
-          \else
-          \ifdim\footnotemargin=-\maxdimen
-               \@makefnmark
-            \else
-               \llap{\hb@xt@ -\footnotemargin{\@makefnmark\hss}}
-            \fi
-          \fi
-        \fi
-      }
-  \@makefntext@cfgpointii
-      { #1 }
+  \noindent
+%    \end{macrocode}
+%    
+%    \begin{macrocode}
+  \socket_use:nn {tagsupport/fntext/mark} { \socket_use:n  {fntext/mark} } 
+  \socket_use:nn {tagsupport/fntext/text} { \socket_use:nn {fntext/text}{#1} } 
 }
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\@makefntext@cfgpoint}
-% default for config point (1 arg)
+% \begin{socketdecl}{fntext/mark}
+%    A socket to typeset the mark at the start of a footnote.
+%    \begin{macrocode}
+\NewSocket    {fntext/mark}{0}
+%    \end{macrocode}
+%    The \plug{default} plug implements the logic introduced with the
+%    \pkg{footmisc} package.
+%    \begin{macrocode}
+\NewSocketPlug{fntext/mark}{default}{
+   \ifdim\footnotemargin>\z@
+     \hb@xt@ \footnotemargin{\hss\@makefnmark}
+   \else
+     \ifdim\footnotemargin=\z@
+       \llap{\@makefnmark}
+     \else
+     \ifdim\footnotemargin=-\maxdimen
+          \@makefnmark
+       \else
+          \llap{\hb@xt@ -\footnotemargin{\@makefnmark\hss}}
+       \fi
+     \fi
+   \fi
+}
+%    \end{macrocode}
+%
 %    \begin{macrocode}
-\cs_new_protected:Npn \@makefntext@cfgpoint { \noindent }
+\AssignSocketPlug{fntext/mark}{default}
 %    \end{macrocode}
-% \end{macro}
+% \end{socketdecl}
 %
-% \begin{macro}{\@makefntext@cfgpointii}
-% default for config point (1 arg)
+% \begin{socketdecl}{fntext/text}
+%    By default this socket does nothing special and simply processes
+%    its argument as provided.
 %    \begin{macrocode}
-\cs_new_protected:Npn \@makefntext@cfgpointii #1 { #1 }
+\NewSocket    {fntext/text}{1}
 %    \end{macrocode}
-% \end{macro}
+% \end{socketdecl}
+%
+%
+%
+% \begin{socketdecl}{tagsupport/fntext/mark,tagsupport/fntext/text}
+%    Not a public socket but reserved for  tagging. By
+%    default it contains \plug{identity} and is reassigned if tagging is active.
+%    \begin{macrocode}
+\NewSocket{tagsupport/fntext/mark}{1}
+\NewSocket{tagsupport/fntext/text}{1}
+%    \end{macrocode}
+% \end{socketdecl}
+%
+%
 %
 % \subsubsection{Making documents use the new \cs{@makefntext}}
 %
 %  If the definition for \cs{@makefntext} is that of the standard
 %  classes then replace it with \cs{fnote_makefntext:n}, otherwise
-%  try to patch the definition.
+%  try to patch the definition used in the class.
 %
 %  Here is the definition the way it is in
 %  \texttt{classes.dtx}. Notice that (for saving space) there is no
@@ -1217,22 +1448,24 @@
 %
 %    Here is the messy code for patching. Note that this is only there
 %    to help classes along that aren't updated yet so it does some
-%    minimal patching to hopefully add configuration points in the
-%    right place.
+%    minimal patching to hopefully add kernel configuration hooks in the
+%    right place while otherwise leaving the legacy code alone. An
+%    updated class would not redefine \cs{@makefntext} but simply add
+%    appropriate code to the provided hooks.
 %
 %    What it does is roughly the
-%    following: It look for a definition of \cs{@makefntext} of the form
+%    following: It looks for a definition of \cs{@makefntext} of the form
 %\begin{verbatim}
 %  {AAA \hbox BBB { CCC } DDD #1 EEE }
 %\end{verbatim}
 %    where ``BBB'' is something like \texttt{to 1em} or similar. It then
 %    replaces that with
 %\begin{verbatim}
-%  {AAA \@makefntext@cfgpoint{\hbox BBB { CCC }} DDD
-%       \@makefntext@cfgpointii{#1} EEE }
+%  {AAA \UseSocket{tagsupport/fntext/mark}{\hbox BBB { CCC }} DDD
+%       \UseSocket{tagsupport/fntext/text}{#1} EEE }
 %\end{verbatim}
 %    The patching is not very careful, i.e., it assumes there is only
-%    one \verb=#1= in the replacement text and that a \cs{hbox} found
+%    one \verb=#1= in the replacement text and that the first \cs{hbox} found
 %    is the right one to patch. But that is enough to cater for all
 %    definitions of \cs{@makefntext} out there in the TL distribution.
 %
@@ -1247,7 +1480,7 @@
 
 \cs_new_protected:Npn \@@_patch:
   {
-    \tl_set:No \l_@@_patch_tl { \@makefntext { \@makefntext@cfgpointii{##1} } }
+    \tl_set:No \l_@@_patch_tl { \@makefntext { \UseSocket{tagsupport/fntext/text}{##1} } }
     \tl_if_in:NnTF \l_@@_patch_tl { \hbox }
       { \cs_set_eq:NN \@@_tmp:w \@@_patch_hbox:w }
       {
@@ -1268,7 +1501,7 @@
 %    \end{macrocode}
 %
 %    If \cs{@makefntext} contains \cs{hbox} then grab ``AAA'' as
-%    \verb=#1= and ``BBB'' (up to the open \verb={=)  and return it as
+%    \verb=#1= and ``BBB'' (up to the open \texttt{\{})  and return it as
 %\begin{verbatim}
 %   AAA  \@makefntext@processX { \hbox BBB }
 %\end{verbatim}
@@ -1291,12 +1524,13 @@
 %    not a patch person, so this is the simple way out for now:
 %
 %    \begin{macrocode}
-\cs_new:Npn \@makefntext@processX #1#2{\@makefntext@cfgpoint{#1{#2}}}
+\cs_new:Npn \@makefntext@processX #1#2{\UseSocket{tagsupport/fntext/mark}{#1{#2}}}
 %    \end{macrocode}
 %
 %    At \verb=\begin{document}= check if the current definition is
 %    that of the standard classes and if so replace it by
 %    \cs{fnote_makefntext:n} otherwise try and patch the definition
+%    made by some class or package
 %    using the approach above.
 %    \begin{macrocode}
 
@@ -1340,7 +1574,7 @@
     \fnote_step_fnmark:nn {#1} \@mpfn
     \cs_set_eq:NN \@@_footnotemark_finish: \prg_do_nothing:
     \@footnotemark
-    \cs_set_eq:NN \@@_footnotemark_finish: \@@_finish:
+    \cs_set_eq:NN \@@_footnotemark_finish: \@@_footnotemark_default_finish:
     \@footnotetext {#2}
     \@@_footnotemark_finish:
   }
@@ -1362,7 +1596,7 @@
 % \cs{footref} used the starred \cs{ref} in \cs{@thefnmark}
 % as the linking is handled by the tagging code inside
 % the \cs{@footnotemark}.
-% \cs{footref} should not try to link to its related related
+% \cs{footref} should not try to link to its related
 % note automatically but should instead use the label.
 % This is passed to \cs{@footnotemark} through
 % \cs{l__fnote_currentlabel_tl}.
@@ -1388,9 +1622,8 @@
 % Tagging of footnotes in minipages require a change in the minipage commands
 % We define at first a local configuration command for minipage footnotes.
 %
-% TODO remove the dependency to etoolbox, and need for the patch.
 %    \begin{macrocode}
-\cs_new_protected:Npn \@mpfootnotetext@cfgpoint #1
+\NewSocketPlug{fntext/process}{mp}
  {
    \global\setbox\@mpfootins\vbox{%
     \unvbox\@mpfootins
@@ -1398,16 +1631,6 @@
     }
  }
 %    \end{macrocode}
-% Then we patch \cs{@iiiminipage}
-%   \begin{macrocode}
-\RequirePackage{etoolbox}
-\ExplSyntaxOff
-\patchcmd\@iiiminipage
- {\let\@footnotetext\@mpfootnotetext}
- {\let\@footnotetext@cfgpoint\@mpfootnotetext@cfgpoint}
- {}{\ERROR}
-\ExplSyntaxOn 
-%    \end{macrocode}
 %
 % \subsubsection{\pkg{memoir}}
 % The \pkg{memoir} class redefines various internal commands to inject its
@@ -1484,35 +1707,28 @@
 % For \cs{footref} and (perhaps later for labeled footnotes)
 % we must extend the label system.
 % Beside the normal values we also need the structure number of the note.
-% We use the \pkg{nameref} hook until latex provides a hook for its label.
+% We use the inbuild label hook
 % At first we define a suitable attribute, it uses as value the structure
 % number of the note as stored in \cs{l__fnote_currentstruct_tl}
 %    \begin{macrocode}
 \ref_attribute_gset:nnnn {fnote/struct}{1}{now}{\l_@@_currentstruct_tl}
 %    \end{macrocode}
 %
-% We add a hook to the \pkg{nameref} hook. By default it does nothing
-% \begin{macro}{\@@_label_hook:}
+% We add a hook to the label hook. By default it does nothing
+% \begin{macro}{\@@_label_hook:n}
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_label_hook: {}
-\AddToHook{begindocument/before}
-  {
-    \RequirePackage{nameref}
-    \g@addto@macro\label@hook
-      {
-        \@@_label_hook:
-      }
-  }
+\cs_new_protected:Npn \@@_label_hook:n #1 {}
+\AddToHookWithArguments{label}{ \@@_label_hook:n{#1}}
 %    \end{macrocode}
 % \end{macro}
 % Inside a footnotetext we change the hook to store the structure number too.
-% nameref provides the name of label in \cs{label@name}.
+% The name of label is provided as argument in the label hook.
 %    \begin{macrocode}
 \AddToHook{fntext/begin}
  {
-   \cs_set_protected:Npn \@@_label_hook:
+   \cs_set_protected:Npn \@@_label_hook:n #1
     {
-      \ref_label:Vn \label@name {fnote/struct}
+      \ref_label:nn {#1} {fnote/struct}
     }
  }
 %    \end{macrocode}
@@ -1526,7 +1742,7 @@
 % tabular notes, other footnote series) to make use of this.
 %
 %
-% \begin{macro}{\fnote_new:nn}
+% \begin{macro}{\fnote_class_new:nn}
 % This sets up a new footnote type, the first argument
 % is the name, the second is meant for options. Currently
 % it does nothing at all.
@@ -1534,19 +1750,19 @@
 % command as its own type!
 %
 %    \begin{macrocode}
-\cs_new_protected:Npn \fnote_new:nn #1 #2 % #1 name, #2 options
+\cs_new_protected:Npn \fnote_class_new:nn #1 #2 % #1 name, #2 options
  {
    \prop_new:c { g_@@_currentmarks_ #1 _prop }
  }
 
-\fnote_new:nn {default}{}
+\fnote_class_new:nn {default}{}
 %    \end{macrocode}
 % \end{macro}
 %
 %
 % \begin{macro}{\fnote_mark_gput:nn}
-% This commands takes as argument the representation of the mark
-% (e.g. \cs{@thefnmark} and the type (typically default should work)
+% This commands takes as argument the representation of the mark,
+% e.g., \cs{@thefnmark} and the type (typically default should work).
 %    \begin{macrocode}
 \cs_new_protected:Npn \fnote_mark_gput:nn #1 #2 % #1 the representation of the mark, #2 type
  {
@@ -1559,13 +1775,13 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\fnote_mark_gpop:nnN}
+% \begin{macro}{\fnote_mark_gpop_all:nnN}
 % This commands takes as argument the representation of the mark
-% (e.g. the content of\cs{@thefnmark}), the series (typically default should work)
+% (e.g. the content of\cs{@thefnmark}), the class (typically |default| should work)
 % and a sequence into which every structure number in the property
-% is stored that has the same value as the mark
+% is stored that has the same value as the mark. The sequence is cleared first.
 %    \begin{macrocode}
-\cs_new_protected:Npn \fnote_mark_gpop:nnN #1 #2 #3
+\cs_new_protected:Npn \fnote_mark_gpop_all:nnN #1 #2 #3
   {
     \seq_clear:N #3
     \prop_set_eq:Nc     \l_@@_tmpa_prop { g_@@_currentmarks_ #2 _prop }
@@ -1584,20 +1800,28 @@
           }
       }
   }
-\cs_generate_variant:Nn\fnote_mark_gpop:nnN  {ooN}
+\cs_generate_variant:Nn\fnote_mark_gpop_all:nnN  {ooN}
 %    \end{macrocode}
 % \end{macro}
-
-
+%
+%
+%
+%
 % \subsubsection{Enabling tagging and links for the mark command}
-% To handle the mark in the text, we define a special command
-% which will surround \cs{@makefntext}.
-% At this time \cs{@thefnmark} is already set.
+%
+%
+% \begin{plugdecl}{FEMark}
+%
+%    To handle the mark in the text, we define a special plug for
+%    the socket \socket{tagsupport/fnmark} that receives
+%    \cs{@makefntext} as its argument.  At this time \cs{@thefnmark}
+%    is already set.
+%
 %    \begin{macrocode}
-\cs_new_protected:Npn \tag@FEMark #1  %#1 content
+\NewSocketPlug{tagsupport/fnmark}{FEMark}
   {
 %    \end{macrocode}
-% end an open mc and start the structure.
+%    End an open mc and start the structure.
 %    \begin{macrocode}
     \tag_mc_end_push:
     \tag_struct_begin:n { tag=footnotemark }
@@ -1658,11 +1882,15 @@
     \tag_mc_begin_pop:n{}
    }
 %    \end{macrocode}
-% At last set the kernel command to this one
+% At last assign the plug:
 %    \begin{macrocode}
-\cs_set_eq:NN \@kernel@process@makefnmark \tag@FEMark
+\AssignSocketPlug{tagsupport/fnmark}{FEMark}
 %    \end{macrocode}
-
+% \end{plugdecl}
+%
+%
+%
+%
 % \subsubsection{The footnote text}
 
 % We need a public command to append values to the Ref keys
@@ -1688,11 +1916,13 @@
 \tl_new:N \l_@@_dflt_struct_tl
 \tl_set:Nn \l_@@_dflt_struct_tl {1}
 %    \end{macrocode}
-% kernel hook for tagging (2 args)
+% kernel hooks for taggin
 % this sets the structure around the whole text
 %
+%
+% \begin{plugdecl}{FENote}
 %    \begin{macrocode}
-\cs_new_protected:Npn \tag@FENote #1#2 % #1 config point, \insert\footins  #2 content
+\NewSocketPlug{tagsupport/fntext/begin}{FENote}
   {
     \tag_mc_end_push:
 %    \end{macrocode}
@@ -1724,7 +1954,7 @@
 %    \end{macrocode}
 % find open marks with identical \cs{@thefnmark}
 %    \begin{macrocode}
-        \fnote_mark_gpop:ooN { \@thefnmark }{ \l_fnote_type_tl } \l_@@_currentrefs_seq
+        \fnote_mark_gpop_all:ooN { \@thefnmark }{ \l_fnote_type_tl } \l_@@_currentrefs_seq
 %    \end{macrocode}
 % Then we store the object numbers of the marks in the /Ref of the FENote structure:
 % and the number of the FEnote into the marks structure:
@@ -1744,57 +1974,62 @@
       {%no auto
 
       }
+  }
 %    \end{macrocode}
 % This finish the setup of the tagging structure.
+% \end{plugdecl}
+
+
+
 % Now we process the text. The destinations for the links are set with the label
 % so that we can be sure that we are in hmode.
 %    \begin{macrocode}
-      #1 {#2}
+\NewSocketPlug{tagsupport/fntext/end}{FENote}
+  {
     \tag_struct_end:
     \tag_mc_begin_pop:n{}
   }
 %    \end{macrocode}
-% At last set the kernel command to this one
+% At last assign the plugs:
 %    \begin{macrocode}
-\cs_set_eq:NN \@kernel@process@footnotetext \tag@FENote
+\AssignSocketPlug{tagsupport/fntext/begin}{FENote}  
+\AssignSocketPlug{tagsupport/fntext/end}{FENote}  
 %    \end{macrocode}
 %
-% \cs{@makefntext@cfgpoint} is the configuration point responsible for
-% typesetting the mark in the note. We use it to surround
+% The kernel socket \socket{tagsupport/fntext/mark} is  responsible for
+% tagging the mark in the note. We use it to surround
 % the mark with the needed tagging commands.
 %
-% TODO check if this should/can be kernel configuration points
-% or if an additional kernel configuration points are needed.
+% TODO check if additional kernel configuration points are needed.
 % If yes, what about the paragraph start and the paratagging??
 %
-%    \begin{macrocode}
-\cs_set_protected:Npn \@makefntext@cfgpoint #1 %#1 code that typesets the mark.
-  {
-    \noindent
-    \tag_mc_end_push:
-    \tag@FENoteLbl { #1 }
-    \tag_mc_begin_pop:n{}
-  }
-%    \end{macrocode}
-% \cs{tag@FENoteLbl} creates the label in the note on the bottom.
-% It also adds link targets for the hyperlinking.
 %
-% \begin{macro}{\tag@FENoteLbl}
+%
+%^^A      If tagging is produced this configuration point is also
+%^^A      responsible for surrounding the mark with the appropriate tags
+%^^A      marking the mark as an Lbl. It does this using the 
+%^^A      \socket{tagsupport/fntext/mark} socket.
+%
+% \begin{plugdecl}{FENoteLbl}
+%    This plug creates the label in the note on the bottom.
+%    It also adds link targets for the hyperlinking.
 %    \begin{macrocode}
-\cs_new_protected:Npn \tag@FENoteLbl #1
+\NewSocketPlug{tagsupport/fntext/mark}{FENoteLbl}
   {
+    \tag_mc_end_push:
 %    \end{macrocode}
-% We create a link target for every related mark. The name is footnote* + structure number
-% of the mark. We also add a link target for the current structure (for footref)
+%     We create a link target for every related mark. The name is
+%    \texttt{footnote*} \meta{structure number of the mark}. We also add a link
+%    target for the current structure (for \cs{footref}).
 %    \begin{macrocode}
      %\seq_show:N\l_@@_currentrefs_seq
      \seq_map_inline:Nn\l_@@_currentrefs_seq {\MakeLinkTarget*{footnote*.##1}}
      \MakeLinkTarget*{footnote*.\l_@@_currentstruct_tl}
 %    \end{macrocode}
-% now we add the tagging commands. We move the structure of the label to
-% to the container at the begin of the note.
+%    Now we add the tagging commands. We move the structure of the label to
+%    to the container at the begin of the note.
 % \begin{NOTE}{UF}
-% check if the NonStruct is really needed. Perhaps we can simply move the mc.
+%   Check if the NonStruct is really needed. Perhaps we can simply move the mc.
 % \end{NOTE}
 %    \begin{macrocode}
      \tag_struct_begin:n { tag=NonStruct,parent=\l_@@_currentstruct_tl +1 }
@@ -1802,37 +2037,43 @@
        #1
       \tag_mc_end:
      \tag_struct_end:
+    \tag_mc_begin_pop:n{}
   }
 %    \end{macrocode}
-% \end{macro}
-%
-%
-%  \cs{@makefntext@cfgpointii} is the
-%  configuration point around the actual note text.
 %
-%  TODO check if this should/can be kernel configuration points
 %    \begin{macrocode}
-\cs_set_protected:Npn \@makefntext@cfgpointii #1
-  {
-    \tag_mc_end_push:
-    \tag@FENotetext { #1 }
-    \tag_mc_begin_pop:n{}
-  }
+\AssignSocketPlug{tagsupport/fntext/mark}{FENoteLbl}
 %    \end{macrocode}
-% \begin{macro}{\tag@FENotetext}
+% \end{plugdecl}
+%
+%
+%^^A      If tagging is produced this configuration point is also
+%^^A      responsible for surrounding the mark with the appropriate tags
+%^^A      marking the mark as an MC of type FENote. It does this using
+%^^A      the socket \socket{tagsupport/fntext/text}.
 %
-% This command currently only adds an MC chunk,
+% \begin{plugdecl}{FENotetext}
+%
+%    This plug is for the kernel socket \socket{tagsupport/fntext/text} 
+%    around the actual note text when doing tagging.
+%    Currently it only adds an MC chunk.
 %
 % TODO Should it set a mc or could it rely on the content?
 %    \begin{macrocode}
-\cs_new_protected:Npn \tag@FENotetext #1
+\NewSocketPlug{tagsupport/fntext/text}{FENotetext}
   {
+    \tag_mc_end_push:
     \tag_mc_begin:n{}
     #1
     \tag_mc_end:
+    \tag_mc_begin_pop:n{}
   }
 %    \end{macrocode}
-% \end{macro}
+%
+%    \begin{macrocode}
+\AssignSocketPlug{tagsupport/fntext/text}{FENotetext}
+%    \end{macrocode}
+% \end{plugdecl}
 %-------------------------------------
 
 %    \begin{macrocode}
@@ -1849,7 +2090,7 @@
 %<*footmisc>
 %%
 %% Copyright (c) 1995-2011 Robin Fairbairns
-%% Copyright (c) 2018-2022 Robin Fairbairns, Frank Mittelbach
+%% Copyright (c) 2018-2023 Robin Fairbairns, Frank Mittelbach
 %%
 %% This file is part of the `latex-lab Bundle'.
 %% --------------------------------------------
@@ -1864,9 +2105,6 @@
 %%
 %% This work has the LPPL maintenance status 'maintained'.
 %%
-%%
-%% File: footmisc.dtx (C) Copyright 1995-2011 Robin Fairbairns
-%%                    (C) Copyright 2018-2022 Frank Mittelbach
 \NeedsTeXFormat{LaTeX2e}
 \providecommand\DeclareRelease[3]{}
 \providecommand\DeclareCurrentRelease[2]{}
@@ -1916,14 +2154,14 @@
                             option "para"}%
                  {I shall ignore "\CurrentOption"}%
   \else
-    \def\@footnotetext@cfgpoint {\marginpar}
     \AddToHook{fntext/para}{%
       \hsize\marginparwidth     % correct the default \hsize
       \footnotesep\z@           % don't add a default separation
     }
-    \def\@footnotetext@cfgpointii  {\@makefntext}
-    \def\@footnotetext@cfgpointiii {}
-    \def\@footnotetext@cfgpointiv  {}
+    \AssignSocketPlug{fntext/process}{side}
+%   \AssignSocketPlug{fntext/make}{default}
+    \AssignSocketPlug{fntext/begin}{noop}
+    \AssignSocketPlug{fntext/end}{noop}
   \fi
 }
 \let\footnotelayout\@empty
@@ -1992,25 +2230,16 @@
 \DeclareOption{multiple}{\FN@multiplefootnotetrue}
 \ProcessOptions
 %    \end{macrocode}
-%    This version of \pkg{footmisc} can assume that the new OR code is
-%    already available, thus nothing needs loading at this
-%    point. However, as long as we use this code also in a package
-%    version that can be loaded by other package while we are in a
-%    transition phase it is not clear whether not the kernel code is
-%    already available for other packages.
-%    \begin{macrocode}
-%\@ifundefined{@kernel@before@cclv}
-%  {\input{latex-lab-new-or.ltx}}{}
-%    \end{macrocode}
 %
 %    Footnote box layout for para footnotes;
 %    this would also be the hook to support dblfootnotes (from the
 %    \texttt{dblfnote} package if we integrate that).
 %    \begin{macrocode}
 \ifFN@para
-  \def\@makecol@cfgpointii {%
+  \NewSocketPlug{@makecol/footnotes}{para}{%
      \global\setbox\footins\vbox{\FN@makefootnoteparagraph}%
     }
+  \AssignSocketPlug{@makecol/footnotes}{para}
 \fi
 %    \end{macrocode}
 %
@@ -2038,64 +2267,29 @@
 %    \end{macrocode}
 %
 %
-%
 %    \begin{macrocode}
 \ifcase \FN@bottomcases\relax
-\ERROR
-\or
+  \ERROR
+\or %1
   \ifFN@abovefloats
-    \def\@makecol@cfgpoint {%
-       \@if@footnotes@TF
-          {\@outputbox@append{\vfill}}%
-          {\@if@bfloats@TF{\@outputbox@append{\vfill}}%
-                          {\@outputbox@reinsertbskip}}%
-       \@outputbox@appendfootnotes
-       \@outputbox@attachfloats
-      }
+    \AssignSocketPlug {@makecol/outputbox}{space-footnotes-floats}
   \else
-    \def\@makecol@cfgpoint {%
-       \@outputbox@attachfloats
-       \@if@footnotes@TF
-          {\@outputbox@append{\vfill}}%
-          {\@outputbox@reinsertbskip}%
-       \@outputbox@appendfootnotes
-    }
+    \AssignSocketPlug {@makecol/outputbox}{floats-footnotes-space}
   \fi
-\or
+\or %2
   \ifFN@abovefloats
-     \def\@makecol@cfgpoint {%
-        \@outputbox@appendfootnotes
-        \@if@bfloats@TF
-            {\@outputbox@append{\vfill}}%
-            {\@outputbox@reinsertbskip}%
-        \@outputbox@attachfloats
-     }
+    \AssignSocketPlug {@makecol/outputbox}{footnotes-space-floats}
   \else
-     \def\@makecol@cfgpoint {%
-       \@if@footnotes@TF
-          {\@outputbox@append{\vfill}}%
-          {\@if@bfloats@TF{\@outputbox@append{\vfill}}%
-                          {\@outputbox@reinsertbskip}}%
-        \@outputbox@attachfloats
-        \@outputbox@appendfootnotes
-     }
+    \AssignSocketPlug {@makecol/outputbox}{space-floats-footnotes}
   \fi
-\or
+\or %3
   \ifFN@abovefloats
-    \def\@makecol@cfgpoint {%
-       \@outputbox@appendfootnotes
-       \@outputbox@attachfloats
-       \@outputbox@reinsertbskip
-    }
+    \AssignSocketPlug {@makecol/outputbox}{footnotes-floats}
   \else
-    \def\@makecol@cfgpoint {%
-       \@outputbox@attachfloats
-       \@outputbox@appendfootnotes
-       \@outputbox@reinsertbskip
-}
+    \AssignSocketPlug {@makecol/outputbox}{floats-footnotes}
   \fi
 \else
-\ERROR
+  \ERROR
 \fi
 
 % next can be dropped when cleaned up
@@ -2120,24 +2314,12 @@
 
 
 \ifFN@para
-  \def\@footnotetext@cfgpoint {\insert\footins}
 
-  \long\def\@footnotetext@cfgpointii #1{%
-    \setbox\FN@tempboxa\hbox{\@makefntext{#1}}%
-    \dp\FN@tempboxa\z@
-    \ht\FN@tempboxa
-      \dimexpr\wd\FN@tempboxa *%
-              \footnotebaselineskip /\columnwidth\relax
-    \box\FN@tempboxa
-  }
-
-
-  \def\@footnotetext@cfgpointiii {}
-  \def\@footnotetext@cfgpointiv {% config point
-           \strut
-           \penalty-10\relax
-           \hskip\footglue
-  }
+% \AssignSocketPlug{fntext/process}{default}
+  \AssignSocketPlug{fntext/make}{para}
+  \AssignSocketPlug{fntext/begin}{noop}
+  \AssignSocketPlug{fntext/end}{para}
+  
 \fi
 
 
@@ -2211,7 +2393,7 @@
 %    perpage is loaded this results in updating counters on the reset
 %    list to 1 (or to a higher starting value if \cs{MakePerPage} is
 %    used with an optional argument, which is precisely the problem
-%    here. By subtracting 1 in that case we set it back to 1 lower
+%    here). By subtracting 1 in that case we set it back to 1 lower
 %    than the starting value.
 %
 %    But to make this fully work we also need to update a support
@@ -2236,10 +2418,7 @@
 %}
 
 
-\AddToHook{fntext/begin}{\nobreak \hspace{.2em}}
-
-
-
+  \AddToHook{fntext/begin}{\nobreak \hspace{.2em}}
 
 \else
 
@@ -2296,7 +2475,11 @@
 
 \ifFN@multiplefootnote
   \providecommand*{\multiplefootnotemarker}{3sp}
-% we tag the separator as artifact
+%    \end{macrocode}
+%    
+% We tag the separator as artifact
+% \fmi{why is this done with \cs{providecommand}?}
+%    \begin{macrocode}
   \ExplSyntaxOn
   \providecommand*{\multfootsep}{\tag_mc_end_push:\tag_mc_begin:n{artifact},\tag_mc_end:\tag_mc_begin_pop:n{}}
   \ExplSyntaxOff
@@ -2526,7 +2709,7 @@
     {\mathparagraph\mathparagraph\mathparagraph}%
 }
 \newcommand\mpfootnotemark{%
-  \@ifnextchar[%
+  \@ifnextchar[%]
     \@xmpfootnotemark
     {%
       \stepcounter\@mpfn
-- 
cgit v1.2.3

