aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuan Fu2022-10-13 15:08:20 -0700
committerYuan Fu2022-10-13 15:09:51 -0700
commitbb8a46e559ec39437a1524b3e9746746768effcc (patch)
tree6563e14ce2a6b659f3a9907fa25924b14e1590b4
parentaf288d813b3c31a528ddcbdce08f497855a56e94 (diff)
downloademacs-bb8a46e559ec39437a1524b3e9746746768effcc.tar.gz
emacs-bb8a46e559ec39437a1524b3e9746746768effcc.zip
Update tree-sitter manual to reflect the previous commit
* doc/lispref/modes.texi: Update manual to reflect previous change: remove :toggle and :level, add :feature. Document new variables and functions. * doc/lispref/parsing.texi: Add the missing closing bracket in @code{(t . nil)}.
-rw-r--r--doc/lispref/modes.texi75
-rw-r--r--doc/lispref/parsing.texi6
2 files changed, 60 insertions, 21 deletions
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index b1287c6ad05..ed232556b28 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -3911,10 +3911,12 @@ a value that @var{treesit-font-lock-settings} accepts. An example:
3911@group 3911@group
3912(treesit-font-lock-rules 3912(treesit-font-lock-rules
3913 :language 'javascript 3913 :language 'javascript
3914 :feature 'constant
3914 :override t 3915 :override t
3915 '((true) @@font-lock-constant-face 3916 '((true) @@font-lock-constant-face
3916 (false) @@font-lock-constant-face) 3917 (false) @@font-lock-constant-face)
3917 :language 'html 3918 :language 'html
3919 :feature 'script
3918 "(script_element) @@font-lock-builtin-face") 3920 "(script_element) @@font-lock-builtin-face")
3919@end group 3921@end group
3920@end example 3922@end example
@@ -3922,7 +3924,12 @@ a value that @var{treesit-font-lock-settings} accepts. An example:
3922This function takes a list of text or s-exp queries. Before each 3924This function takes a list of text or s-exp queries. Before each
3923query, there are @var{:keyword} and @var{value} pairs that configure 3925query, there are @var{:keyword} and @var{value} pairs that configure
3924that query. The @code{:lang} keyword sets the query’s language and 3926that query. The @code{:lang} keyword sets the query’s language and
3925every query must specify the language. Other keywords are optional: 3927every query must specify the language. The @code{:feature} keyword
3928sets the feature name of the query. Users can control which features
3929are enabled with @code{font-lock-maximum-decoration} and
3930@code{treesit-font-lock-feature-list} (see below).
3931
3932Other keywords are optional:
3926 3933
3927@multitable @columnfractions .15 .15 .6 3934@multitable @columnfractions .15 .15 .6
3928@headitem Keyword @tab Value @tab Description 3935@headitem Keyword @tab Value @tab Description
@@ -3932,21 +3939,8 @@ every query must specify the language. Other keywords are optional:
3932@item @tab @code{append} @tab Append the new face to existing ones 3939@item @tab @code{append} @tab Append the new face to existing ones
3933@item @tab @code{prepend} @tab Prepend the new face to existing ones 3940@item @tab @code{prepend} @tab Prepend the new face to existing ones
3934@item @tab @code{keep} @tab Fill-in regions without an existing face 3941@item @tab @code{keep} @tab Fill-in regions without an existing face
3935@item @code{:toggle} @tab @var{symbol} @tab
3936If non-nil, its value should be a variable name. The variable's value
3937(nil/non-nil) disables/enables the query during fontification.
3938@item @tab nil @tab Always enable this query.
3939@item @code{:level} @tab @var{integer} @tab
3940If non-nil, its value should be the decoration level for this query.
3941Decoration level is controlled by @code{font-lock-maximum-decoration}.
3942@item @tab nil @tab Always enable this query.
3943@end multitable 3942@end multitable
3944 3943
3945Note that a query is applied only when both @code{:toggle} and
3946@code{:level} permit it. @code{:level} is used for global,
3947coarse-grained control, whereas @code{:toggle} is for local,
3948fine-grained control.
3949
3950Capture names in @var{query} should be face names like 3944Capture names in @var{query} should be face names like
3951@code{font-lock-keyword-face}. The captured node will be fontified 3945@code{font-lock-keyword-face}. The captured node will be fontified
3952with that face. Capture names can also be function names, in which 3946with that face. Capture names can also be function names, in which
@@ -3957,6 +3951,42 @@ is both a face and a function, the face takes priority. If a capture
3957name is not a face name nor a function name, it is ignored. 3951name is not a face name nor a function name, it is ignored.
3958@end defun 3952@end defun
3959 3953
3954@defvar treesit-font-lock-feature-list
3955This is a list of lists of feature symbols.
3956
3957Each sublist represents a decoration level.
3958@code{font-lock-maximum-decoration} controls which levels are
3959activated.
3960
3961Inside each sublist are feature symbols, which corresponds to the
3962@code{:feature} value of a query defined in
3963@code{treesit-font-lock-rules}. Removing a feature symbol from this
3964list disables the corresponding query during font-lock.
3965
3966Common feature names (for general programming language) include
3967function-name, type, variable-name (LHS of assignments), builtin,
3968constant, keyword, string-interpolation, comment, doc, string,
3969operator, preprocessor, escape-sequence, key (in key-value
3970pairs). Major modes are free to subdivide or extend on these
3971common features.
3972
3973For example, the value of this variable could be:
3974@example
3975@group
3976((comment string doc) ; level 1
3977 (function-name keyword type builtin constant) ; level 2
3978 (variable-name string-interpolation key)) ; level 3
3979@end group
3980@end example
3981
3982Major modes should set this variable before calling
3983@code{treesit-font-lock-enable}.
3984
3985@findex treesit-font-lock-recompute-features
3986In addition, for further changes to this variable to take effect, run
3987@code{treesit-font-lock-recompute-features}.
3988@end defvar
3989
3960@defvar treesit-font-lock-settings 3990@defvar treesit-font-lock-settings
3961A list of @var{setting}s for tree-sitter font lock. The exact format 3991A list of @var{setting}s for tree-sitter font lock. The exact format
3962of this variable is considered internal. One should always use 3992of this variable is considered internal. One should always use
@@ -3965,12 +3995,21 @@ of this variable is considered internal. One should always use
3965Each @var{setting} is of form 3995Each @var{setting} is of form
3966 3996
3967@example 3997@example
3968(@var{language} @var{query}) 3998(@var{query} @var{enable} @var{feature} @var{override})
3969@end example 3999@end example
3970 4000
3971Each @var{setting} controls one parser (often of different language). 4001@var{query} must be a compiled query (@pxref{Pattern Matching}).
3972And @var{language} is the language symbol (@pxref{Language 4002
3973Definitions}); @var{query} is the query (@pxref{Pattern Matching}). 4003For @var{setting} to be activated for font-lock, @var{enable} must be
4004t. To disable this @var{setting}, set @var{enable} to nil.
4005
4006@var{feature} is the ``feature name'' of the query, users can control
4007which features are enabled with @code{font-lock-maximum-decoration}
4008and @code{treesit-font-lock-feature-list}.
4009
4010@var{override} is the override flag for this query. Its value can be
4011t, nil, append, prepend, keep. See more in
4012@code{treesit-font-lock-rules}.
3974@end defvar 4013@end defvar
3975 4014
3976Multi-language major modes should provide range functions in 4015Multi-language major modes should provide range functions in
diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi
index 8b684d11fcd..d2a333027b9 100644
--- a/doc/lispref/parsing.texi
+++ b/doc/lispref/parsing.texi
@@ -87,9 +87,9 @@ library.
87This function returns non-nil if @var{language} exists and is 87This function returns non-nil if @var{language} exists and is
88loadable. 88loadable.
89 89
90If @var{detail} is non-nil, return @code{(t . nil) when @var{language} 90If @var{detail} is non-nil, return @code{(t . nil)} when
91is available, @code{(nil . DATA)} when unavailable. @var{data} is the 91@var{language} is available, @code{(nil . DATA)} when unavailable.
92signal data of @code{treesit-load-language-error}. 92@var{data} is the signal data of @code{treesit-load-language-error}.
93@end defun 93@end defun
94 94
95@vindex treesit-load-name-override-list 95@vindex treesit-load-name-override-list