From f331be1f074d68e7e5cdbac324419e07c186492a Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Wed, 2 Nov 2022 16:31:25 -0700 Subject: 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. --- lisp/progmodes/python.el | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'lisp/progmodes/python.el') 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 (cl-incf string-beg)) (treesit-fontify-with-override string-beg string-end face override))) -(defun python--treesit-fontify-string-end (node &rest _) - "Mark the whole string as to-be-fontified. -NODE is the ending quote of a string." - (let ((string (treesit-node-parent node))) - (setq jit-lock-context-unfontify-pos (treesit-node-start string)))) - (defvar python--treesit-settings (treesit-font-lock-rules :feature 'comment @@ -1051,8 +1045,8 @@ NODE is the ending quote of a string." :language 'python :override t ;; TODO Document on why we do this. - '((string "\"" @python--treesit-fontify-string-end :anchor) - (string :anchor "\"" @python--treesit-fontify-string :anchor)) + '((string :anchor "\"" @python--treesit-fontify-string) + (string) @contextual) :feature 'string-interpolation :language 'python -- cgit v1.2.1