aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorEli Zaretskii2023-12-30 04:51:17 -0500
committerEli Zaretskii2023-12-30 04:51:17 -0500
commit3b7198dc4703671fa8b00ed3bf159cb56d4d7ba3 (patch)
tree13db74148b39c017ea6932c6572e1aa3c73a2259 /lisp/progmodes/python.el
parentaa0037aaf7c2cd7052925fdeca73c77c91254de1 (diff)
parent530315287254da2e6b0767ad343fa55f79be8536 (diff)
downloademacs-3b7198dc4703671fa8b00ed3bf159cb56d4d7ba3.tar.gz
emacs-3b7198dc4703671fa8b00ed3bf159cb56d4d7ba3.zip
Merge from origin/emacs-29
53031528725 Revert "Fix treesit-node-field-name and friends (bug#66674)" fa0bb88302b ; * src/buffer.c (syms_of_buffer) <default-directory>: Do... 44517037aed ; Fix typo ccf46acefd2 ; Fix last change. c86b039dffc ; * etc/DEBUG: Improve advice for debugging native-compil... 9afba605bbc Explain status "r" in `epa-list-keys` 62714221968 ; * lisp/dired.el (dired--make-directory-clickable): Refo... fcbb0044899 Fix mouse clicks on directory line in Dired be8a7155b48 Fix 'split-root-window-right' and 'split-root-window-below' eb19984c4db Mark icalendar.el as maintained by emacs-devel 03dc914fd37 ; Fix footnotes in ELisp Intro manual ceacf753958 Fix usage of `setq-default' and offer more suggestions 2701da0eee5 Fix python-ts-mode triple quote syntax (bug#67262) 683c7c96871 Increment parser timestamp when narrowing changes (bug#67... 8ae42c825e1 ruby-ts-mode: Fix indentation for string_array closer 9cfa498e0ab treesit-major-mode-setup: Use 'treesit--syntax-propertize... da2e440462b ruby-ts-mode: Fix an out-of-bounds error with heredoc at eob 6ea507296a7 Correctly refontify changed region in tree-sitter modes (...
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el17
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