summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorYuan Fu <casouri@gmail.com>2022-11-20 20:31:42 -0800
committerYuan Fu <casouri@gmail.com>2022-11-21 01:29:31 -0800
commit3f25b22cadc9f73583e83b00f828ee00efa8764e (patch)
tree786f2c9e19abe476d1a242108ca5c6abbb7f184d /lisp
parent938e68bb280c96eaf163bd932ab2582fbe27e780 (diff)
downloademacs-3f25b22cadc9f73583e83b00f828ee00efa8764e.tar.gz
emacs-3f25b22cadc9f73583e83b00f828ee00efa8764e.tar.bz2
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')
-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
fontified."
(let* ((string-beg (treesit-node-start node))
(string-end (treesit-node-end node))
+ (maybe-expression (treesit-node-parent node))
(maybe-defun (treesit-node-parent
(treesit-node-parent
- (treesit-node-parent node))))
- (face (if (member (treesit-node-type maybe-defun)
- '("function_definition"
- "class_definition"))
+ maybe-expression)))
+ (face (if (and (member (treesit-node-type maybe-defun)
+ '("function_definition"
+ "class_definition"))
+ ;; This check filters out this case:
+ ;; def function():
+ ;; return "some string"
+ (equal (treesit-node-type maybe-expression)
+ "expression_statement"))
'font-lock-doc-face
'font-lock-string-face)))
(when (eq (char-after string-beg) ?f)