aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorYuan Fu2022-11-20 20:31:42 -0800
committerYuan Fu2022-11-21 01:29:31 -0800
commit3f25b22cadc9f73583e83b00f828ee00efa8764e (patch)
tree786f2c9e19abe476d1a242108ca5c6abbb7f184d /lisp/progmodes/python.el
parent938e68bb280c96eaf163bd932ab2582fbe27e780 (diff)
downloademacs-3f25b22cadc9f73583e83b00f828ee00efa8764e.tar.gz
emacs-3f25b22cadc9f73583e83b00f828ee00efa8764e.zip
Tweak python-ts-mode fontification
* lisp/progmodes/python.el (python--treesit-fontify-string): Make the matching condition for docstrings more specific.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el14
1 files changed, 10 insertions, 4 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index c49af223c66..d38d0292775 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1020,12 +1020,18 @@ f-strings. OVERRIDE is the override flag described in
1020fontified." 1020fontified."
1021 (let* ((string-beg (treesit-node-start node)) 1021 (let* ((string-beg (treesit-node-start node))
1022 (string-end (treesit-node-end node)) 1022 (string-end (treesit-node-end node))
1023 (maybe-expression (treesit-node-parent node))
1023 (maybe-defun (treesit-node-parent 1024 (maybe-defun (treesit-node-parent
1024 (treesit-node-parent 1025 (treesit-node-parent
1025 (treesit-node-parent node)))) 1026 maybe-expression)))
1026 (face (if (member (treesit-node-type maybe-defun) 1027 (face (if (and (member (treesit-node-type maybe-defun)
1027 '("function_definition" 1028 '("function_definition"
1028 "class_definition")) 1029 "class_definition"))
1030 ;; This check filters out this case:
1031 ;; def function():
1032 ;; return "some string"
1033 (equal (treesit-node-type maybe-expression)
1034 "expression_statement"))
1029 'font-lock-doc-face 1035 'font-lock-doc-face
1030 'font-lock-string-face))) 1036 'font-lock-string-face)))
1031 (when (eq (char-after string-beg) ?f) 1037 (when (eq (char-after string-beg) ?f)