Subject: bug#51468: reftex-ref-style-alist in amsmath.el

From: Arash Esbati <[email-masked]>
Date: Fri, 29 Oct 2021 11:31:03 +0200

Hi Gustavo.

Gustavo Barros <[email-masked]> writes:

> `reftex-vars.el' defines the user option `reftex-ref-style-alist' and
> includes the "AMSmath" style among the default ones, the same as with
> other package specific reference commands.  The activation of each of
> these entries is controlled by
> `LaTeX-reftex-ref-style-auto-activate'. And users can set
> `reftex-ref-style-alist' so that they choose which styles may
> potentially get activated, according to loaded packages in the style
> files.
>
> However, `amsmath.el' goes a little further and adds (again) the
> "AMSmath" ref style to `reftex-ref-style-alist'.  Hence, if an user
> had removed it from the variable, the style file overrides that
> customization, and the only way to disable this ref style, while
> keeping `LaTeX-reftex-ref-style-auto-activate' to `t', is to add an
> empty "AMSmath" ref style instead.

My understanding of `reftex-ref-style-alist' being a custom variable is
that you can toggle the keys for the reference macros if you want to.
The reference styles get activated:

a) in RefTeX without AUCTeX: If you add an entry to
   `reftex-ref-style-default-list'
   
   ,----[ C-h v reftex-ref-style-default-list RET ]
   | reftex-ref-style-default-list is a variable defined in ‘reftex-vars.el’.
   | 
   | Its value is ("Default")
   | 
   | List of reference styles to be activated by default.
   | The order is significant and controls the order in which macros
   | can be cycled in the buffer for selecting a label.  The entries
   | in the list have to match the respective reference style names
   | used in the variable ‘reftex-ref-style-alist’.
   `----

b) in AUCTeX: When you have set `LaTeX-reftex-ref-style-auto-activate'
   to t.

So deleting an entry in `reftex-ref-style-alist' isn't intended to
prevent a reference style from being activated.

> But doesn't this re-adding of the ref style in `amsmath.el' defeat the
> purpose of the interplay between `reftex-ref-style-alist' and
> `LaTeX-reftex-ref-style-auto-activate'?  As far as I can tell,
> `amsmath.el' is the only style file from the ones included by default
> in `reftex-ref-style-alist' which does this.  I'd expect it not to do
> it.

Re-adding the entry is due to supporting older Emacs'en.  The entry for
"AMSmath" was not present as the variable was introduced[1].  That entry
was added in 2018 and amsmath.el tries to fill the gap.

I think the bottom line is set `LaTeX-reftex-ref-style-auto-activate' to
nil if you don't want AUCTeX to activate that reference style.

,----[ C-h v LaTeX-reftex-ref-style-auto-activate RET ]
| LaTeX-reftex-ref-style-auto-activate is a variable defined in ‘tex-style.el’.
| 
| Its value is t
| 
| Whether to activate automatically RefTeX reference styles.
`----

Best, Arash

Footnotes:
[1]  http://git.savannah.gnu.org/cgit/emacs.git/commit/lisp/textmodes/reftex-vars.el?id=4f595e1504dfbb6f81e04fb98aa4b033dd5398a4