diff options
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 211969140ab..ff9402eaaaf 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1238,6 +1238,21 @@ For NODE, OVERRIDE, START, END, and ARGS, see | |||
| 1238 | (treesit-node-start node) (treesit-node-end node) | 1238 | (treesit-node-start node) (treesit-node-end node) |
| 1239 | 'font-lock-variable-use-face override start end))) | 1239 | 'font-lock-variable-use-face override start end))) |
| 1240 | 1240 | ||
| 1241 | (defun python--treesit-syntax-propertize (start end) | ||
| 1242 | "Propertize triple-quote strings between START and END." | ||
| 1243 | (save-excursion | ||
| 1244 | (goto-char start) | ||
| 1245 | (while (re-search-forward (rx (or "\"\"\"" "'''")) end t) | ||
| 1246 | (let ((node (treesit-node-at (point)))) | ||
| 1247 | ;; The triple quotes surround a non-empty string. | ||
| 1248 | (when (equal (treesit-node-type node) "string_content") | ||
| 1249 | (let ((start (treesit-node-start node)) | ||
| 1250 | (end (treesit-node-end node))) | ||
| 1251 | (put-text-property (1- start) start | ||
| 1252 | 'syntax-table (string-to-syntax "|")) | ||
| 1253 | (put-text-property end (min (1+ end) (point-max)) | ||
| 1254 | 'syntax-table (string-to-syntax "|")))))))) | ||
| 1255 | |||
| 1241 | 1256 | ||
| 1242 | ;;; Indentation | 1257 | ;;; Indentation |
| 1243 | 1258 | ||
| @@ -6854,6 +6869,8 @@ implementations: `python-mode' and `python-ts-mode'." | |||
| 6854 | #'python--treesit-defun-name) | 6869 | #'python--treesit-defun-name) |
| 6855 | (treesit-major-mode-setup) | 6870 | (treesit-major-mode-setup) |
| 6856 | 6871 | ||
| 6872 | (setq-local syntax-propertize-function #'python--treesit-syntax-propertize) | ||
| 6873 | |||
| 6857 | (python-skeleton-add-menu-items) | 6874 | (python-skeleton-add-menu-items) |
| 6858 | 6875 | ||
| 6859 | (when python-indent-guess-indent-offset | 6876 | (when python-indent-guess-indent-offset |