Subject: bug#49061: electric-quote-mode in bibtex-mode

From: Gustavo Barros <[email-masked]>
Date: Wed, 16 Jun 2021 11:00:32 -0300

Hi All,

I'm trying to get `electric-quote-mode' to work in `bibtex-mode', but 
I'm having some trouble with it.

The problem stems from the fact that `electric-quote-mode' makes a basic 
distinction between `text-mode' and "all other modes" (it seems 
implicitly to address `prog-mode' in this case).  However, `bibtex-mode' 
does not set a "parent mode" when it is defined.  So, 
`electric-quote-mode' will provide functionality similar to that of 
`prog-mode' for `bibtex-mode'.  In doing so it checks for comments or 
strings with `(nth 8 (syntax-ppss))' (this is done in 
`electric-quote-post-self-insert-function'), however a regular bibtex 
field will (or may) fail to have either comment or string syntax.  It 
actually depends on `bibtex-field-delimiters', if it is `double-quotes' 
a field will be within string syntax, but the normal case, and the 
default one is `braces', in which case the string syntax check fails. 
It does work for comments, of course, but not for a regular field 
though.

In practical terms, the effect of this is that we don't get curved 
quotes in a regular bibtex field if it is enclosed by braces, which is 
where we might need those quotes in this case.

I'm not sure what the best solution to this would be.  Changing the 
syntax of `{}' in `bibtex-mode' does not seem like a good idea. 
However, just assuming `bibtex-mode' should work "as `text-mode'" from 
`electric-quote-mode's side may also be problematic (assume, for 
example, that a user sets `bibtex-field-delimiters' to `double-quotes'). 
Still, this is something that is not working particularly well, and I 
thought it worth reporting.

Best regards,
Gustavo.

PS: The state of things this report refers to is that of "GNU Emacs 27.2 
(build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 
1.16.0) of 2021-03-25".