Subject: bug#71240: Keeping track of class and packages, even w/o options

From: Arash Esbati <[email-masked]>
Date: Tue, 28 May 2024 12:06:23 +0200

Hi all,

currently, AUCTeX keeps track of options given to packages and/or
documentclass in `LaTeX-provided-package-options' and
`LaTeX-provided-class-options' respectively.  No entries are added to
the variables if the packages/documentclass are loaded without options.
This is Ok in general, but things get complicated when we want to have a
style file where both package and class have the same name, e.g.:

  texmf-dist/tex/latex/standalone/standalone.cls
  texmf-dist/tex/latex/standalone/standalone.sty

We have to cater for different set of macros inside one style, so
something like this:

  (TeX-add-style-hook
   "standalone"
   (lambda ()
     ;; standalone.cls
     (when (assoc "standalone" LaTeX-provided-class-options)
       (TeX-add-symbols '(...)))

     ;; standalone.sty
     (when (assoc "standalone" LaTeX-provided-package-options)
       ...)))

which currently doesn't work because if the package or class are loaded
without options.  I suggest the following change to
`LaTeX-auto-cleanup':

--8<---------------cut here---------------start------------->8---
diff --git a/latex.el b/latex.el
index d0a9ee6f..8844fdc4 100644
--- a/latex.el
+++ b/latex.el
@@ -2168,9 +2168,8 @@ TYPE is one of the symbols mac or env."
               (add-to-list 'TeX-auto-file elt t)
               ;; Append to `LaTeX-provided-package-options' the name of the
               ;; package and the options provided to it at load time.
-              (unless (equal options '(""))
-                (TeX-add-to-alist 'LaTeX-provided-package-options
-                                  (list (cons elt options)))))
+              (TeX-add-to-alist 'LaTeX-provided-package-options
+                                (list (cons elt options))))
           ;; And a special "art10" style file combining style and size.
           (add-to-list 'TeX-auto-file style t)
           (add-to-list 'TeX-auto-file
@@ -2201,9 +2200,8 @@ TYPE is one of the symbols mac or env."
                               (t
                                "10")))
                        t)
-          (unless (equal options '(""))
-            (TeX-add-to-alist 'LaTeX-provided-class-options
-                              (list (cons style options)))))
+          (TeX-add-to-alist 'LaTeX-provided-class-options
+                            (list (cons style options))))

         ;; The third argument if "class" indicates LaTeX2e features.
         (cond ((or (string-equal class "class")
--8<---------------cut here---------------end--------------->8---

This adds entries like ("package/class" "") to the variables when no
options are given, and styles can check against them.

WDYT?

Best, Arash