[latex3-commits] [git/LaTeX3-latex3-latex3] gh450: Change how special cases such as \l_tmpa_tl are detected (fixes #450) (8ee35d312)

Bruno Le Floch blflatex at gmail.com
Tue Apr 27 17:09:08 CEST 2021


Repository : https://github.com/latex3/latex3
On branch  : gh450
Link       : https://github.com/latex3/latex3/commit/8ee35d31293a82a71e822b0f404cd5e1668276a4

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

commit 8ee35d31293a82a71e822b0f404cd5e1668276a4
Author: Bruno Le Floch <blflatex at gmail.com>
Date:   Fri Apr 23 21:16:00 2021 +0200

    Change how special cases such as \l_tmpa_tl are detected (fixes #450)
    
    Now we have a fixed list of words (alignment, tmpa, ...) that cannot
    end up as modules for the purpose of the l3doc index.  When indexing
    \c_alignment_token or \l_tmpa_seq or similar, the last word is taken
    as the module instead of the first word.  But for \l_mymodule_tl,
    since "mymodule" is not in our list, the variable ends up classified
    as belonging to mymodule.


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

8ee35d31293a82a71e822b0f404cd5e1668276a4
 l3kernel/l3doc.dtx | 52 +++++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 41 insertions(+), 11 deletions(-)

diff --git a/l3kernel/l3doc.dtx b/l3kernel/l3doc.dtx
index 965fd8026..4a7bd34af 100644
--- a/l3kernel/l3doc.dtx
+++ b/l3kernel/l3doc.dtx
@@ -4373,11 +4373,18 @@ and all files in that bundle must be distributed together.
 %   otherwise use the part before any underscore as the module name.
 %   For variables, distinguish quarks and scan marks (starting with |q|
 %   and~|s|), then drop the first letter (local/global/constant marker)
-%   and underscores.  If there is no underscore left we had something
-%   like \cs{c_zero} which we assume is an integer constant.  If there
-%   is one underscore we assume it is a variable like \cs{c_empty_tl}
-%   whose module name is the last part.  Otherwise the module name is
-%   the part before any underscore.
+%   and underscores to improve the index sorting.
+%   Then get the module as the first (underscore-delimited) \enquote{word}.
+%   In the past, we distinguished according to how many such words there
+%   were, to detect commands like \cs[no-index]{c_zero}, which should be
+%   sorted as |int| variables, and \cs[no-index]{l_tmpa_dim}, which should
+%   be sorted in the |dim| and not the |tmpa| module.
+%   Now the first case has been deprecated for some time, while |tmpa| and
+%   similar are special-cased through an explicit list given below.
+%   The way it works is that if the module is in a list of special names
+%   that are not valid modules, then we try the last word, and if that
+%   also fails (for instance in the deprecated \cs[no-index]{c_one_hundred})
+%   we empty the module completely.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_key_var:
   {
@@ -4396,15 +4403,14 @@ and all files in that bundle must be distributed together.
           {
             \seq_set_split:NoV \l_@@_tmpa_seq
               { \token_to_str:N _ } \l_@@_index_key_tl
-            \__kernel_tl_set:Nx \l_@@_index_module_tl
+            \seq_get_left:NN \l_@@_tmpa_seq \l_@@_index_module_tl
+            \clist_if_in:NoT \g_@@_non_modules_clist \l_@@_index_module_tl
               {
-                \int_case:nnF { \seq_count:N \l_@@_tmpa_seq }
+                \seq_get_right:NN \l_@@_tmpa_seq \l_@@_index_module_tl
+                \clist_if_in:NoT \g_@@_non_modules_clist \l_@@_index_module_tl
                   {
-                    { 0 } { }
-                    { 1 } { int }
-                    { 2 } { \seq_item:Nn \l_@@_tmpa_seq { 2 } }
+                    \tl_clear:N \l_@@_index_module_tl
                   }
-                  { \seq_item:Nn \l_@@_tmpa_seq { 1 } }
               }
           }
       }
@@ -4416,6 +4422,30 @@ and all files in that bundle must be distributed together.
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{variable}{\g_@@_non_modules_clist}
+%   List of names that appear as the first word in an \pkg{expl3}
+%   command, but that are not true modules, so that they should be
+%   sorted differently in an index.
+%    \begin{macrocode}
+\clist_new:N \g_@@_non_modules_clist
+\clist_gset:Nx \g_@@_non_modules_clist
+  {
+    \tl_to_str:n
+      {
+
+        alignment, ampersand, atsign, backslash, catcode, circumflex,
+        code, colon, document, dollar, e, empty, false, hash, inf,
+        initex, job, left, log, math, mark, max, minus, nan, nil, no,
+        novalue, other, parameter, percent, pi, recursion, right, space,
+        stop, term, tilde, tmpa, tmpb, true, underscore, zero, one, two,
+        three, four, five, six, seven, eight, nine, ten, eleven, twelve,
+        thirteen, fourteen, fifteen, sixteen, thirty, hundred
+
+      }
+  }
+%    \end{macrocode}
+% \end{variable}
+%
 % \subsection{Change history}
 %
 % Set the change history to use \tn{part}.





More information about the latex3-commits mailing list.