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#50538: [PATCH] 28.0.50; electric-pair-mode fails to pair double quotes in some cases in CC mode Date: Sat, 11 Sep 2021 20:58:47 -0700 Message-ID: <021853bf-0169-c158-ab3d-296b6c144e08@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------75E1D06C54734075675BA122" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1324"; mail-complaints-to="usenet@ciao.gmane.io" To: 50538@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 12 05:59:11 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 1mPGe7-0000BS-7C for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 12 Sep 2021 05:59:11 +0200 Original-Received: from localhost ([::1]:55372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPGe5-0004wf-B0 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 11 Sep 2021 23:59:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPGdz-0004wW-8V for bug-gnu-emacs@gnu.org; Sat, 11 Sep 2021 23:59:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58532) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mPGdy-0001qj-RK for bug-gnu-emacs@gnu.org; Sat, 11 Sep 2021 23:59:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mPGdy-0006wd-KN for bug-gnu-emacs@gnu.org; Sat, 11 Sep 2021 23:59:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 12 Sep 2021 03:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50538 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.163141913426676 (code B ref -1); Sun, 12 Sep 2021 03:59:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 12 Sep 2021 03:58:54 +0000 Original-Received: from localhost ([127.0.0.1]:41845 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mPGdq-0006wB-Ez for submit@debbugs.gnu.org; Sat, 11 Sep 2021 23:58:54 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:58774) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mPGdp-0006w4-9I for submit@debbugs.gnu.org; Sat, 11 Sep 2021 23:58:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42510) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPGdo-0004w9-Uh for bug-gnu-emacs@gnu.org; Sat, 11 Sep 2021 23:58:52 -0400 Original-Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:45605) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mPGdm-0001fF-TO for bug-gnu-emacs@gnu.org; Sat, 11 Sep 2021 23:58:52 -0400 Original-Received: by mail-pl1-x62e.google.com with SMTP id d17so3665870plr.12 for ; Sat, 11 Sep 2021 20:58:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:subject:to:message-id:date:mime-version:content-language; bh=meTzmysNbydRUqa2kUJfRR6+3A0Kqj+rVkVZZyDnf40=; b=WYbU1PIVGe++zu6fgUDakwXILOAREqyTtj57k8VQzL86zWTMILY0RugDtdX+Gh5DeF nKL/417Uv+W9EitC0xSop4vlL3YRrIkWPQNp+oivy/4PF39C91TvWQEYepUHktqLADsw pSpYT4L+vseilhWAfsapwkmiZ+lZhjFYlVDOy8TTaGKe6OHFizjRxUVOaiekiUkqAaEX lQJW4N+odKM6Gu4k9JQcoINlP97/1ABaiIH/nuuoS/lHblIwh/VtxAzlq5erwhIAu3/q 0WbrdqQWA8pd8WZLjaCC0bw+pTSauJpZObJ9XkcfC4q/NSiaRn3aPqZaJGaH+NQMS1ze VD6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:subject:to:message-id:date:mime-version :content-language; bh=meTzmysNbydRUqa2kUJfRR6+3A0Kqj+rVkVZZyDnf40=; b=D18L63bNfuFPVoiyEQj1ja+EkCwNN+x7yelJ2RQdIVpYbZuWYgKrVBSsFpUlz76loM jeGNGv3lY4k7uULA8ZJoxfcsp9YD/o+Q9+643DjijJpdo7JOKf43VbF6Kg2xuNvhCxBS 2HojoQ/XZDe2hjwX6JIImvb1JKtRTIgxtpB/NlDBH/Yc8ZiCvsjqo7lZx+Kd2b7XevpS k26udDlevCpAp6n0QxF1jh3gXV31mL7L2e0Ecgdv973nFXW1hkdhxKJ1D/uyf3iHN1Qr s6G1KIkkQpjmKgYkcOYPIFiQM4gCVRBm1zUY+8Ym5Y2F77WEp+GMTj8wvwWEYU8iIZyK ZPBQ== X-Gm-Message-State: AOAM530CdbfaPYigtEg9PAUTp+TfCcbJbCj9Tix7vAAbqTVDcuwkyPZV SUmiY5PLFtbjKwGi25ssQykIYMHSeY4= X-Google-Smtp-Source: ABdhPJxBOppqlMSoCMDZJ+VHDRkuW9Ygf2oiMZ+KBJlUKdCKI4ySZkwL+yNUCVgx00vHARJdJabOIA== X-Received: by 2002:a17:90b:3a91:: with SMTP id om17mr5822266pjb.7.1631419128575; Sat, 11 Sep 2021 20:58:48 -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 e16sm3186915pfj.90.2021.09.11.20.58.47 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 11 Sep 2021 20:58:47 -0700 (PDT) Content-Language: en-US Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=jporterbugs@gmail.com; helo=mail-pl1-x62e.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-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:214109 Archived-At: This is a multi-part message in MIME format. --------------75E1D06C54734075675BA122 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit (Note: I've just updated my copyright assignment information, but haven't received confirmation that everything is in order, so this might need to wait until that's done for it to merge.) There are a few related issues with pairing double quotes in CC mode while using `electric-pair-mode'. Hopefully the steps to reproduce below will explain the issues. In all the cases, I'd expect `electric-pair-mode' to insert a closing quote, but it doesn't. You can try similar steps in a `ruby-mode' buffer to see how it should work. ---------------------------------------- Common setup ------------ $ cat foo.c "foobar" $ emacs -Q foo.c M-x electric-pair-mode Note that | represents the point below. 1. Quote pairing in comments ---------------------------- C-o ;; to make a blank line // " ;; type this Expected: line 1 is // "|" Actual: line 1 is // "| 2. Inserting quote pairs before existing string ----------------------------------------------- " ;; type this (point is at beginning of buffer, before "foobar") Expected: line 1 is "|""foobar" Actual: line 1 is "|"foobar" 3. Splitting strings into two ----------------------------- "foo|bar" ;; move point here " ;; type this Expected: line 1 is "foo"|"bar" Actual: line 1 is "foo"|bar" ---------------------------------------- This is because the logic in the patch for bug#36474 isn't quite right. Currently, `c-electric-pair-inhibit-predicate' checks if the newly-inserted quotation mark has "a string fence syntax-table text property" (i.e. if it's the start of a string literal not terminated on that line[1]). However, this fails in all three cases above: in (1) because we're in a comment, not a string literal; and in (2) and (3) because it's the *last* quotation mark on the line that's unterminated, not the one before point. The attached patch fixes this by taking those cases into account. I also added `c-mode' to the list of modes to check in `test/lisp/electric-tests.el'. This required setting single-line comments as the default in those tests, since the tests expect single-line comments (I tried testing under `c++-mode', but the tests failed, I think due to <> being paren-like in C++). [1] I think this is what it means, at least (or close to it). --------------75E1D06C54734075675BA122 Content-Type: text/plain; charset=UTF-8; name="0001-Improve-behavior-of-electric-pair-mode-in-cc-mode.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename*0="0001-Improve-behavior-of-electric-pair-mode-in-cc-mode.patch" RnJvbSBkOWM4ODc5YjMwODJhNDAzNzU1NTJkZGI2MjljODNhMGQ5NDFiZmY5IE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBKaW0gUG9ydGVyIDxqcG9ydGVyYnVnc0BnbWFpbC5j b20+CkRhdG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3RyaWMtdGVzdHMuZWwKQEAgLTMyLDYgKzMyLDkgQEAKIChy ZXF1aXJlICdlbGVjLXBhaXIpCiAocmVxdWlyZSAnY2wtbGliKQogCis7OyBXaGVuIHJ1bm5p bmcgdGVzdHMgaW4gYy1tb2RlLCB1c2Ugc2luZ2xlLWxpbmUgY29tbWVudHMgKC8vKS4KKyhh ZGQtaG9vayAnYy1tb2RlLWhvb2sgKGxhbWJkYSAoKSAoYy10b2dnbGUtY29tbWVudC1zdHls ZSAtMSkpKQorCiAoZGVmdW4gY2FsbC13aXRoLXNhdmVkLWVsZWN0cmljLW1vZGVzIChmbikK ICAgKGxldCAoKHNhdmVkLWVsZWN0cmljIChpZiBlbGVjdHJpYy1wYWlyLW1vZGUgMSAtMSkp CiAgICAgICAgIChzYXZlZC1sYXlvdXQgKGlmIGVsZWN0cmljLWxheW91dC1tb2RlIDEgLTEp KQpAQCAtMTczLDcgKzE3Niw3IEBAIGRlZmluZS1lbGVjdHJpYy1wYWlyLXRlc3QKICAgICAg ICAgICBleHBlY3RlZC1zdHJpbmcKICAgICAgICAgICBleHBlY3RlZC1wb2ludAogICAgICAg ICAgIGJpbmRpbmdzCi0gICAgICAgICAgKG1vZGVzICcocXVvdGUgKHJ1YnktbW9kZSBqcy1t b2RlKSkpCisgICAgICAgICAgKG1vZGVzICcocXVvdGUgKHJ1YnktbW9kZSBqcy1tb2RlIGMt bW9kZSkpKQogICAgICAgICAgICh0ZXN0LWluLWNvbW1lbnRzIHQpCiAgICAgICAgICAgKHRl c3QtaW4tc3RyaW5ncyB0KQogICAgICAgICAgICh0ZXN0LWluLWNvZGUgdCkKLS0gCjIuMjUu MQoK --------------75E1D06C54734075675BA122--