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

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

Hi Arash,

>
> I think this is because of this part of amsmath.el[1]:
>
>    ;; RefTeX support: Tell RefTeX about amsmath environments.
>    (when (fboundp 'reftex-add-to-label-alist)
>      (reftex-add-to-label-alist '(AMSTeX)))
>
>> The issue arose when using log-edit-generate-changelog-from-diff for a
>> commit involving tex files.  I distilled it down to the above example.
>
> I'd say the form above was in amsmath.el since forever :-)
>

Indeed.

The attached patch addresses the issue for me.  Thoughts?

Paul

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)