From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 10 21:32:51 2021 Received: (at submit) by debbugs.gnu.org; 11 Jul 2021 01:32:51 +0000 Received: from localhost ([127.0.0.1]:33674 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m2OKw-0006D9-Lq for submit@debbugs.gnu.org; Sat, 10 Jul 2021 21:32:50 -0400 Received: from lists.gnu.org ([209.51.188.17]:50548) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m2OKu-0006D0-Rk for submit@debbugs.gnu.org; Sat, 10 Jul 2021 21:32:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m2OKu-0005sh-Jq for bug-gnu-emacs@gnu.org; Sat, 10 Jul 2021 21:32:48 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:44657) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m2OKs-0001dq-VY for bug-gnu-emacs@gnu.org; Sat, 10 Jul 2021 21:32:48 -0400 Received: by mail-pj1-x1035.google.com with SMTP id p4-20020a17090a9304b029016f3020d867so8331311pjo.3 for ; Sat, 10 Jul 2021 18:32:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=gLbAaXkZlqHtX7PHLGs1DKokOmand3/HbzqMG7A2EGA=; b=LJmBqnJLy1gm41DBZOLb/90XWgHCO6PENLBwqjY4NFJb5kCpw3ZMDq7w2T8Hm1cPae 58R3AvCRinOqUM5qU+I8yW/eExilLwH0JLBtCiDCOwAONbcQM8rWtikEmgZzEZElUvl3 PBa8iUwEIlPR5RqmNemtgCtu+jtfjhtTl2788YpKsbQIOJTBRMFIo1z79ygMjFMBkw5t dpTSY9T4s4dlz2SV1g6ypEkm/ZVd1IKzXpdxVr3/B6pZKis+iHppbPvKALxy79D6Peus Zw3CJKKknDg5XVhW0O/8uRzByv3IB5EfTnv93j31herQ7ZFQNGTlXImyPoTLa3BEDVtH pjCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=gLbAaXkZlqHtX7PHLGs1DKokOmand3/HbzqMG7A2EGA=; b=l8dHafsDTAMH4nd4yi4A3k0UixISGcZkqZdjVOOei+YnLQ2NtD4eMjZQpK4MblTmMa WzDgqaRvVQeEMTB6e4cGLQbJQcjfv97j3uvk4rTNK/HTFvV9p5pCi9WEe9nBHiY8KyYG TfALzhxT5G1h5UyCfyB2E8XtiHrNpuHP7ouTvroKuMwNVPtlVVQgxNoLhstCNF+XLgJa 0tvnRelzpAyQuX4do/AfObQw8w9uufmorpfvPMQbqnve00JI6ErXtKCTD3G7ZMH+FQ+o 0nQT4xJcxFZcn8e7dcbhKXUsDISXABuTImYvBpCuCGYRfr5BgsG5JYN+odhO1k0n02mE /4hQ== X-Gm-Message-State: AOAM530fHv3Msw0ux/cTFHYyt+D4cJbJTUWpJt8CmUIXRYCDYkA0mJ/S v/hupY51KCvRWKtBGBPgeAL8H8sT+ygVHgtoZMgA3cwjTlI= X-Google-Smtp-Source: ABdhPJxCgRVPiNrOiLxMuxftgYmT787BKx3074u5Q1S3xKcBFNig7yPP2SD+vAB+ry5V0qclL1kA/DiD3KqyFeDRfzM= X-Received: by 2002:a17:90a:710a:: with SMTP id h10mr6899640pjk.103.1625967164494; Sat, 10 Jul 2021 18:32:44 -0700 (PDT) MIME-Version: 1.0 From: Jim Porter Date: Sat, 10 Jul 2021 18:32:34 -0700 Message-ID: Subject: 28.0.50; electric-pair-mode skip-self fails for single-quotes in python-mode To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=jporterbugs@gmail.com; helo=mail-pj1-x1035.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) To reproduce this issue: 1. emacs -Q --eval '(electric-pair-mode)' foo.py 2a. Type " (double-quote); result should be "|", where | is the point 2b. Type " (double-quote); result should be ""| (Note: This is the correct behavior, as I understand it.) 3. Delete everything (optional) 4a. Type ' (single-quote); result should be '|' 4b. Type ' (single-quote); result is ''|', but (I think) it should be ''| Having looked through the source of both `electric-pair-mode' and `python-mode', I believe I understand the problem. First, some background: in `electric-pair-syntax-info', it checks whether the point is inside a string or comment. If so, it uses `electric-pair-text-syntax-table' (defaulting to `prog-mode-syntax-table'); if not, it uses `python-mode-syntax-table'. Normally, this means if you have a snippet like ''|', the point is *not* inside string; it's after the end of one string and before the start of the next. However, Python has multiline strings, which causes an issue here. When python-mode sees 3 quotation marks in a row, it doesn't see that as an empty string followed by the start of a separate string; it sees the start of a multiline string. Thus, when we have our snippet ''|', the point is considered to be in a string. That means `electric-pair-syntax-info' uses `electric-pair-text-syntax-table'. Since the default prog-mode syntax table doesn't consider single-quote to be a quote character, `electric-pair-syntax-info' ends up returning nil. Notably, this *isn't* an issue for double-quote. While we (temporarily) have the state ""|", double-quote is a quote character according to `electric-pair-text-syntax-table', and so skip-self proceeds as expected. (You might think the fix here would be to do like `emacs-lisp-mode' and locally set `electric-pair-text-pairs' to include single-quote. This wouldn't work though, since it would make it hard to type an apostrophe in a word; `electric-pair-mode' would double it up.) One possible fix would be for `python-mode' to locally set `electric-pair-text-syntax-table' to `python-mode-syntax-table'. This seems to work for me after some basic testing, but I'm not confident it's the right thing to do here; I don't see any examples of other modes that do this, and I haven't thought over all the possible problems with it. From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 11 04:11:32 2021 Received: (at 49518) by debbugs.gnu.org; 11 Jul 2021 08:11:32 +0000 Received: from localhost ([127.0.0.1]:33830 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m2UYl-0007gC-V5 for submit@debbugs.gnu.org; Sun, 11 Jul 2021 04:11:32 -0400 Received: from mout.gmx.net ([212.227.17.20]:53147) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m2UYi-0007fw-Df for 49518@debbugs.gnu.org; Sun, 11 Jul 2021 04:11:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1625991081; bh=wzP5Kc/aRKAzGc9IDd4EgGfnVV72bvmX9TTit6zQBPg=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=QQ3o4YyaskieO/GacgBMoBW2qmardFjbekF62LQpj40Fohb++eNwsNlIXPIGzGDDP B0G03RRkAzjWOBRzJsWa1eGrYSJKaBTJKIySMQ72uIq0DVMp+r1hS+ebvikcU1l80I b0OxxTZwZpdwr0GySk6KgQ1zOQfj9PtCE0xd6msQ= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from strobelfs ([178.1.122.254]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N3se8-1l2nBR2Gi8-00zjWl; Sun, 11 Jul 2021 10:11:21 +0200 From: Stephen Berman To: Jim Porter Subject: Re: bug#49518: 28.0.50; electric-pair-mode skip-self fails for single-quotes in python-mode References: Date: Sun, 11 Jul 2021 10:11:20 +0200 In-Reply-To: (Jim Porter's message of "Sat, 10 Jul 2021 18:32:34 -0700") Message-ID: <877dhxp8wn.fsf@gmx.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:AHb9ii7XTFurPcH0ouo4T6TrYp3bwfI37B0KJKJEFBP9rK+YSVi Z5jxA31U1/kTNuMDGnXD39ZkKdyxw4E1CpRN41MzbiqdqHqZtHzab6Eh/eR7/Tgu/RMEGoo +7Y/6J4vWkJYbJEWfhMJe2/nGGWH9ej7eu70tQtbecGgQM7NOEcHLby5Y7O8lSxFMuGXen5 uI/KbD8hNRk1g6it3dgsw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:jJiP0H3P3nE=:GRe4QTLxJwoDFw/dbV0gmi Wbt9oJ336XYlkJ2owgdqdeHaDfgeFmsnf/yIRB+4lvm6Zd/WkAPrViGp40cEy6RXsiNsY9sQJ f7o/j9+sx2wjPF4nQGagS8FRIsAXxfQjOZWbuUiK1RsKfn60a188r0RKY6k3SQmj97WJwBE8x rdqHIsEUXzytbEXZ59ZPADrS4n6u1U5W5yNQjt8XqtCO6GtURoAY5g3nLwDnlBCK5NOY0idSc gzW4UY6c5/HUKDCqCLRe54+uUAQ2cPZR2/eEiQI/rXytErvwTY5FhJTaqPUo0UR2IcmxsD4SE hg5OWxZFy+hxfGxS9QuS9fuST5CgzzzKnUtSvqMvo8D7C8wDqFB/MDkf4VNJyCpe/4bsAIBYr AIgdEls10rM+f+0OF+jJphtXHtPWySRcLDTFyqduOvhHmn5N3KVcthR+Bt8JUa5/uZR/Z38aJ 3tcLd2N1amYs8vtXkZvsttAOjVViYZpwdUQ/akinAZ3nqQ+Kpvhf6Z+ONHc6LgfRjdQIi3lHu H5hOclypW2ztZiAU9BW+k8cqD12lK/KsTP+ROPnry5X5nfJNP53o41VehO9mEZGeAsVwhuqeN hzdcko4298N9xuEurluiWaXquOubzffgZyNbe0hOTlkLzLUp0iefkrpQyS+Ezw6NSfkL8FxAb 9rwy2gJ7Fa2RtXiLQtUhsrmdMeW6ladl8NiTMhzK8u9l6okSAOMiYn1ljNVWd3aHvi6i2sTLb NjdoyR2pjQVQNz3Af1WTjiENC5gflM6oQTWNNokfHgXoNhHLNnkARPXC6z4XIhllZVAGqvKHd cjakp510Ec0ediUOLreCFZMHA8jMgt9jj+N+pinMCymzsknZpgkCkzM3esuf1PoYRyEaX0z03 ivFePPbhg/kMTH0+k0tMSrCrNxxLOKTLEgvXEDx+XIKosShPeF9eBPt/0y+y2FRjHTmNzteTc sLW6RLcM6egDCSjQYkwpktHwmHwkkuibRwYa8/ldvlNniF9VrkmYnfce63Hf0SwCIUdZPWMtL A10yhGs9rsFpBQvEk1BVDiMdMrYAu/mxgE8dgzCnofu7PY9gQiACEiMXAkGeMvkAvx4Sh11Oo fEAaiih8+bYB1cTRnJASofxjhuj9DZFQKkVDoIgp9nApgRq9r7BndAAuA== X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 49518 Cc: 49518@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Sat, 10 Jul 2021 18:32:34 -0700 Jim Porter wrote: > To reproduce this issue: > > 1. emacs -Q --eval '(electric-pair-mode)' foo.py > 2a. Type " (double-quote); result should be "|", where | is the point > 2b. Type " (double-quote); result should be ""| > (Note: This is the correct behavior, as I understand it.) > 3. Delete everything (optional) > 4a. Type ' (single-quote); result should be '|' > 4b. Type ' (single-quote); result is ''|', but (I think) it should be ''| [...] > One possible fix would be for `python-mode' to locally set > `electric-pair-text-syntax-table' to `python-mode-syntax-table'. This > seems to work for me after some basic testing, but I'm not confident > it's the right thing to do here; I don't see any examples of other > modes that do this, and I haven't thought over all the possible > problems with it. One thing that's kinda nice about the current behavior of typing single-quote in python-mode is that if you type it three times in a row you get '''|''', so it's ready for typing a multiple string. This doesn't happen with double-quote, and after setting electric-pair-text-syntax-table to python-mode-syntax-table it doesn't happen any more with single-quote. Steve Berman From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 11 13:34:35 2021 Received: (at 49518) by debbugs.gnu.org; 11 Jul 2021 17:34:35 +0000 Received: from localhost ([127.0.0.1]:35819 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m2dLf-0007Sa-Dj for submit@debbugs.gnu.org; Sun, 11 Jul 2021 13:34:35 -0400 Received: from mail-pf1-f180.google.com ([209.85.210.180]:44019) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m2dLd-0007SM-Pl for 49518@debbugs.gnu.org; Sun, 11 Jul 2021 13:34:34 -0400 Received: by mail-pf1-f180.google.com with SMTP id a127so13943634pfa.10 for <49518@debbugs.gnu.org>; Sun, 11 Jul 2021 10:34:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wpH2Fvf8ysNpYLqsVNukl/tX+rhJk1vib4GNHuz8l0Y=; b=mPM7sB9B7Te8tL/Pl1BhDQxfxop/Vls7XuktzltE4rg0op8U/lqB2lKPr/FnoT7KtK tXQlFK1L8soDoYrGwG1QYSS3YMQUUC59INvrzQuTKMuXsN9gJMkskbGDbZItuWnRjGue TLz/UFcUf8Fzjdo2jSo6h2Hn0GwFT8kSOq9vco1rHdXQWwHFNyQerP4LbDttjXcIUrzQ 06Ia6WtW3N5oJdTwKikV2h+vuNPzkoIc4NZnlB/XkH6Gq0bqwK5Uq0KeLYza5Uo0tG2F tDOAHbly991XSXJmaVsuxvt99yYE7tLUyYxT+0/rGw6WqXI2wT6riiEQMiUaCdqiGJKQ 8xlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wpH2Fvf8ysNpYLqsVNukl/tX+rhJk1vib4GNHuz8l0Y=; b=iuxQIPKYtiODcpG/9UwMo2/Efdof3Bf67wpdh0+Lu3fVC0CtC4GFlH+X/nQFt3RqmX HgfMpdisy3x/xQkrGoETS+u1poX2yZD59Piq4j36zfhE4iCLoUJP9FfiYz/9vFzomAvi oIBtyPK9hlEPXEgATgA1+KN3HhCE2e7oFFpRd+azD8O5lGyq2uMR4MtS2OvUl+O3pKIC U0I0e+vkFUQ8LCBj19906xr9d1IJ7pnBfIDGSxan5STTR8je4/feMPC6GSXIy1zuimdO HWUXdylz+Wggdqe28laInG2pOArZU/te/G/JNX5Q+eu89k50Ypu2iQJ/Q0V7U5LRjDP6 LItw== X-Gm-Message-State: AOAM5337d+OtZyngTKfQ9pGYO9qT1TgReYB51MeBsfZoXgPsVUeqAK4K EzG/K1Lrm0INGMetVel9YhpYQXYgcuOw0oFbENE= X-Google-Smtp-Source: ABdhPJyMulh04CFT+fJnbKY/Dkodne0dQV9IOOu5lkwxBlomEj0/ox1o+HtEe5gjRwt4vsWSnuuIne4D57cRD6BqtJo= X-Received: by 2002:a65:41c6:: with SMTP id b6mr49843981pgq.206.1626024867653; Sun, 11 Jul 2021 10:34:27 -0700 (PDT) MIME-Version: 1.0 References: <877dhxp8wn.fsf@gmx.net> In-Reply-To: <877dhxp8wn.fsf@gmx.net> From: Jim Porter Date: Sun, 11 Jul 2021 10:34:19 -0700 Message-ID: Subject: Re: bug#49518: 28.0.50; electric-pair-mode skip-self fails for single-quotes in python-mode To: Stephen Berman Content-Type: text/plain; charset="UTF-8" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 49518 Cc: 49518@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Sun, Jul 11, 2021 at 1:11 AM Stephen Berman wrote: > > One thing that's kinda nice about the current behavior of typing > single-quote in python-mode is that if you type it three times in a row > you get '''|''', so it's ready for typing a multiple string. This > doesn't happen with double-quote, and after setting > electric-pair-text-syntax-table to python-mode-syntax-table it doesn't > happen any more with single-quote. 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. In particular, it would need to take into account the various possible settings for `electric-pair-skip-self', since with that set to nil, I'd generally expect `python-electric-pair-string-delimiter' to be a no-op (we should already have three quote characters after point, so no need to insert more). From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 18 08:55:46 2021 Received: (at 49518) by debbugs.gnu.org; 18 Sep 2021 12:55:46 +0000 Received: from localhost ([127.0.0.1]:33827 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRZsf-0000Sz-OZ for submit@debbugs.gnu.org; Sat, 18 Sep 2021 08:55:45 -0400 Received: from mail-wr1-f50.google.com ([209.85.221.50]:43974) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRZsd-0000Sk-Ox for 49518@debbugs.gnu.org; Sat, 18 Sep 2021 08:55:44 -0400 Received: by mail-wr1-f50.google.com with SMTP id w17so11593953wrv.10 for <49518@debbugs.gnu.org>; Sat, 18 Sep 2021 05:55:43 -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; bh=oVkG1JlcW9OOosx/DvUslD5YxdJzRjeTsmSPj/dzVFU=; b=DgaJ3AGCIZgVQMmD+dqFjHIlfYmrhLhyLEKWFTWZPrQb/u3OVsl2TrCxB5mokkaogV xSsHQ3JVdm9pcjcPjhOOL+kBB1EW0NXJtR9xz04boP0sBi2h/J1otsyBGRzj1LdfRMvB k2v3eo3zIrv3nv9IXWfKqSsBJhRzPCmesgNa5p2AiqJweGhfYw4m3Fb0UPc4naSoqQWk 5nBmOKLDochNdAWiWfwbpIaJV+Gq4y/SPwP0qrJ3D+KQ3CJ8JxjwEKVq88YiEVc+VnCB 8Fph58sfp2q7J0syLgn0F2ZJDxhIoyugORIWVy3wC6QAPI1rHttKz0vKNcFhZmgifVr2 EjkQ== 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; bh=oVkG1JlcW9OOosx/DvUslD5YxdJzRjeTsmSPj/dzVFU=; b=2izc/h6b0hVkYWRHAoAZwQN6hFfU0dKpH4bzvbnbC9sB5mYpTaeD50jvtyHKGqVUjs IYI97rQ8kZ0b2Ex+j0DE18OIkhYFj22Kb0K8TEiKDsjuvn9eBLRKAOT5/12DoMfaoHW2 NaSVntaCVMQJd6T9fR5KilEeOqAHGn9HF907m8eVAKYEjcgFp7wCj+sXHaVEtu6yKO5V njH0TFU72Zlx5PTEKRqeLVxR3y5ogEP8hxzikmqblT7RgRxR5cYLj3O7j/hwi7szdEff FxmNqth+ZXjuFnvQ9BYs9kqfyc2IHNu3tVONPmI0HVlwGNpB21OOPN92o34knQSLNuz+ 61ZQ== X-Gm-Message-State: AOAM532+RLVqVvTju/1gdwc6bzd13LuX7kL4tQG2VTS+1f0hfPmvZTcv uVA9JTb3SbqVeVgan3qHL/DkzFER6x0= X-Google-Smtp-Source: ABdhPJysuNOjZY5GCinAVAI/86KtfJSHEffoM1cAksa98shT3txdI3I7FRV3oOBW5WFv6hon1WBC9g== X-Received: by 2002:a5d:6343:: with SMTP id b3mr17177288wrw.124.1631969737641; Sat, 18 Sep 2021 05:55:37 -0700 (PDT) Received: from Home-Mac ([141.226.13.159]) by smtp.gmail.com with ESMTPSA id j27sm8566044wms.6.2021.09.18.05.55.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Sep 2021 05:55:37 -0700 (PDT) From: Daniel Fleischer To: Jim Porter Subject: Re: bug#49518: 28.0.50; electric-pair-mode skip-self fails for single-quotes in python-mode References: <877dhxp8wn.fsf@gmx.net> Date: Sat, 18 Sep 2021 15:55:35 +0300 In-Reply-To: (Jim Porter's message of "Sun, 11 Jul 2021 10:34:19 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 49518 Cc: 49518@debbugs.gnu.org, Stephen Berman X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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 '((?' . ?')))) -- Daniel Fleischer From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 18 12:56:27 2021 Received: (at 49518) by debbugs.gnu.org; 18 Sep 2021 16:56:27 +0000 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 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 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) 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) Subject: Re: bug#49518: 28.0.50; electric-pair-mode skip-self fails for single-quotes in python-mode To: Daniel Fleischer References: <877dhxp8wn.fsf@gmx.net> From: Jim Porter Message-ID: <58515d93-dbca-4cd1-e820-ad9d5bb6d462@gmail.com> Date: Sat, 18 Sep 2021 09:56:17 -0700 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 49518 Cc: 49518@debbugs.gnu.org, Stephen Berman , =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) (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 From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 18 19:43:57 2021 Received: (at 49518) by debbugs.gnu.org; 18 Sep 2021 23:43:57 +0000 Received: from localhost ([127.0.0.1]:37156 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRjzw-00014i-Tn for submit@debbugs.gnu.org; Sat, 18 Sep 2021 19:43:57 -0400 Received: from mail-wr1-f41.google.com ([209.85.221.41]:34730) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRjzv-00014T-3m for 49518@debbugs.gnu.org; Sat, 18 Sep 2021 19:43:55 -0400 Received: by mail-wr1-f41.google.com with SMTP id t8so14599335wri.1 for <49518@debbugs.gnu.org>; Sat, 18 Sep 2021 16:43:55 -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=yfmmaiPXMxkapOLlDLUVcJDNgeDdC66y+PqGw2LwRmI=; b=ZXgXi6ib9jtdsBYO79/w+Piyy65+uPKJPdpPI0OU05hgfTtw/imWascBkIEMqUGEb7 9htj5y+bWCWm5yPE9NkF2UMEsSvCiQpLx9418tWK1C3VlohmjzzQlYhBMCI7+rLqk63w tQySXu4y272kEAd6oWrNc0LIUbqDeGhmyk9w7qmV3UA/icM6w7I2jn3YDy2BJrtJn1au wf4a9kxKgqp9We89qSkkH+cVAKBdFHhKvQX/8S7r3YTDSS5RCvDJ1riWW1MgQ/jgZFGK XKSoV4cAGQFQRq8XdkYB6s/ptcw1cN5m+yOfYNFG0gpkyWA/YbALiuTuoKDFZ71/3EZz N79g== 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=yfmmaiPXMxkapOLlDLUVcJDNgeDdC66y+PqGw2LwRmI=; b=0tmtvgCnF3w0QtST1g6rZux+7pItsgpGmbXHe3FfwH5koY5ZlxvpIONoqzr/jcMXKW HLv6fZNiZQQO8NSEEQ7uFtWdx/PFwS+yOrou3G7aUYaswfxrVl96fKhLl+l2gTjfjhi5 +1Gk6oZlhR91Kj+yHmlmTCdgkktO/l7T2t6VPJOgbIyHWJliExthJVhadbzJGLrnrEwn /17jgDoYhlu5UcgOUv6847LtD3nOp67WMMJaOqECzk/GnSlsyMa5F9a9IkqCq0YZxYaJ ICW0an7jfuW6Pm2ffbO+pjU8Y5wKHmLEtZP5iuzZioOru5eQCShlmffZtkQ5Ru4ci21I ciHA== X-Gm-Message-State: AOAM533EwRwRRwon313b8xmfIYDwpHe43iyuOzwRgIlzPR6DDObyRZTX 3pu+7AeCc8AZZ7Qwg36QR2U= X-Google-Smtp-Source: ABdhPJxdQmieswrs34/YPu6RMJKk9pNQW5ruSEnTv17WsQi/kHdXoD/dZXfeIUZqv1z5ABrxruwRmQ== X-Received: by 2002:adf:f3ce:: with SMTP id g14mr19822681wrp.95.1632008629047; Sat, 18 Sep 2021 16:43:49 -0700 (PDT) Received: from krug (a83-132-177-247.cpe.netcabo.pt. [83.132.177.247]) by smtp.gmail.com with ESMTPSA id o24sm14406900wmm.11.2021.09.18.16.43.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Sep 2021 16:43:48 -0700 (PDT) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Jim Porter Subject: Re: bug#49518: 28.0.50; electric-pair-mode skip-self fails for single-quotes in python-mode References: <877dhxp8wn.fsf@gmx.net> <58515d93-dbca-4cd1-e820-ad9d5bb6d462@gmail.com> Date: Sun, 19 Sep 2021 00:43:48 +0100 In-Reply-To: <58515d93-dbca-4cd1-e820-ad9d5bb6d462@gmail.com> (Jim Porter's message of "Sat, 18 Sep 2021 09:56:17 -0700") Message-ID: <87zgs9bgaz.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 49518 Cc: 49518@debbugs.gnu.org, Stephen Berman , Daniel Fleischer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Jim Porter writes: > (CCing Jo=C3=A3o since he wanted to hear about `electric-pair-mode' issue= s[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. Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 18 20:20:44 2021 Received: (at 49518) by debbugs.gnu.org; 19 Sep 2021 00:20:44 +0000 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 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 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) 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) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Jim Porter Subject: Re: bug#49518: 28.0.50; electric-pair-mode skip-self fails for single-quotes in python-mode References: <877dhxp8wn.fsf@gmx.net> <58515d93-dbca-4cd1-e820-ad9d5bb6d462@gmail.com> <87zgs9bgaz.fsf@gmail.com> Date: Sun, 19 Sep 2021 01:20:30 +0100 In-Reply-To: <87zgs9bgaz.fsf@gmail.com> (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vor?= =?utf-8?Q?a=22's?= message of "Sun, 19 Sep 2021 00:43:48 +0100") Message-ID: <87v92xbelt.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 49518 Cc: 49518@debbugs.gnu.org, Stephen Berman , Daniel Fleischer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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 From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 18 21:55:18 2021 Received: (at 49518) by debbugs.gnu.org; 19 Sep 2021 01:55:18 +0000 Received: from localhost ([127.0.0.1]:37224 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRm34-00049L-CS for submit@debbugs.gnu.org; Sat, 18 Sep 2021 21:55:18 -0400 Received: from mail-pj1-f42.google.com ([209.85.216.42]:52062) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRm2z-000492-Uh for 49518@debbugs.gnu.org; Sat, 18 Sep 2021 21:55:15 -0400 Received: by mail-pj1-f42.google.com with SMTP id dw14so9560447pjb.1 for <49518@debbugs.gnu.org>; Sat, 18 Sep 2021 18:55:13 -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=TZ+sGS66rkwEt+RHZOg9znH02Ue5jIseCeqJjQf1h28=; b=bMHD3iTjU4oeHtreo+Uw3mpTjq1My0DQq5Qjg6J5gZGFS8eRm+ABfxGVFmlmhZpJX+ 2a7gIQnFQMoLr8x1O1Vn4Ct5oyoGXzho/GJpbYYbo9NOTHU7XE7kMR4h/SN9oioWSQ+b yCBNjJXx7flXITrkIoWf6YndwdRg6Wm99QAhKSggTfaufnbzjrbvYCZ8RkBHisRFMNrD jqgrIkGSysilMRTjSY+qnHTbJhGrKMvPeukX9VFpRV5zKcln2F59ED2olDXMzqkHmg80 4Cn+NW6yZwEvQmd/g8lKskA1z9huf9mxvHp/13fZ3J1ktat+UCss/K5paWE3LU7RtJHn nq8Q== 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=TZ+sGS66rkwEt+RHZOg9znH02Ue5jIseCeqJjQf1h28=; b=EH0OZWAUEE2z2JvWZx1C6ebEyEzgM9H79b/WBCf2gLp6qTMYd8uQ/167cMjykk4kaZ MA0QAgSPhx2g7ROmGtIhMNztLqm9ceS03+UgZtP/EtvylLjvXIKcj/rm8C2fl63EX0rN RQzU03aS1bw0HXP4ER3f30DaZnnEdVUy9K5qmxXVI1QjJQCbT75WcLcbbfZ7PkbDoBoZ 21ywHgtybXRoYG9KZdSxnDMZy2RNehuj/7m525hKQ9J4EOi1oJkepP1NxXMKkVRurGYg J+mCYWT5X+hOtk/UIikbwqYwDj8xlr1SR/E/FPW1clpgJXFyZd1GAvVnHnFpFX2wYegO viWA== X-Gm-Message-State: AOAM531sDxsWKCIQFKsj4YLPvmRJJV4z8Hq39AaJVtaQwtXFh4Xx8yr6 e1vnc0kEpiTpn0o38bk8yw8= X-Google-Smtp-Source: ABdhPJwyyjDZZOwo52OWIlcGZ2hHhpJ5FWnapREUhdS+qotmCnKvVUUA9aQ078ciev4exgQM/mySxw== X-Received: by 2002:a17:90b:4f8a:: with SMTP id qe10mr19543556pjb.5.1632016508144; Sat, 18 Sep 2021 18:55:08 -0700 (PDT) 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 d18sm11207678pgk.24.2021.09.18.18.55.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 18 Sep 2021 18:55:07 -0700 (PDT) Subject: Re: bug#49518: 28.0.50; electric-pair-mode skip-self fails for single-quotes in python-mode To: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= References: <877dhxp8wn.fsf@gmx.net> <58515d93-dbca-4cd1-e820-ad9d5bb6d462@gmail.com> <87zgs9bgaz.fsf@gmail.com> <87v92xbelt.fsf@gmail.com> From: Jim Porter Message-ID: Date: Sat, 18 Sep 2021 18:55:06 -0700 MIME-Version: 1.0 In-Reply-To: <87v92xbelt.fsf@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 49518 Cc: 49518@debbugs.gnu.org, Stephen Berman , Daniel Fleischer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 9/18/2021 5:20 PM, João Távora wrote: > 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)) > Thanks, this patch works for me. It also works fine with my patch in bug#50538, so there's no conflict there. > Maybe better less brittle solutions can probably be found within the > syntax tables framework. I agree that something less brittle would be nice, but that might be tricky. I had tried a few options when I filed this bug, but nothing worked quite right. As for Stephen's desired behavior, the code snippet I posted above[1] mostly fixes it (just the `python-electric-pair-string-delimiter' part is necessary after your patch). However, that code doesn't work right if `electric-pair-skip-self' is set to nil, so I'd need to be a bit smarter with the implementation if I wanted to merge it into Emacs. Perhaps there's an even cleaner solution though. [1] https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-09/msg01509.html From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 19 06:45:03 2021 Received: (at 49518) by debbugs.gnu.org; 19 Sep 2021 10:45:03 +0000 Received: from localhost ([127.0.0.1]:37530 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRuJi-0001AF-Hr for submit@debbugs.gnu.org; Sun, 19 Sep 2021 06:45:03 -0400 Received: from mail-wr1-f44.google.com ([209.85.221.44]:35771) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRuJe-00019Y-4P for 49518@debbugs.gnu.org; Sun, 19 Sep 2021 06:45:01 -0400 Received: by mail-wr1-f44.google.com with SMTP id i23so23328148wrb.2 for <49518@debbugs.gnu.org>; Sun, 19 Sep 2021 03:44:58 -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=dEX4z6w+900Kqdr2IN9yQZZeY2jHq2nckRdgZYAgE4k=; b=iKUg6aBsxz88hKjbV1DBYtqxfLwrE1wqNxQNLHGGOKPXc5K2r5qgnaP2sRdFVP3SI7 UikK5ZhLw5hl6dNc6jUW59QvLPYxigm+oBeP+YpkE9qfajS/BYvX/YliU87zBKpRpR+v 32WmrDC1Gf7EPvpPgEyFtBfNPbjxy0U0tojDpIiXYakj8tSBVRpugExAC95PFJWJjy/v +fcACMPy7mCpkyZZ7Pcy2jF/HLVWEZ5o4KQ8LlVvDgHeIbCU+dkQg8DDmthKCmN/dVRX Y/6kokEuP1cqIlRJ4JZsD5fmBzr/aOf3LUEfV4D4hgpJG/Idc0LIfA4rWdJjsLE6AJp7 zj2g== 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=dEX4z6w+900Kqdr2IN9yQZZeY2jHq2nckRdgZYAgE4k=; b=4YzBwwdcI7L8dFwnxztCvsYGg+bXVTV++MnKIjk16GwPoy0W44KVX1mx0Toch2ofem yUDJgtGTc16KQz9WOxuHmql0zj9dVJ0f2HgeVmQKEZ9Z8Ob+Iw86IklXJNnA+JC0ecQn f5tjeF4pQikkc6fB7g/F/HB9xlllGnmqDHfJ2nU6tsWiv26Ws64uweS5ts52sWPc7ALI v6MxDhDx5qlFLvHK4r9AAcpzpDchLw9WmMImvYnIIr5OWJZk/E0CnNZCTTU1V5iQZ1c9 iwNyp5gpvw+N/5d7xcGTWfgF9XY3Mhi3hWp6rcpqbgeDDr7NlzuCfMlvlTzuU7L9cmOA 38FA== X-Gm-Message-State: AOAM530pNiS+07rEneXdt20L5bcHeQt5KQ6uOKOYK+zTSucibKyVwvfu plb3wSCLb2gFBMdI+NKAU6M= X-Google-Smtp-Source: ABdhPJxHl9aV73htzvWFRnALe7TVHFRjAf2q3Ap+WU8TGHZA91On+MLkdFEjbESI1EkJcGXxAiMg/A== X-Received: by 2002:adf:e44c:: with SMTP id t12mr23133739wrm.49.1632048292131; Sun, 19 Sep 2021 03:44:52 -0700 (PDT) Received: from krug (a83-132-177-247.cpe.netcabo.pt. [83.132.177.247]) by smtp.gmail.com with ESMTPSA id 23sm9013988wme.27.2021.09.19.03.44.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 03:44:51 -0700 (PDT) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Jim Porter Subject: Re: bug#49518: 28.0.50; electric-pair-mode skip-self fails for single-quotes in python-mode References: <877dhxp8wn.fsf@gmx.net> <58515d93-dbca-4cd1-e820-ad9d5bb6d462@gmail.com> <87zgs9bgaz.fsf@gmail.com> <87v92xbelt.fsf@gmail.com> Date: Sun, 19 Sep 2021 11:44:47 +0100 In-Reply-To: (Jim Porter's message of "Sat, 18 Sep 2021 18:55:06 -0700") Message-ID: <87o88oc09s.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 49518 Cc: 49518@debbugs.gnu.org, Stephen Berman , Daniel Fleischer , monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) [Stefan, I'm CC-ing you to assist with a python.el syntax propertization bug and a patch for it at the end of this mail] Jim Porter writes: > On 9/18/2021 5:20 PM, Jo=C3=A3o T=C3=A1vora wrote: >> 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 >> + (string 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)) >>=20 > > Thanks, this patch works for me.=20 >> Maybe better less brittle solutions can probably be found within the >> syntax tables framework. > I agree that something less brittle would be nice, but that might be > tricky. I had tried a few options when I filed this bug, but nothing > worked quite right. The point of 'electric-pair-syntax-info's STRING-OR-COMMENT-START return value is to tell if both the current and the pre-insertion point are and were inside a string or a comment. It seems reasonable (i.e. not crazy) to skip the same syntax _and_ char backwards to discover that. Ideally this would be remembered from before the insertion, it's true. But again, the fact that the patch passes all demanding tests is a good sign: they are quite strict. Notice, for example, that if the patch were the seemingly also reasonable: (let* ((pre-string-or-comment (or (bobp) (nth 8 (save-excursion - (skip-chars-backward - (string command-event)) + (skip-syntax-backward + (string (char-syntax com= mand-event))) (syntax-ppss (point)))))) (post-string-or-comment (nth 8 (syntax-ppss (point)))) (string-or-comment (and post-string-or-comment There would be one single test failure in a ruby-mode "mixed quote" situation. > As for Stephen's desired behavior, the code snippet I posted above[1] > mostly fixes it (just the `python-electric-pair-string-delimiter' part > is necessary after your patch). However, that code doesn't work right > if `electric-pair-skip-self' is set to nil, so I'd need to be a bit > smarter with the implementation if I wanted to merge it into > Emacs. Perhaps there's an even cleaner solution though. I think the cleaner solution is to fix a bug in python.el. Here's the reproduction for that bug (no electric pair mode involved) emacs -Q something.py type two single quotes M-: (nth 3 (syntax-ppss)) notice how the return value says you're outside a string, correctly type another quote M-: (nth 3 (syntax-ppss)) notice how the return value says you're inside a string, correctly backspace the quote just entered M-: (nth 3 (syntax-ppss)) notice how the return value says you're inside a string, incorrectly When this bug is fixed, I'm confident that Stephen's case will start working. In fact, it's possible that if this python.el bug were fixed, we wouldn't need the above patch at all, becasue backtracking one char into just before the third quote of a triple quote should _also_ yield a nil (nth 3 (syntax-ppss)). In fact, I have tried a patch for python.el that could fix _all_ of this (but would need some heavy testing probably): =20 (defvar python-mode-syntax-tablediff --git a/lisp/progmodes/python.el = b/lisp/progmodes/python.el index 19b79b6919..da7b92ae42 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -775,12 +775,14 @@ python-syntax-stringify ;; The first quote is escaped, so it's not part of a triple= quote! (goto-char (1+ quote-starting-pos))) ((null string-start) - ;; This set of quotes delimit the start of a string. - (put-text-property quote-starting-pos (1+ quote-starting-po= s) + ;; This set of quotes delimit the start of a string. Put + ;; the delimiter syntax in the last of the three quotes. + (put-text-property (1- quote-ending-pos) quote-ending-pos 'syntax-table (string-to-syntax "|"))) (t - ;; This set of quotes delimit the end of a string. - (put-text-property (1- quote-ending-pos) quote-ending-pos + ;; This set of quotes delimit the end of a string. Put the + ;; delimiter syntax in the first of the three quotess. + (put-text-property quote-starting-pos (1+ quote-starting-po= s) 'syntax-table (string-to-syntax "|")))))) =20=20=20=20=20 (defvar python-mode-syntax-table Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 19 12:35:41 2021 Received: (at 49518) by debbugs.gnu.org; 19 Sep 2021 16:35:41 +0000 Received: from localhost ([127.0.0.1]:39694 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRzn3-0004qU-BN for submit@debbugs.gnu.org; Sun, 19 Sep 2021 12:35:41 -0400 Received: from mail-wr1-f52.google.com ([209.85.221.52]:35609) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRzn1-0004qH-8f for 49518@debbugs.gnu.org; Sun, 19 Sep 2021 12:35:39 -0400 Received: by mail-wr1-f52.google.com with SMTP id i23so24346171wrb.2 for <49518@debbugs.gnu.org>; Sun, 19 Sep 2021 09:35: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=5AcKGFFgEeCqp4pwks9ss7OigemRiTwerGKNUuX9/bo=; b=o0MGVw7lPTZiYTxOIc738BAmP1OOFWYbspAS2A8VwOY4+fO4SqWTWzEeQWhjijBGEG k3FxZomkxxFSz9ZggeSBBEzgkYPUKRMBwX5d98EkQrKS/wYms5CvUiEpIur08p3eFj7Q IyqWk2JvnxBWEbjFOVQmDSAZ4oh+tpFHTqXzbBOj16VdZGtXFtXs8EMs5eV9i0wunb4k PWoPQ+wl90T+v3tWgrYhKeyPPxBACTNbuVEmQwLeRpmddX4QJ4nc0nef9rVtbBJ1Y85C Rc2bIaIbTmYwUU36WgsS3Fa1w/n9gA+H4EyaXDQexfcd22t+2wyqHBuWDuXovZYE4dFe poCw== 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=5AcKGFFgEeCqp4pwks9ss7OigemRiTwerGKNUuX9/bo=; b=B0ikx21DkBQtZrEvGVqCkkB08s8oqTSFR+Q4T24QzNwt+rbzAQgeExUUFAn9h9VnpB jCCMLJikhbUPwYpGPHHDD7BKBMFuxC+0JqhqLKXbJOMJXLMxm1xGtDjCmDXB2yGNT7Xc FQhPUr4evaA1dw8NGSucL4nJfHG3iPamestorIPFZn8RMiGjfOHs3aLaNz7rkvBHj9BZ HyGVxAEIS4My6VVisfcve+usktxpxVAdmNpkqGm+bArmlWKJ+BwGyTnMMADKRpha5MAP JY3f7pHK9As9N6hmXpVHxrRDVe3Ybsj7VhwfIzgKFsRaZE9h/53kPSAObEPaJ5oBtu10 vP8w== X-Gm-Message-State: AOAM5336GSdLfueGZsFu0Jh8waSUw7tYNoAs5uSMPmbSFoa1i9D4o7z4 CN08buEeTcp5TwRbGWz+7Dg= X-Google-Smtp-Source: ABdhPJzp0fEYX0++ymvhF1hSTX5D4OE7mILYwche3u52QjXovwm4oRjd+gwMhkA77crUAIF+7OdX1A== X-Received: by 2002:a05:6000:1569:: with SMTP id 9mr21779774wrz.337.1632069333296; Sun, 19 Sep 2021 09:35:33 -0700 (PDT) Received: from krug (a83-132-177-247.cpe.netcabo.pt. [83.132.177.247]) by smtp.gmail.com with ESMTPSA id c14sm7424430wrd.50.2021.09.19.09.35.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 09:35:32 -0700 (PDT) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Jim Porter Subject: Re: bug#49518: 28.0.50; electric-pair-mode skip-self fails for single-quotes in python-mode References: <877dhxp8wn.fsf@gmx.net> <58515d93-dbca-4cd1-e820-ad9d5bb6d462@gmail.com> <87zgs9bgaz.fsf@gmail.com> <87v92xbelt.fsf@gmail.com> <87o88oc09s.fsf@gmail.com> Date: Sun, 19 Sep 2021 17:35:31 +0100 In-Reply-To: <87o88oc09s.fsf@gmail.com> (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vor?= =?utf-8?Q?a=22's?= message of "Sun, 19 Sep 2021 11:44:47 +0100") Message-ID: <87k0jcbk18.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 49518 Cc: 49518@debbugs.gnu.org, Stephen Berman , Daniel Fleischer , monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Jo=C3=A3o T=C3=A1vora writes: > [Stefan, I'm CC-ing you to assist with a python.el syntax propertization > bug and a patch for it at the end of this mail] ...in fact, I've done a big of digging and it seems that the patch I posted earlier fixes a longstanding failing test in python-mode.el as well. Opened as the result of #17912 more than 7 years ago (i'd totally forgotten that)! Some triple-pairing tests I added there should have started failing, but didn't for some reason.=20=20 Anyway, skipping and pairing, and triple-pairing are working with the python.el, so I'm going to push the following fixes and tests soon, unless there are major objections. All python tests pass, too. Jo=C3=A3o commit b0c34e3c207be0450fddd70620c600cd546751f2 Author: Jo=C3=A3o T=C3=A1vora Date: Sun Sep 19 17:08:41 2021 +0100 Test electric-pair-mode more closely in python-mode, too (bug#49518) =20=20=20=20 * test/lisp/electric-tests.el (define-electric-pair-test): Also run main tests for python-mode. (pair-some-quotes-skip-others): Test another slightly different pairing. diff --git a/test/lisp/electric-tests.el b/test/lisp/electric-tests.el index 235f46056f..85a8e23bfa 100644 --- a/test/lisp/electric-tests.el +++ b/test/lisp/electric-tests.el @@ -174,7 +174,7 @@ define-electric-pair-test expected-string expected-point bindings - (modes '(quote (ruby-mode js-mode))) + (modes '(quote (ruby-mode js-mode python-mode))) (test-in-comments t) (test-in-strings t) (test-in-code t) @@ -297,7 +297,7 @@ only-skip-over-at-least-partially-balanced-stuff ;;; Quotes ;;; (define-electric-pair-test pair-some-quotes-skip-others - " \"\" " "-\"\"-----" :skip-pair-string "-ps------" + " \"\" " "-\"\"\"\"---" :skip-pair-string "-ps-p----" :test-in-strings nil :bindings `((electric-pair-text-syntax-table . ,prog-mode-syntax-table))) commit 44870df239ba681e826795fc54d69e8d9a517826 Author: Jo=C3=A3o T=C3=A1vora Date: Sun Sep 19 11:42:20 2021 +0100 Make syntax-ppss more accurate for Python triple quotes (bug#49518) =20=20=20=20 By putting delimiter syntax on the "inside" of Python triple-quoted strings, this makes syntax-ppss be more accurate and thus helps things like electric-pair-mode. Also, the test python-syntax-after-python-backspace now passes, again. =20=20=20=20 * lisp/progmodes/python.el (python-syntax-stringify): Put delimiter syntax in "inner" of the surrouding triple quotes. =20=20=20=20 * test/lisp/progmodes/python-tests.el (python-syntax-after-python-backspace): Now passes. diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 19b79b6919..da7b92ae42 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -775,12 +775,14 @@ python-syntax-stringify ;; The first quote is escaped, so it's not part of a triple quo= te! (goto-char (1+ quote-starting-pos))) ((null string-start) - ;; This set of quotes delimit the start of a string. - (put-text-property quote-starting-pos (1+ quote-starting-pos) + ;; This set of quotes delimit the start of a string. Put + ;; the delimiter syntax in the last of the three quotes. + (put-text-property (1- quote-ending-pos) quote-ending-pos 'syntax-table (string-to-syntax "|"))) (t - ;; This set of quotes delimit the end of a string. - (put-text-property (1- quote-ending-pos) quote-ending-pos + ;; This set of quotes delimit the end of a string. Put the + ;; delimiter syntax in the first of the three quotess. + (put-text-property quote-starting-pos (1+ quote-starting-pos) 'syntax-table (string-to-syntax "|")))))) =20 (defvar python-mode-syntax-table diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/pyth= on-tests.el index 1af579bb7a..a172f0f8e9 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -193,7 +193,6 @@ python-tests-look-at-2 =20 (ert-deftest python-syntax-after-python-backspace () ;; `python-indent-dedent-line-backspace' garbles syntax - :expected-result :failed (python-tests-with-temp-buffer "\"\"\"" (goto-char (point-max)) From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 21 05:59:56 2021 Received: (at 49518-done) by debbugs.gnu.org; 21 Sep 2021 09:59:56 +0000 Received: from localhost ([127.0.0.1]:44995 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mScZA-0003FZ-Ey for submit@debbugs.gnu.org; Tue, 21 Sep 2021 05:59:56 -0400 Received: from mail-pf1-f182.google.com ([209.85.210.182]:45019) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mScZ8-0003FJ-CH for 49518-done@debbugs.gnu.org; Tue, 21 Sep 2021 05:59:54 -0400 Received: by mail-pf1-f182.google.com with SMTP id 145so5043671pfz.11 for <49518-done@debbugs.gnu.org>; Tue, 21 Sep 2021 02:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=EYvkLaGVunwg5G5feVf9jkLUUr9swpEWp32jCnTxTAg=; b=PI9PB0SskNuwq7Bam+KanC63BYxlQPzujyR+t4jEDqK+NypWWHxJG7ciFcvAh3AJTA ndP3Gs2n1DJwCF4ovPsMNKZipRXbZLgUpcrBZHK4iOeLGcJJ/uhSXcjm0v45Ts+5Iaph mXL38OpmF2zk+v3YPsPw7j9FYJu7Gibb4bqavh2yjchol7nSUYbO9F/YgNa2fN/IoYq6 RCpo8XT822RyzUAjQOQjOcE0puQ3EosV1gc3nK9hCECb42RENGWW7SHtnEZNfkxilyOt ZeGzm79tAoJr1MgGHxwM+6UXoYpX/oSDQmTfa8AdpZZTTxfiyJcNQo1pnTAxg+QCAZo7 kY3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=EYvkLaGVunwg5G5feVf9jkLUUr9swpEWp32jCnTxTAg=; b=dUO1eDZakUgkgrC6fuzQacDiFC9qZpgaxlcfVcf3MpVp1HkAJRnglUlrRgaAkRdBSs bKwPnO8NiZXZsIFMd0tRAKq0N5t2KAQiofLWh8IUTsO4OTNyfyNO9ngXe5sNaPxrBskb 0pjwrp1ViKqSQGyg6TquoSg+34o1oWudje6w8o1H6I6tpZFZ9HtJuOhjvjX71eM6H/68 TIceQS89y4xQs94Aj+6l3a83LhSTv/TNFQI6DGUT/q+da4XPViFAPfOJ3S8LpIzcqcgK 1UFpq/z7i8CfcCmusuHqn2RI4ttSJ6nN4Q+rJTb+u5v7KSaNdt9vX/qrZWFY2036jNac Hn8A== X-Gm-Message-State: AOAM532J7wvEf15EiDpeKcEoYP2514hnQitRVi89oSDRFT9upLGS22aN g1CKNTs+UnMWaczRLyWkc22Tomj83ozOKSziYg0= X-Google-Smtp-Source: ABdhPJxuBIG9d25izLMwiFua4jZEZ6/WtZlKoa29vJGYaMk3tlEvwWAaLpF39OcvtD10I89jqt3oWPROYz/Sxf7kgiQ= X-Received: by 2002:a63:3648:: with SMTP id d69mr6463810pga.295.1632218388466; Tue, 21 Sep 2021 02:59:48 -0700 (PDT) MIME-Version: 1.0 References: <877dhxp8wn.fsf@gmx.net> <58515d93-dbca-4cd1-e820-ad9d5bb6d462@gmail.com> <87zgs9bgaz.fsf@gmail.com> <87v92xbelt.fsf@gmail.com> <87o88oc09s.fsf@gmail.com> <87k0jcbk18.fsf@gmail.com> In-Reply-To: <87k0jcbk18.fsf@gmail.com> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Tue, 21 Sep 2021 10:59:37 +0100 Message-ID: Subject: Re: bug#49518: 28.0.50; electric-pair-mode skip-self fails for single-quotes in python-mode To: Jim Porter , 49518-done@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 49518-done Cc: Stephen Berman , Daniel Fleischer , Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) After some more testing, pushed the aforementioned simple fix to master. Expanded the electric-pair-mode tests to python, too. See commit 0646c6817139aa905a2f6079fdc82eb4be944de0 and commit 9ad962e118a17daf073ef5308233f9301755035d Marking this bug done as all the problems mentioned here seem to be solved. I'd appreciate confirmation/feedback. Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 22 16:04:23 2021 Received: (at 49518) by debbugs.gnu.org; 22 Sep 2021 20:04:23 +0000 Received: from localhost ([127.0.0.1]:51777 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mT8Tf-0008OA-5c for submit@debbugs.gnu.org; Wed, 22 Sep 2021 16:04:23 -0400 Received: from mail-pj1-f46.google.com ([209.85.216.46]:38581) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mT8Tb-0008Ns-HL for 49518@debbugs.gnu.org; Wed, 22 Sep 2021 16:04:21 -0400 Received: by mail-pj1-f46.google.com with SMTP id g13-20020a17090a3c8d00b00196286963b9so5307104pjc.3 for <49518@debbugs.gnu.org>; Wed, 22 Sep 2021 13:04:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:references:from:message-id:date:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=gXrRpSz7Qtw7ELAK8tCxsapLyc5HMO+uI6H/MIh4Xnw=; b=LwlBWui7/5U0evocczI4yShVrNnlk2eDLaXowxQJFxenD9vdUi8s2EHpvX35dTwYfP fgs+aejMcrZ+m+asMMFmBLOU1HzBRSsN9lFKBi75pOYF6lFfU84w1rVHQP7tb7qLnbSm 5tCvZRxsWnQThWn+kFr8Ihj/Gk0PnTFSLWUiGxGaFDdXcB1EJn/SROWePpqiaV1eLfiI UoiYbOfsyi4no7KzIF6ogxRFH1bpg0Kx8VuiM1pBGSpeJmCczjI2mr+g/Yy2yeNhH3HW QjSKToZWp4lZ2OdE6er0iYdNVq/jmIkYh8skMQYbrd/ELL3Xpq+qdBAvpfjzy8vegwOZ WmYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=gXrRpSz7Qtw7ELAK8tCxsapLyc5HMO+uI6H/MIh4Xnw=; b=kk2+JtDgawlvIsIQSwrrBys50DzQI521mZwmu3k3MMDSUcx8Bp+9MISUyFIUs9S2h3 qYi0oyAHRPpV5K7jv7+Tc6AbxYTgYYs1gHm4WZpHMtWg7vb//TY2d2aOnizLXYjnZ/h4 MdaN057Q0FHLlFGHzs4gopgn8t9Qu97OHUBPOz+xyp+nL3/etpBWh2HGdxBjX8jPRKPP Ij0JA7vKX6446A0SUpw25NhgKxRBedvqryhwl8+VUpTMdU+XPlEkapAXOlEgs4rx2GmN BI/e9upODpjA3mDnOP3/17cVwLb3nj087TgxbX6oYdi6yG9y2D7xjEiMtmwHkyo5H4Bg z+NA== X-Gm-Message-State: AOAM533/LdRShrOrZNXg6xG2DhRPJKA53egccduwCPbRc/KtZCVWfNvT qLhJfcuauZ4V0y7J3eqcyJw= X-Google-Smtp-Source: ABdhPJyONNNlzJRyb4/Y7WguLW7roOj0TqE0kUR8WnObJ9Ny4PUsVTSld9IYg5ILmsTKo8e8+U0BMQ== X-Received: by 2002:a17:90b:17ca:: with SMTP id me10mr13416168pjb.171.1632341053664; Wed, 22 Sep 2021 13:04:13 -0700 (PDT) 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 u194sm3367748pfc.177.2021.09.22.13.04.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Sep 2021 13:04:13 -0700 (PDT) Subject: Re: bug#49518: 28.0.50; electric-pair-mode skip-self fails for single-quotes in python-mode To: 49518@debbugs.gnu.org, joaotavora@gmail.com References: <877dhxp8wn.fsf@gmx.net> <58515d93-dbca-4cd1-e820-ad9d5bb6d462@gmail.com> <87zgs9bgaz.fsf@gmail.com> <87v92xbelt.fsf@gmail.com> <87o88oc09s.fsf@gmail.com> <87k0jcbk18.fsf@gmail.com> From: Jim Porter Message-ID: <2df0fa4a-a986-85b7-1000-dbeb129d2257@gmail.com> Date: Wed, 22 Sep 2021 13:04:12 -0700 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 49518 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 9/21/2021 2:59 AM, João Távora wrote: > After some more testing, pushed the aforementioned simple fix to > master. Expanded the electric-pair-mode tests to python, too. > > See commit 0646c6817139aa905a2f6079fdc82eb4be944de0 > and commit 9ad962e118a17daf073ef5308233f9301755035d > > Marking this bug done as all the problems mentioned here seem > to be solved. I'd appreciate confirmation/feedback. I've tested things out with `emacs -Q', with my .emacs config, and with my patch in bug#50538, and everything appears to be working correctly. Thanks! From unknown Mon Jun 23 16:49:00 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 21 Oct 2021 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator