]> git.eshelyaron.com Git - emacs.git/commit
Make syntax-ppss more accurate for Python triple quotes (bug#49518)
authorJoão Távora <joaotavora@gmail.com>
Sun, 19 Sep 2021 10:42:20 +0000 (11:42 +0100)
committerJoão Távora <joaotavora@gmail.com>
Tue, 21 Sep 2021 09:56:27 +0000 (10:56 +0100)
commit0646c6817139aa905a2f6079fdc82eb4be944de0
tree99744a6d07ea4486b2abd0911c9aa3c22de96747
parent9ad962e118a17daf073ef5308233f9301755035d
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.
lisp/progmodes/python.el
test/lisp/progmodes/python-tests.el