emacs-diffs
[Top][All Lists]
Advanced

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

scratch/electric-pair-cleanup-and-49518-bugfix 44870df 3/4: Make syntax-


From: João Távora
Subject: scratch/electric-pair-cleanup-and-49518-bugfix 44870df 3/4: Make syntax-ppss more accurate for Python triple quotes (bug#49518)
Date: Sun, 19 Sep 2021 14:39:08 -0400 (EDT)

branch: scratch/electric-pair-cleanup-and-49518-bugfix
commit 44870df239ba681e826795fc54d69e8d9a517826
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>

    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): Passes again.
---
 lisp/progmodes/python.el            | 10 ++++++----
 test/lisp/progmodes/python-tests.el |  1 -
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 19b79b6..da7b92a 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -775,12 +775,14 @@ is used to limit the scan."
            ;; 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 1af579b..a172f0f 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -193,7 +193,6 @@ aliqua."
 
 (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]