aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorYuan Fu2022-11-02 16:31:25 -0700
committerYuan Fu2022-11-02 16:47:53 -0700
commitf331be1f074d68e7e5cdbac324419e07c186492a (patch)
treeeb2d16d70a9aa23ab3e5b2a083db4b59fefa780e /lisp/progmodes/python.el
parent040991a4697b50ebcb54e498e7de54b8d0885101 (diff)
downloademacs-f331be1f074d68e7e5cdbac324419e07c186492a.tar.gz
emacs-f331be1f074d68e7e5cdbac324419e07c186492a.zip
Add handling of contextual entities in tree-sitter font-lock
* lisp/progmodes/python.el: Remove function. (python--treesit-settings): Capture contextual node. * lisp/treesit.el (treesit--set-nonsticky): (treesit-font-lock-contextual-post-process): New functions. (treesit-font-lock-fontify-region): Change local variable START and END to NODE-START and NODE-END, handle special capture name "contextual". * doc/lispref/modes.texi (Parser-based Font Lock): Update manual.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el10
1 files changed, 2 insertions, 8 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 46559db2cd1..603cdb14e15 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1035,12 +1035,6 @@ f for f-strings. OVERRIDE is the override flag described in
1035 (cl-incf string-beg)) 1035 (cl-incf string-beg))
1036 (treesit-fontify-with-override string-beg string-end face override))) 1036 (treesit-fontify-with-override string-beg string-end face override)))
1037 1037
1038(defun python--treesit-fontify-string-end (node &rest _)
1039 "Mark the whole string as to-be-fontified.
1040NODE is the ending quote of a string."
1041 (let ((string (treesit-node-parent node)))
1042 (setq jit-lock-context-unfontify-pos (treesit-node-start string))))
1043
1044(defvar python--treesit-settings 1038(defvar python--treesit-settings
1045 (treesit-font-lock-rules 1039 (treesit-font-lock-rules
1046 :feature 'comment 1040 :feature 'comment
@@ -1051,8 +1045,8 @@ NODE is the ending quote of a string."
1051 :language 'python 1045 :language 'python
1052 :override t 1046 :override t
1053 ;; TODO Document on why we do this. 1047 ;; TODO Document on why we do this.
1054 '((string "\"" @python--treesit-fontify-string-end :anchor) 1048 '((string :anchor "\"" @python--treesit-fontify-string)
1055 (string :anchor "\"" @python--treesit-fontify-string :anchor)) 1049 (string) @contextual)
1056 1050
1057 :feature 'string-interpolation 1051 :feature 'string-interpolation
1058 :language 'python 1052 :language 'python