@findex treesit-fontify-with-override
Capture names can also be function names, in which case the function
-is called with 4 arguments: @var{start}, @var{end}, @var{node}, and
-@var{override}, where @var{start} and @var{end} are the start and end
-position of the node in buffer, @var{node} is the node itself, and
-@var{override} is the override property of the rule which captured
-this node. (If this function wants to respect the @var{override}
-argument, it can use @code{treesit-fontify-with-override}.) Beyond
-the 4 arguments presented, this function should accept more arguments
-as optional arguments for future extensibility.
+is called with 2 arguments: @var{node} and @var{override}, where
+@var{node} is the node itself, and @var{override} is the override
+property of the rule which captured this node. (If this function
+wants to respect the @var{override} argument, it can use
+@code{treesit-fontify-with-override}.) Beyond the 2 arguments
+presented, this function should accept more arguments as optional
+arguments for future extensibility.
If a capture name is both a face and a function, the face takes
priority. If a capture name is neither a face nor a function, it is
@font-lock-constant-face)))
"Tree-sitter font-lock settings.")
-(defun js--fontify-template-string (beg end node override &rest _)
+(defun js--fontify-template-string (node override &rest _)
"Fontify template string but not substitution inside it.
BEG, END, NODE refers to the template_string node.
OVERRIDE is the override flag described in
`treesit-font-lock-rules'."
- (ignore end)
;; You would have thought that the children of the string node spans
;; the whole string. No, the children of the template_string only
;; includes the starting "`", any template_substitution, and the
;; closing "`". That's why we have to track BEG instead of just
;; fontifying each child.
- (let ((child (treesit-node-child node 0)))
+ (let ((child (treesit-node-child node 0))
+ (beg (treesit-node-start node)))
(while child
(if (equal (treesit-node-type child) "template_substitution")
(treesit-fontify-with-override
"VMSError" "WindowsError"
))
-(defun python--treesit-fontify-string (_beg _end node override &rest _)
+(defun python--treesit-fontify-string (node override &rest _)
"Fontify string.
NODE is the leading quote in the string. Do not fontify the initial
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 (_beg _end node &rest _)
+(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)))
Capture names in QUERY should be face names like
`font-lock-keyword-face'. The captured node will be fontified
with that face. Capture names can also be function names, in
-which case the function is called with (START END NODE OVERRIDE),
-where START and END are the start and end position of the node in
-buffer, NODE is the tree-sitter node object, and OVERRIDE is the
-override option of that rule. This function should accept more
-arguments as optional arguments for future extensibility. If a
-capture name is both a face and a function, the face takes
+which case the function should have a signature (NODE OVERRIDE
+&rest _), where NODE is the tree-sitter node object, and OVERRIDE
+is the override option of that rule. This function should accept
+more arguments as optional arguments for future extensibility.
+
+If a capture name is both a face and a function, the face takes
priority. If a capture name is not a face name nor a function
name, it is ignored.
((facep face)
(treesit-fontify-with-override start end face override))
((functionp face)
- (funcall face start end node override)))
+ (funcall face node override)))
;; Don't raise an error if FACE is neither a face nor
;; a function. This is to allow intermediate capture
;; names used for #match and #eq.