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 17:35:31 +0100 Message-ID: <87k0jcbk18.fsf@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> 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="26692"; 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 , monnier@iro.umontreal.ca To: Jim Porter Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 19 18:38:56 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 1mRzqC-0006qK-4N for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 Sep 2021 18:38:56 +0200 Original-Received: from localhost ([::1]:40704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRzqB-0007qp-1o for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 Sep 2021 12:38:55 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43300) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRznO-00043D-Cw for bug-gnu-emacs@gnu.org; Sun, 19 Sep 2021 12:36:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56381) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mRznO-00026t-5c for bug-gnu-emacs@gnu.org; Sun, 19 Sep 2021 12:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mRznO-0004r3-2V for bug-gnu-emacs@gnu.org; Sun, 19 Sep 2021 12:36: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 16:36: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.163206934118635 (code B ref 49518); Sun, 19 Sep 2021 16:36:02 +0000 Original-Received: (at 49518) by debbugs.gnu.org; 19 Sep 2021 16:35:41 +0000 Original-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 Original-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 Original-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) Original-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) In-Reply-To: <87o88oc09s.fsf@gmail.com> ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Sun, 19 Sep 2021 11:44:47 +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:214752 Archived-At: 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))