unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Jim Porter <jporterbugs@gmail.com>
Cc: 49518@debbugs.gnu.org, Stephen Berman <stephen.berman@gmx.net>,
	Daniel Fleischer <danflscr@gmail.com>,
	monnier@iro.umontreal.ca
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	[thread overview]
Message-ID: <87k0jcbk18.fsf@gmail.com> (raw)
In-Reply-To: <87o88oc09s.fsf@gmail.com> ("João Távora"'s message of "Sun, 19 Sep 2021 11:44:47 +0100")

João Távora <joaotavora@gmail.com> 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.  

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ão

commit b0c34e3c207be0450fddd70620c600cd546751f2
Author: João Távora <joaotavora@gmail.com>
Date:   Sun Sep 19 17:08:41 2021 +0100

    Test electric-pair-mode more closely in python-mode, too (bug#49518)
    
    * 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ão Távora <joaotavora@gmail.com>
Date:   Sun Sep 19 11:42:20 2021 +0100

    Make syntax-ppss more accurate for Python triple quotes (bug#49518)
    
    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.
    
    * lisp/progmodes/python.el (python-syntax-stringify): Put
    delimiter syntax in "inner" of the surrouding triple quotes.
    
    * 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 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-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 "|"))))))
 
 (defvar python-mode-syntax-table
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-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
 
 (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))








  reply	other threads:[~2021-09-19 16:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-11  1:32 bug#49518: 28.0.50; electric-pair-mode skip-self fails for single-quotes in python-mode Jim Porter
2021-07-11  8:11 ` Stephen Berman
2021-07-11 17:34   ` Jim Porter
2021-09-18 12:55     ` Daniel Fleischer
2021-09-18 16:56       ` Jim Porter
2021-09-18 23:43         ` João Távora
2021-09-19  0:20           ` João Távora
2021-09-19  1:55             ` Jim Porter
2021-09-19 10:44               ` João Távora
2021-09-19 16:35                 ` João Távora [this message]
2021-09-21  9:59                   ` João Távora
2021-09-22 20:04                     ` Jim Porter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k0jcbk18.fsf@gmail.com \
    --to=joaotavora@gmail.com \
    --cc=49518@debbugs.gnu.org \
    --cc=danflscr@gmail.com \
    --cc=jporterbugs@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    --cc=stephen.berman@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).