From unknown Fri Jun 20 07:16:00 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#23387 <23387@debbugs.gnu.org> To: bug#23387 <23387@debbugs.gnu.org> Subject: Status: 25.0.93; Unicode quote inserted in Python mode outside of strings Reply-To: bug#23387 <23387@debbugs.gnu.org> Date: Fri, 20 Jun 2025 14:16:00 +0000 retitle 23387 25.0.93; Unicode quote inserted in Python mode outside of str= ings reassign 23387 emacs submitter 23387 Philipp Stephani
emacs -Q
M-x electric-quote-mode
M-x customize-variable RET electric-quote-string, set it to t, save
M-x python-mode
Hit '
Expected: ' (ASCII apostrophe) is inserted because point is outside a s= tring
Actual: =E2=80=99 (Unicode quote) is inserted
This seems to happen only in Python mode, not in e.g. emacs-lisp-mode.
emacs -Q
M-x electric-quote-mode
M-x customize-variable RET electric-quote-string, set it to t, save
M-x python-mode
Hit '
Expected: ' (ASCII apostrophe) is inserted because point is outside a s= tring
Actual: =E2=80=99 (Unicode quote) is inserted
This seems to happen only in Python mode, not in e.g. emacs-lisp-mode.
A= lso happens in C++ mode, and probably others.=C2=A0
Thanks for the bug report and patch, but I ran into a problem= with the
patch. Suppose I do this:
emacs -Q
M-x electric-quote-mode
M-x customize-variable RET electric-quote-string, set it to t, save
M-x python-mode
'abc'
That is, I type apostrophe-a-b-c-apostrophe in Python mode. With the
patch, the buffer will contain:
'abc=E2=80=99
The opening apostrophe is OK, but the closing apostrophe is considered
to be inside a string so it is transmogrified into a right single
quotation mark. A Python programmer would want both to be apostrophes.
<= /blockquote>I'm not sure, I think if a user has ele= ctric-quote-string enabled, that's the behavior they want, because it= 39;s inside a string. However, I can see that both approaches are valid. Th= ere is probably no good way that would work in all circumstances.