1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Make syntax-ppss more accurate for Python triple quotes (bug#49518)

By putting delimiter syntax on the last character of Python
triple-quoted strings, this makes syntax-ppss be more accurate.

Previously:

    emacs -Q something.py
    type two single quotes
    M-: (nth 3 (syntax-ppss))
    notice how the return value says you're outside a string, correctly
    type another quote
    M-: (nth 3 (syntax-ppss))
    notice how the return value says you're inside a string, correctly
    backspace the quote just entered
    M-: (nth 3 (syntax-ppss))
    notice how the return value says you're inside a string, incorrectly

With this patch the last step is corrected.  This 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.
This commit is contained in:
João Távora 2021-09-19 11:42:20 +01:00
parent 9ad962e118
commit 0646c68171
2 changed files with 7 additions and 5 deletions

View file

@ -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))