Subject: bug#76615: 14.0.9; error with amsmath style hooks

From: "Paul D. Nelson" <[email-masked]>
Date: Fri, 28 Feb 2025 16:54:13 +0100

"Paul D. Nelson" <[email-masked]> writes:

>
> The attached patch addresses the issue for me.  Thoughts?
>

Here's a more complete version, addressing related issues.  This feels a
bit like plugging a leak with a band-aid, so other suggestions would
also be welcome.

diff --git a/style/amsmath.el b/style/amsmath.el
index 9d6944dc..68cd5983 100644
--- a/style/amsmath.el
+++ b/style/amsmath.el
@@ -163,7 +163,8 @@
    (TeX-run-style-hooks "amstext" "amsbsy" "amsopn")
 
    ;; RefTeX support: Tell RefTeX about amsmath environments.
-   (when (fboundp 'reftex-add-to-label-alist)
+   (when (and (fboundp 'reftex-add-to-label-alist)
+              (buffer-file-name))
      (reftex-add-to-label-alist '(AMSTeX)))
 
    ;; Add \eqref to `reftex-ref-style-alist' and associate it to `e'
@@ -180,6 +181,7 @@
    ;; is non-nil
    (and LaTeX-reftex-ref-style-auto-activate
         (fboundp 'reftex-ref-style-activate)
+        (buffer-file-name)
         (reftex-ref-style-activate "AMSmath"))
 
    (when (and (featurep 'font-latex)
diff --git a/style/cleveref.el b/style/cleveref.el
index 129d4ce1..67bece8b 100644
--- a/style/cleveref.el
+++ b/style/cleveref.el
@@ -211,6 +211,7 @@ string."
    ;; Activate RefTeX reference style.
    (and LaTeX-reftex-ref-style-auto-activate
         (fboundp 'reftex-ref-style-activate)
+        (buffer-file-name)
         (reftex-ref-style-activate "Cleveref")))
  TeX-dialect)
 
diff --git a/style/fancyref.el b/style/fancyref.el
index d2d87bf5..a580fcbf 100644
--- a/style/fancyref.el
+++ b/style/fancyref.el
@@ -103,6 +103,7 @@
    ;; Activate RefTeX reference style.
    (and LaTeX-reftex-ref-style-auto-activate
         (fboundp 'reftex-ref-style-activate)
+        (buffer-file-name)
         (reftex-ref-style-activate "Fancyref")))
  TeX-dialect)
 
diff --git a/style/hyperref.el b/style/hyperref.el
index 868acd33..e801140b 100644
--- a/style/hyperref.el
+++ b/style/hyperref.el
@@ -343,6 +343,7 @@
    ;; Activate RefTeX reference style.
    (and LaTeX-reftex-ref-style-auto-activate
         (fboundp 'reftex-ref-style-activate)
+        (buffer-file-name)
         (reftex-ref-style-activate "Hyperref")))
  TeX-dialect)
 
diff --git a/style/refcount.el b/style/refcount.el
index e20ef395..560855c0 100644
--- a/style/refcount.el
+++ b/style/refcount.el
@@ -79,6 +79,7 @@
    ;; Activate RefTeX reference style
    (and LaTeX-reftex-ref-style-auto-activate
         (fboundp 'reftex-ref-style-activate)
+        (buffer-file-name)
         (reftex-ref-style-activate "Refcount")))
  TeX-dialect)
 
diff --git a/style/varioref.el b/style/varioref.el
index e7f95f7f..b149d4de 100644
--- a/style/varioref.el
+++ b/style/varioref.el
@@ -90,6 +90,7 @@
    ;; Activate RefTeX reference style.
    (and LaTeX-reftex-ref-style-auto-activate
         (fboundp 'reftex-ref-style-activate)
+        (buffer-file-name)
         (reftex-ref-style-activate "Varioref")))
  TeX-dialect)