From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#49518: 28.0.50; electric-pair-mode skip-self fails for single-quotes in python-mode Date: Sun, 19 Sep 2021 01:20:30 +0100 Message-ID: <87v92xbelt.fsf@gmail.com> References: <877dhxp8wn.fsf@gmx.net> <58515d93-dbca-4cd1-e820-ad9d5bb6d462@gmail.com> <87zgs9bgaz.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32568"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 49518@debbugs.gnu.org, Stephen Berman , Daniel Fleischer To: Jim Porter Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 19 02:21:34 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mRkaL-00088Z-Aq for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 Sep 2021 02:21:33 +0200 Original-Received: from localhost ([::1]:48848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRkaD-0008NA-K6 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Sep 2021 20:21:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRkZt-0008N1-4Q for bug-gnu-emacs@gnu.org; Sat, 18 Sep 2021 20:21:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53860) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mRkZs-0007cf-Oy for bug-gnu-emacs@gnu.org; Sat, 18 Sep 2021 20:21:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mRkZq-0001xK-GI for bug-gnu-emacs@gnu.org; Sat, 18 Sep 2021 20:21:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 19 Sep 2021 00:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49518 X-GNU-PR-Package: emacs Original-Received: via spool by 49518-submit@debbugs.gnu.org id=B49518.16320108447480 (code B ref 49518); Sun, 19 Sep 2021 00:21:02 +0000 Original-Received: (at 49518) by debbugs.gnu.org; 19 Sep 2021 00:20:44 +0000 Original-Received: from localhost ([127.0.0.1]:37173 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRkZX-0001wa-RM for submit@debbugs.gnu.org; Sat, 18 Sep 2021 20:20:44 -0400 Original-Received: from mail-wr1-f41.google.com ([209.85.221.41]:46795) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRkZT-0001wH-4Z for 49518@debbugs.gnu.org; Sat, 18 Sep 2021 20:20:41 -0400 Original-Received: by mail-wr1-f41.google.com with SMTP id x6so21634561wrv.13 for <49518@debbugs.gnu.org>; Sat, 18 Sep 2021 17:20:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=u7MlIIdacgPqgzcz7dJ3G65p5xQ9c41vf3kgKJvJECE=; b=cNZ+omq4p45Iw3y6Ga1dsSDY2uHzhlPnXbS0c2CVctwjXg0DmA87wMycrZO46QtOOk X6DS7OKk3b1cLqMX6+FQIYczuFsZo1ex+ADpD6WesHTgQzIKlQpuW3Iguyabb7hf9Sjd 9x2gR8ut0438yKuDTOV9TH0Fs59HobDtHiVq0zEtsnrHik75zdFhWgQTGSL27kq8IE4J Sd26waJLOBoRig15f/rb2dKUcbLnPqfDWCQsFTgzwonl6Ob2OHnope5tQVniilaKj7Oo cy8gzBO9YY6FH+DZmvdiEhnSMy1YOkjJa3SZFQBSlZMwsg4/j3YSzHPNLKTVengf/ueM w1yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=u7MlIIdacgPqgzcz7dJ3G65p5xQ9c41vf3kgKJvJECE=; b=RiK03lYxP4Fm+rE43AXQVjBO4bH2689+qFt3yAfC8/EbO0nEs1+lOdk1ebrv1cZyfN DIdLQDNNXA8LfYyVhTs0KhlVrIgpQnTOQZooNCxuxR9kNQQvEeun/21LPO1eZdCGnRjy x9rvKxahrDFnv/WK6mM04nW5gxiLL7hYd1iogoc5nw1KzzqwoBFOoARhBsJ0RdEcPBlw jDaj/is2z4BAiaq+7mOajspJhSg3Ji9IH6uD0GTvEvUZfTqh2ojiteLKX1UK0LgrrED8 CTPniBSKdIIUFQiRB4INTvEaT59enRMgJ+kLPTpeJMb41Pw3ZAecoN2Uj/AmradnWhq+ V2bg== X-Gm-Message-State: AOAM530SM9N36+DmumEGzBVJKWnC6KG/HyR6mpkOCy1cRj4QNHWdBC2e V5/aEdQoysvNS7rlwhVgsCw= X-Google-Smtp-Source: ABdhPJwMM0GAgKiXk3jgPaxxjHHv1rZPKEHqltJUy/uqb9fHxjr8L61pMHehBNxs3VKzPN9VD3ryCg== X-Received: by 2002:a05:6000:144d:: with SMTP id v13mr12837064wrx.303.1632010832039; Sat, 18 Sep 2021 17:20:32 -0700 (PDT) Original-Received: from krug (a83-132-177-247.cpe.netcabo.pt. [83.132.177.247]) by smtp.gmail.com with ESMTPSA id c4sm4277163wrt.23.2021.09.18.17.20.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Sep 2021 17:20:31 -0700 (PDT) In-Reply-To: <87zgs9bgaz.fsf@gmail.com> ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Sun, 19 Sep 2021 00:43:48 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:214669 Archived-At: Jo=C3=A3o T=C3=A1vora writes: > Jim Porter writes: > >> (CCing Jo=C3=A3o since he wanted to hear about `electric-pair-mode' issu= es[1].) > > Thanks you Jim, > > I've read your original bug report. It is very clear in reproduction > and also the analysis seems mostly correct. I'll see what I can do. > > The solution will probably go into python.el in terms of customization > of electric-pair-mode's variables. The only question is whether it can > be made to serve Stephen's and your requirements. > > In the meantime, if you're curious: this was one of the first things I > worked in with autopair.el. See > https://github.com/joaotavora/autopair/issues/6. So after having a look at this, I came up with a patch. All tests pass, and your original request is granted. Unfortunately, Stephen's desired triple-pair behaviour is also lost. However, I think that behaviour can be recovered via other more elegant, less accidental ways. python.el has 'python-electric-pair-string-delimiter' for triple-pairing that doesn't seem to be doing its thing. Here is the patch. Give it a shot. diff --git a/lisp/elec-pair.el b/lisp/elec-pair.el index d8c377a2ef..b8b8a97651 100644 --- a/lisp/elec-pair.el +++ b/lisp/elec-pair.el @@ -198,7 +198,9 @@ electric-pair-syntax-info inside a comment or string." (let* ((pre-string-or-comment (or (bobp) (nth 8 (save-excursion - (syntax-ppss (1- (point))))))) + (skip-chars-backward + (make-string 1 command-event= )) + (syntax-ppss (point)))))) (post-string-or-comment (nth 8 (syntax-ppss (point)))) (string-or-comment (and post-string-or-comment pre-string-or-comment)) The original idea of electric-pair-syntax-info is that electric-pair-text-syntax-table is consulted if point is "well within" a string or comment. That's why it backtracks a character to establish pre-string-or-comment. But for strings started with multiple characters it failed, as you well noticed. So my patch makes it more likely that it understands if point is right after the string start. Maybe better less brittle solutions can probably be found within the syntax tables framework. If not, we can make a variable. I'll think about it better later. Anyway, I'm not entirely unhappy with this patch because all the tests pass, and they are reasonably strict and sensitive to this stuff. So no breakage there is a very good sign. Jo=C3=A3o