aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorDmitry Gutov2024-01-26 03:00:04 +0200
committerDmitry Gutov2024-01-26 03:00:23 +0200
commit737d46e04d73dbad84bf0225cebb1c936ff89365 (patch)
tree80d26378f34651cd70eb54628007e5307d6c2b83 /lisp/progmodes/python.el
parent22a58fccb763da6ec52f4bea98f91647b71ee1f0 (diff)
downloademacs-737d46e04d73dbad84bf0225cebb1c936ff89365.tar.gz
emacs-737d46e04d73dbad84bf0225cebb1c936ff89365.zip
python--treesit-syntax-propertize: Fix edits in the middle
* lisp/progmodes/python.el (python--treesit-syntax-propertize): Process the beginning and the end of the triple-quoted string's delimiters separately. Among other things, that still works when the beginning is outside of the propertized region (bug#68445).
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el18
1 files changed, 9 insertions, 9 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index e2f614f52c2..41f612c8b1c 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1359,15 +1359,15 @@ For NODE, OVERRIDE, START, END, and ARGS, see
1359 (save-excursion 1359 (save-excursion
1360 (goto-char start) 1360 (goto-char start)
1361 (while (re-search-forward (rx (or "\"\"\"" "'''")) end t) 1361 (while (re-search-forward (rx (or "\"\"\"" "'''")) end t)
1362 (let ((node (treesit-node-at (point)))) 1362 (let ((node (treesit-node-at (- (point) 3))))
1363 ;; The triple quotes surround a non-empty string. 1363 ;; Handle triple-quoted strings.
1364 (when (equal (treesit-node-type node) "string_content") 1364 (pcase (treesit-node-type node)
1365 (let ((start (treesit-node-start node)) 1365 ("string_start"
1366 (end (treesit-node-end node))) 1366 (put-text-property (1- (point)) (point)
1367 (put-text-property (1- start) start 1367 'syntax-table (string-to-syntax "|")))
1368 'syntax-table (string-to-syntax "|")) 1368 ("string_end"
1369 (put-text-property end (min (1+ end) (point-max)) 1369 (put-text-property (- (point) 3) (- (point) 2)
1370 'syntax-table (string-to-syntax "|")))))))) 1370 'syntax-table (string-to-syntax "|"))))))))
1371 1371
1372 1372
1373;;; Indentation 1373;;; Indentation