GNU bug report logs - #78296
Hand-written styles with `LaTeX-provided-package-options'

Previous Next

Package: auctex;

Reported by: Arash Esbati <arash <at> gnu.org>

Date: Wed, 7 May 2025 08:18:02 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Arash Esbati <arash <at> gnu.org>
To: 78296 <at> debbugs.gnu.org
Subject: bug#78296: Hand-written styles with `LaTeX-provided-package-options'
Date: Wed, 07 May 2025 10:17:20 +0200
Hi all,

say you have a .tex file like this:

--8<---------------cut here---------------start------------->8---
\documentclass[11pt]{article}

\usepackage{mypackage}

\begin{document}
foo
\end{document}

%%% Local Variables:
%%% mode: LaTeX
%%% TeX-master: t
%%% End:
--8<---------------cut here---------------end--------------->8---

loading mypackage.sty and you have also written an AUCTeX style file
mypackage.el which looks like this:

--8<---------------cut here---------------start------------->8---
;;;   -*- lexical-binding: t; -*-

(TeX-add-style-hook
 "mypackage"
 (lambda ()
   (TeX-add-to-alist 'LaTeX-provided-class-options
                     '(("article" "11pt")))
   (TeX-add-to-alist 'LaTeX-provided-package-options
                     '(("babel" "english")
                       ("booktabs" "")
                       ("fontspec" "")
                       ("geometry" "a4paper")
                       ("graphicx" "")
                       ("lastpage" "")
                       ("microtype" "activate")
                       ("parskip" "")
                       ("siunitx" "")
                       ("tabularx" "")
                       ("titlesec" "pagestyles")
                       ("xcolor" "svgnames")
                       ("xspace" "")))
   (TeX-run-style-hooks
    "article"
    "babel"
    "booktabs"
    "fontspec"
    "geometry"
    "graphicx"
    "lastpage"
    "microtype"
    "parskip"
    "siunitx"
    "tabularx"
    "titlesec"
    "xcolor"
    "xspace"))
 TeX-dialect)
--8<---------------cut here---------------end--------------->8---

IIUC, the hand-written additions to `LaTeX-provided-package-options' and
`LaTeX-provided-class-options' are never activated in the .tex file.  I
played with moving these forms around from `LaTeX-auto-cleanup':

  (setq LaTeX-provided-class-options nil)
  (setq LaTeX-provided-package-options nil)

but no avail.  The best solution I can currently offer is:

--8<---------------cut here---------------start------------->8---
diff --git a/latex.el b/latex.el
index 3a32c4e7..8b35851a 100644
--- a/latex.el
+++ b/latex.el
@@ -1943,6 +1943,8 @@ For example, its value will be
    ...)
 See also `LaTeX-provided-package-options'.")

+(add-to-list 'TeX-normal-mode-reset-list 'LaTeX-provided-class-options)
+
 (defun LaTeX-provided-class-options-member (class option)
   "Return non-nil if OPTION has been given to CLASS at load time.
 The value is actually the tail of the list of options given to CLASS."
@@ -1966,6 +1968,8 @@ For example, its value will be
    ...)
 See also `LaTeX-provided-class-options'.")

+(add-to-list 'TeX-normal-mode-reset-list 'LaTeX-provided-package-options)
+
 (defun LaTeX-provided-package-options-member (package option)
   "Return non-nil if OPTION has been given to PACKAGE at load time.
 The value is actually the tail of the list of options given to PACKAGE."
@@ -2140,8 +2144,8 @@ TYPE is one of the symbols mac or env."
                                 LaTeX-auto-bibliography)))

   ;; Reset class and packages options for the current buffer
-  (setq LaTeX-provided-class-options nil)
-  (setq LaTeX-provided-package-options nil)
+  ;; (setq LaTeX-provided-class-options nil)
+  ;; (setq LaTeX-provided-package-options nil)

   ;; Cleanup document classes and packages
   (unless (null LaTeX-auto-style)
--8<---------------cut here---------------end--------------->8---

I.e., adding the variables to `TeX-normal-mode-reset-list' and deleting
the forms inside `LaTeX-auto-cleanup'.  Am I missing something?

Best, Arash




This bug report was last modified 20 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.