From aa6cb4166174d2b7d601bb3dc6c2f03b5296a442 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Sat, 21 Oct 2023 11:05:47 -0700 Subject: [PATCH] Documentation for treesit-font-lock-rules change * doc/lispref/modes.texi (Parser-based Font Lock): Update manual. * lisp/treesit.el (treesit-font-lock-rules): Update docstring. --- doc/lispref/modes.texi | 5 ++++- etc/NEWS | 5 +++++ lisp/treesit.el | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 00148420893..f365d88fade 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -4149,7 +4149,7 @@ it add meta information to it. The @code{:language} keyword declares name of @var{query}. Users can control which features are enabled with @code{treesit-font-lock-level} and @code{treesit-font-lock-feature-list} (described below). These two -keywords are mandatory. +keywords are mandatory (with exceptions). Other keywords are optional: @@ -4161,6 +4161,9 @@ Other keywords are optional: @item @tab @code{append} @tab Append the new face to existing ones @item @tab @code{prepend} @tab Prepend the new face to existing ones @item @tab @code{keep} @tab Fill-in regions without an existing face +@item @code{:default-language} @tab @var{language} +@tab Every @var{query} after this keyword will use @var{language} +by default. @end multitable Lisp programs mark patterns in @var{query} with capture names (names diff --git a/etc/NEWS b/etc/NEWS index 3810305e9f4..5d42d88fb60 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1353,6 +1353,11 @@ Since circular alias chains now cannot occur, 'function-alias-p', 'indirect-function' and 'indirect-variable' will never signal an error. Their 'noerror' arguments have no effect and are therefore obsolete. ++++ +** 'treesit-font-lock-rules' now accepts additional global keywords. +When supplied with ':default-language LANGUAGE', rules after it will +default to use 'LANGUAGE'. + * Changes in Emacs 30.1 on Non-Free Operating Systems diff --git a/lisp/treesit.el b/lisp/treesit.el index 669f41d8015..80bdf164b07 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -892,6 +892,8 @@ Other keywords include: `append' Append the new face to existing ones. `prepend' Prepend the new face to existing ones. `keep' Fill-in regions without an existing face. + :default-language LANGUAGE Every QUERY after this keyword + will use LANGUAGE by default. Capture names in QUERY should be face names like `font-lock-keyword-face'. The captured node will be fontified -- 2.39.5