bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#49518: 28.0.50; electric-pair-mode skip-self fails for single-quotes


From: João Távora
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
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]