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

From: "Paul D. Nelson" <[email-masked]>
Date: Fri, 14 Mar 2025 08:09:18 -0700

Hi Ikumi,

> Is `reftex-TeX-master-file' the only source of RefTeX non-file buffer
> difficulties? If so, I expect there is a possibility that we can amend
> it so that RefTeX would not stumble in non-file buffer. For example,
> `TeX-master-file' returns "<none>.tex" if it can't find a sensible
> master file. What if we implement similar fallback for
> `reftex-TeX-master-file'?

Patching reftex in the suggested way does seem to alleviate the noted
issue with style hooks.  I can only imagine it breaks other things, but
given that non-file buffers are already not supported in reftex, maybe
that's OK?

Paul

diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el
index 8088ab391f5..2fac7982848 100644
--- a/lisp/textmodes/reftex.el
+++ b/lisp/textmodes/reftex.el
@@ -389,7 +389,9 @@ reftex-TeX-master-file
      (t
       ;; Use buffer file name.
       (setq master (buffer-file-name))))
-    (expand-file-name master)))
+    (if master
+        (expand-file-name master)
+      "<none>.tex")))
 
 (defun reftex-is-multi ()
   ;; Tell if this is a multifile document.  When not sure, say yes.