From b440fa0a6b48a95323fa922b88e9a9a73d6c6360 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Wed, 16 Nov 2022 21:31:04 -0800 Subject: [PATCH] ; Elaborate on tree-sitter fontification features documentation * doc/lispref/modes.texi (Parser-based Font Lock) * lisp/treesit.el (treesit-font-lock-feature-list): Explain in more detail, and change some features. --- doc/lispref/modes.texi | 19 ++++++++++++++----- lisp/treesit.el | 10 +++++----- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 71687b0783d..8b20bc0b758 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -4077,11 +4077,20 @@ Each element of the list is a list of the form @w{@code{(@var{feature} list disables the corresponding query during font-lock. Common feature names, for many programming languages, include -function-name, type, variable-name (left-hand-side or @acronym{LHS} of -assignments), builtin, constant, keyword, string-interpolation, -comment, doc, string, operator, preprocessor, escape-sequence, and key -(in key-value pairs). Major modes are free to subdivide or extend -these common features. +@code{definition}, @code{type}, @code{assignment}, @code{builtin}, +@code{constant}, @code{keyword}, @code{string-interpolation}, +@code{comment}, @code{doc}, @code{string}, @code{operator}, +@code{preprocessor}, @code{escape-sequence}, and @code{key}. Major +modes are free to subdivide or extend these common features. + +Some of these features warrant some explanation: @code{definition} +highlights whatever is being defined, e.g., the function name in a +function definition, the struct name in a struct definition, the +variable name in a variable definition; @code{assignment} highlights +the whatever is being assigned to, e.g., the variable or field in an +assignment statement; @code{key} highlights keys in key-value pairs, +e.g., keys in a JSON object, or a Python dictionary; @code{doc} +highlights docstrings or doc-comments. For example, the value of this variable could be: @example diff --git a/lisp/treesit.el b/lisp/treesit.el index 1284afe84bc..6a41c1a4113 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -542,11 +542,11 @@ Removing a feature symbol from this list disables the corresponding query during font-lock. Common feature names (for general programming languages) include -function-name, type, variable-name (LHS of assignments), builtin, -constant, keyword, string-interpolation, comment, doc, string, -operator, preprocessor, escape-sequence, key (in key-value -pairs). Major modes are free to subdivide or extend on these -common features. +definition, type, assignment, builtin, constant, keyword, +string-interpolation, comment, doc, string, operator, property, +preprocessor, escape-sequence, key (in key-value pairs). Major +modes are free to subdivide or extend on these common features. +See the manual for more explanations on some of the feature. For changes to this variable to take effect, run `treesit-font-lock-recompute-features'.") -- 2.39.5