Subject: Re: bug#55511: 13.1.3; TeX-auto-store issues with complex paths

From: Ikumi Keita <[email-masked]>
Date: Sun, 22 May 2022 18:09:07 +0900

Hi Cyril,

>>>>> Cyril Arnould <[email-masked]> writes:
>> I'm not sure whether there is smart solution for this matter.
> Maybe there should be an "auto" folder at every .tex file location instead
> of only in the master location, I imagine this could solve a few of the
> issues.

Ah, yes, you are right. I was confusing with the case generating support
files for such as 'example.dtx', 'example.sty', 'example.drv' and
'example.bib', all in the same directory.

> The path to the .el file would have to be constructed using
> "../", then the path to the included file, then "auto/" and finally the
> filename.

Yes, and that's already implemented. AUCTeX searches support files under
each those "auto/" (and "stlye/") subdirectories and load them if found.

With respect to the main issue of this bug#55511, I think the attached
patch would solve the problem. Could you test it if possible?

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine

diff --git a/latex.el b/latex.el
index 8bdbc94b..a6a775a8 100644
--- a/latex.el
+++ b/latex.el
@@ -52,7 +52,6 @@
 
 ;; Silence the compiler for variables:
 (defvar outline-heading-alist)
-(defvar TeX-auto-file)
 (defvar LaTeX-section-list-changed)
 
 ;;; Syntax
@@ -1779,7 +1778,7 @@ This is necessary since index entries may contain commands and stuff.")
        ("\\\\newenvironment\\*?{\\([^}]+\\)}"
         1 LaTeX-auto-environment)
        (,(concat "\\\\newtheorem{\\(" token "+\\)}") 1 LaTeX-auto-environment)
-       ("\\\\input{\\(\\.*[^#}%\\\\\\.\n\r]+\\)\\(\\.[^#}%\\\\\\.\n\r]+\\)?}"
+       ("\\\\input{\"?\\([^#}%\"\\\n\r]+?\\)\\(?:\\.[^#}%/\"\\.\n\r]+\\)?\"?}"
         1 TeX-auto-file)
        ("\\\\include{\\(\\.*[^#}%\\\\\\.\n\r]+\\)\\(\\.[^#}%\\\\\\.\n\r]+\\)?}"
         1 TeX-auto-file)
diff --git a/tex.el b/tex.el
index 1a3338c7..8b76f98d 100644
--- a/tex.el
+++ b/tex.el
@@ -3841,6 +3841,10 @@ The algorithm is as follows:
 (defconst TeX-auto-parser-local 3)
 (defconst TeX-auto-parser-change 4)
 
+(defvar TeX-auto-file nil)
+;; Internal temporal variable.  Don't refer to it in your program
+;; unless you know what you are doing.  Use (TeX-style-list) instead.
+
 (defun TeX-auto-add-information (name entries)
   "For NAME in `TeX-auto-parser' add ENTRIES."
   (let* ((entry (assoc name TeX-auto-parser))
@@ -4227,7 +4231,7 @@ alter the numbering of any ordinary, non-shy groups.")
        1 TeX-auto-symbol)
       (,(concat "\\\\newfont{?\\\\\\(" token "+\\)}?") 1 TeX-auto-symbol)
       (,(concat "\\\\typein\\[\\\\\\(" token "+\\)\\]") 1 TeX-auto-symbol)
-      ("\\\\input +\\(\\.*[^#%\\\\\\.\n\r]+\\)\\(\\.[^#%\\\\\\.\n\r]+\\)?"
+      ("\\\\input +\\([^#}%\"\\\n\r]+?\\)\\(?:\\.[^#}%/\"\\.\n\r]+\\)?"
        1 TeX-auto-file)
       (,(concat "\\\\mathchardef\\\\\\(" token "+\\)[^a-zA-Z@]")
        1 TeX-auto-symbol)))