From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.bugs Subject: bug#49518: 28.0.50; electric-pair-mode skip-self fails for single-quotes in python-mode Date: Sat, 18 Sep 2021 09:56:17 -0700 Message-ID: <58515d93-dbca-4cd1-e820-ad9d5bb6d462@gmail.com> References: <877dhxp8wn.fsf@gmx.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13003"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 49518@debbugs.gnu.org, Stephen Berman , =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= To: Daniel Fleischer Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 18 18:57:55 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 1mRdf1-0003B5-9g for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Sep 2021 18:57:55 +0200 Original-Received: from localhost ([::1]:40340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRdez-0006uo-G4 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Sep 2021 12:57:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRdeA-0006Ag-1W for bug-gnu-emacs@gnu.org; Sat, 18 Sep 2021 12:57:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53365) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mRde9-0007Oe-QJ for bug-gnu-emacs@gnu.org; Sat, 18 Sep 2021 12:57:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mRde9-0005X2-Kl for bug-gnu-emacs@gnu.org; Sat, 18 Sep 2021 12:57:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Sep 2021 16:57:01 +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.163198418721219 (code B ref 49518); Sat, 18 Sep 2021 16:57:01 +0000 Original-Received: (at 49518) by debbugs.gnu.org; 18 Sep 2021 16:56:27 +0000 Original-Received: from localhost ([127.0.0.1]:36678 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRddb-0005WA-AN for submit@debbugs.gnu.org; Sat, 18 Sep 2021 12:56:27 -0400 Original-Received: from mail-pf1-f182.google.com ([209.85.210.182]:42863) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRddW-0005Vu-Gb for 49518@debbugs.gnu.org; Sat, 18 Sep 2021 12:56:25 -0400 Original-Received: by mail-pf1-f182.google.com with SMTP id q23so10082460pfs.9 for <49518@debbugs.gnu.org>; Sat, 18 Sep 2021 09:56:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=zUara4HMxHfFfHjEzzB0VgQW6aCQ9GvEpodKPTKAHog=; b=aQUyAk3VewWLquLmhTl2i2u/idBmlh2TLysITmrNc4kRG0/8FDo2pvnw6nUOVpkkpk EI66VIsTlmv+D3XfPpkrtthgrYdz3nMzC4HAFk1NHqc0TppRL1yZ4GhZ+lyKAncstiC7 TT+jOp9RKlbAgiNw9sQptBBrjshOuQIqClmXMDHIDsXMQDPnYfuKVvdDmUtfn5W+NREP 5q9Phm9ZGmnvEThX38MBfxFVbVbGpmXM76SZomQXhuhRixbPfqAS1HJ2xlesKSUIfkJF KPo/bztcKhJaPJof/dRnOVLdKWcj87w1Mb1gOF9cbpQJwIo3bokxiZ1Tp7WzDwYIsx2h J2Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=zUara4HMxHfFfHjEzzB0VgQW6aCQ9GvEpodKPTKAHog=; b=1y4TBwKrR6tRFZ5s6GGuGmwXqoiJP24o0xNm+LdiZT6vsGrOmodKosI7e3wxpc2mzK myjIqyOEZkdgMAY9WYOFh/x7aB/UuWbQ4qGUgMkju8uo/PhXOfIEb0KNvGwdd9sQF2EI yI9J3Iz5CN6kAbiZ+WEKRJ8DvP2alM7dV1VVwHjKcEhXF9zc8t3DNKRs9iYu80abgbIM aCns5GkNkZmFuFwlKRP+LJH4LzVwyNd0H+qqdZhvAsioyEGLlEpd7k+vQ03J2aWFx7ii qAjsCzBhy+7kIhPiKQfl+M+UZYOxZ+FUEtK8bQA4lX5XrggD7D+ZIh5tf1UlrF3M3aN3 /Cjg== X-Gm-Message-State: AOAM531DNun48nd7WxRdEIqk9cjL/QtVvv0NuAGvskrJUqzzHskpg6q6 pGaK+wrnMbgl1XNX6LYCRgc= X-Google-Smtp-Source: ABdhPJxnnWQ0vI4qHJ+Q5AziL3on7qDIGbXbikr5msFCE0/xOFRC0YmEuzHH8ERCStGAL2mvNDR1iQ== X-Received: by 2002:a63:be0e:: with SMTP id l14mr15198860pgf.363.1631984176675; Sat, 18 Sep 2021 09:56:16 -0700 (PDT) Original-Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id c11sm9915080pfm.55.2021.09.18.09.56.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 18 Sep 2021 09:56:16 -0700 (PDT) In-Reply-To: Content-Language: en-US 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:214646 Archived-At: (CCing João since he wanted to hear about `electric-pair-mode' issues[1].) On 9/18/2021 5:55 AM, Daniel Fleischer wrote: > Jim Porter [2021-07-11 Sun 10:34] wrote: > >> That's true, and I've been working on a patch to make that behavior >> more robust. The code for that is in >> `python-electric-pair-string-delimiter', but I think an improved >> implementation of that would depend on how this bug is fixed. I have a >> local patch that works for me, but it depends on the other >> electric-pair settings I use, so it couldn't merge as-is. > > As I'm also bothered by this, is there some resolution? > > BTW, my solution is hooking this code in 'inferior-python-mode': > > (setq-local electric-pair-pairs > (append electric-pair-pairs '((?' . ?')))) This isn't the right fix in general, but maybe it will help you. It works for me because I turn off `electric-pair-mode' inside comments and strings, but with the default configuration, it will pair single-quotes inside double-quoted strings (i.e. you won't be able to type an apostrophe). There's probably a more robust solution, but I haven't had time to investigate further... ---------------------------------------- (defun user--python-electric-pair-string-delimiter () (when (and electric-pair-mode (memq last-command-event '(?\" ?')) (let ((count 0)) (while (eq (char-before (- (point) count)) last-command-event) (cl-incf count)) (= count 3))) (save-excursion (insert (make-string 3 last-command-event))))) (defun user--electric-pair-python-hook () (setq-local electric-pair-text-syntax-table python-mode-syntax-table)) (advice-add #'python-electric-pair-string-delimiter :override #'user--python-electric-pair-string-delimiter) (add-hook 'python-mode-hook #'user--electric-pair-python-hook) ---------------------------------------- [1] https://lists.gnu.org/archive/html/emacs-devel/2021-09/msg01313.html