[latex3-commits] [l3svn] 02/02: Correct value of \g_file_current_name_str

noreply at latex-project.org noreply at latex-project.org
Tue Jun 20 08:22:09 CEST 2017


This is an automated email from the git hooks/post-receive script.

joseph pushed a commit to branch master
in repository l3svn.

commit ef63488567c600053c9982237f8527b520719d38
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Jun 20 07:16:02 2017 +0100

    Correct value of \g_file_current_name_str
    
    This largely relies on the fact that LaTeX2e already tracks the
    value in the preamble using \@pushfilename/\@popfilename. To grab the
    'new' values we have to do a bit of cheating, relying on the fact that
    \@pushfilename is always followed by
    
        \xdef\@currname{#1}%
    
    Currently, there is no attempt to pick up from \input or similar:
    that needs something like the filehooks package and is likely too
    invasive at the LaTeX2e for us.
---
 l3kernel/expl3.dtx  |   13 +++++++++++++
 l3kernel/l3file.dtx |   29 ++++++++++++++++++++++++++++-
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/l3kernel/expl3.dtx b/l3kernel/expl3.dtx
index cc7493c..fda4f95 100644
--- a/l3kernel/expl3.dtx
+++ b/l3kernel/expl3.dtx
@@ -1509,6 +1509,7 @@
 %    \begin{macrocode}
 \tl_put_left:Nn \@pushfilename
   {
+    \seq_gpush:Nx \g__file_stack_seq \@currname
     \tl_put_left:Nx \l__expl_status_stack_tl
       {
         \bool_if:NTF \l__kernel_expl_bool
@@ -1516,9 +1517,21 @@
           { 0 }
       }
     \ExplSyntaxOff
+    \@pushfilenameaux
+  }
+%    \end{macrocode}
+%   This bit of trickery is needed to grab the name of the file being loaded
+%   so we can record it.
+%    \begin{macrocode}
+\cs_set_protected:Npn \@pushfilenameaux #1#2#3
+  {
+    \str_gset:Nn \g_file_current_name_str {#3}
+    #1 #2 {#3}
   }
 \tl_put_right:Nn \@popfilename
   {
+    \seq_gpop:NN \g__file_stack_seq \l__file_tmp_tl
+    \tl_gset_eq:NN \g_file_current_name_str \l__file_tmp_tl
     \tl_if_empty:NTF \l__expl_status_stack_tl
       { \ExplSyntaxOff }
       { \exp_after:wN \__expl_status_pop:w \l__expl_status_stack_tl \q_stop }
diff --git a/l3kernel/l3file.dtx b/l3kernel/l3file.dtx
index f84f8f1..8432623 100644
--- a/l3kernel/l3file.dtx
+++ b/l3kernel/l3file.dtx
@@ -688,9 +688,36 @@
 % \end{variable}
 %
 % \begin{variable}{\g_@@_stack_seq}
-%   The input list of files is stored as a sequence stack.
+%   The input list of files is stored as a sequence stack. In package
+%   mode we can recover the information from the details held by
+%   \LaTeXe{} (we must be in the preamble and loaded using \tn{usepackage}
+%   or \tn{RequirePackage}).
 %    \begin{macrocode}
 \seq_new:N \g_@@_stack_seq
+%<*package>
+\group_begin:
+  \cs_set_protected:Npn \@@_tmp:w #1#2#3
+    {
+      \tl_if_blank:nTF {#1}
+        {
+          \cs_set:Npn \@@_tmp:w ##1 " ##2 " ##3 \q_stop { ##2 }
+          \seq_gput_right:Nx \g_@@_stack_seq
+            {
+              \exp_after:wN \exp_after:wN \exp_after:wN
+              \@@_tmp:w
+                \exp_after:wN \tex_jobname:D
+                \exp_after:wN " \tex_jobname:D "
+                \q_stop
+            }
+        }
+        {
+          \seq_gput_right:Nn \g_@@_stack_seq {#1}
+          \@@_tmp:w
+        }
+    }
+  \exp_after:wN \@@_tmp:w \@currnamestack
+\group_end:
+%</package>
 %    \end{macrocode}
 % \end{variable}
 %

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the latex3-commits mailing list