From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.bugs Subject: bug#23387: 25.0.93; Unicode quote inserted in Python mode outside of strings Date: Thu, 28 Apr 2016 17:22:06 +0000 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c32940891f5a05318ec473 X-Trace: ger.gmane.org 1461864200 10853 80.91.229.3 (28 Apr 2016 17:23:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 28 Apr 2016 17:23:20 +0000 (UTC) To: 23387@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Apr 28 19:23:11 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1avpef-0003bm-Vc for geb-bug-gnu-emacs@m.gmane.org; Thu, 28 Apr 2016 19:23:10 +0200 Original-Received: from localhost ([::1]:50308 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avpef-0005QN-DL for geb-bug-gnu-emacs@m.gmane.org; Thu, 28 Apr 2016 13:23:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avpea-0005L1-Ke for bug-gnu-emacs@gnu.org; Thu, 28 Apr 2016 13:23:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1avpeX-0005gn-UK for bug-gnu-emacs@gnu.org; Thu, 28 Apr 2016 13:23:04 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41138) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avpeX-0005gb-RH for bug-gnu-emacs@gnu.org; Thu, 28 Apr 2016 13:23:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1avpeX-0008GQ-Nl for bug-gnu-emacs@gnu.org; Thu, 28 Apr 2016 13:23:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philipp Stephani Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 28 Apr 2016 17:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23387 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23387-submit@debbugs.gnu.org id=B23387.146186414431709 (code B ref 23387); Thu, 28 Apr 2016 17:23:01 +0000 Original-Received: (at 23387) by debbugs.gnu.org; 28 Apr 2016 17:22:24 +0000 Original-Received: from localhost ([127.0.0.1]:53475 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1avpdv-0008FN-Vt for submit@debbugs.gnu.org; Thu, 28 Apr 2016 13:22:24 -0400 Original-Received: from mail-lf0-f54.google.com ([209.85.215.54]:33409) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1avpdt-0008F8-QC for 23387@debbugs.gnu.org; Thu, 28 Apr 2016 13:22:22 -0400 Original-Received: by mail-lf0-f54.google.com with SMTP id y84so91777855lfc.0 for <23387@debbugs.gnu.org>; Thu, 28 Apr 2016 10:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=bXDds70Giq8452mn3QTuxPvgc7VQGYWtlvRKIqy4ACI=; b=Yfk7HbcTDN1/TUpEXM+nelT3fQbfnXJLhwnwH/mtAGtRMYIRscGcEzfwB66LGpMTg+ 7hxECvR29zqGDErR2EQIlo4cl3FtjNa/v8tqGYVQboaXh3QQybpU6U5LcRjTpuAPak40 s1sCZL2KLmwur7qKFE7xqAST3FIec9+ZJetoUFSqiixfOLa/zjAotIyPTSIhCo5R5hIX jDI9Opo7z61X6lxRxP7DEQPwGgEcCAp4567ROsSYbxdbUCC6QL3HfmXw89jkud2LE2I7 DFF8wkyMhpfhRU1npVQwvWw6gYEW+5Ww8H487ZQ4UlLuY4Ffu9JUh5IPn3HYZ5yjuJCN 434Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=bXDds70Giq8452mn3QTuxPvgc7VQGYWtlvRKIqy4ACI=; b=hpRz32Tw3pGUyikXzvhJccH7X8YK3fjVeFnPst/11sLM6roEhev3/XqTEvf8oc4Grc 6UkTN9WEZrgGIxcilhqG8i3olmH2l4273VAA6PC0a+fgZyIjvdx3DjO+htVBUsmiK/jl 71MA74jL4Sjwuiglk9bHiIvrq2dW+PqLwyadbQ43o+n506v7DoaLTER/ewFuvsXpnUcD OOrWCiNXq2MupxTpi60E478MR8jtrOaIvFHjdZA81SbcA9DRotxSnMRHdVmIO5ElkKqd UXaCItRKsW9CEEtzgcpnQBTrsr8AJak3MuZnMgI58P20bqcjPPMqj3m2uIA1YB+Z7IK9 x+rQ== X-Gm-Message-State: AOPr4FVBs1t5HreRdsoiOsYl5FvvgkjTYXyYn6hCHUq1xR9lfLLc8bupFmdJXwpwUva0IqgNVey84foOH9CCzA== X-Received: by 10.112.198.132 with SMTP id jc4mr7041373lbc.120.1461864135989; Thu, 28 Apr 2016 10:22:15 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:117103 Archived-At: --001a11c32940891f5a05318ec473 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Philipp Stephani schrieb am Do., 28. Apr. 2016 um 19:11 Uhr: > Philipp Stephani schrieb am Mi., 27. Apr. 2016 um > 16:16 Uhr: > >> >> 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 >> string >> Actual: =E2=80=99 (Unicode quote) is inserted >> >> This seems to happen only in Python mode, not in e.g. emacs-lisp-mode. >> >> Also happens in C++ mode, and probably others. > The root cause is that electric-quote-post-self-insert-function uses syntax-ppss to check whether point is in a string or comment. Before it makes any replacement, the ASCII apostrophe is still in the buffer, so syntax-ppss considers point to be inside a string. It looks like calling syntax-ppss with (forward-point -1) as argument instead of (point) should fix it, but I'm not sure whether that's the right way. --001a11c32940891f5a05318ec473 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


Philip= p Stephani <p.stephani2@gmail.c= om> schrieb am Do., 28. Apr. 2016 um 19:11=C2=A0Uhr:
Philipp Stephani <p.stephani2@gmail.com> schrieb am Mi., 27. Apr. 2016= um 16:16=C2=A0Uhr:

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

The root cause is that electric-quote-post-self-= insert-function uses syntax-ppss to check whether point is in a string or c= omment. Before it makes any replacement, the ASCII apostrophe is still in t= he buffer, so syntax-ppss considers point to be inside a string. It looks l= ike calling syntax-ppss with (forward-point -1) as argument instead of (poi= nt) should fix it, but I'm not sure whether that's the right way.
--001a11c32940891f5a05318ec473--