diff options
| author | Juri Linkov | 2025-04-09 21:21:53 +0300 |
|---|---|---|
| committer | Juri Linkov | 2025-04-09 21:21:53 +0300 |
| commit | 99a2cb05a41c66565d417e11e60f4324aaa5c5b5 (patch) | |
| tree | 64545332ce9b2bd6a8aaeb354c2ce40560edac16 /lisp/textmodes | |
| parent | fa247a24a5ec9cf10865f0ac3711eddfd0ad3546 (diff) | |
| download | emacs-99a2cb05a41c66565d417e11e60f4324aaa5c5b5.tar.gz emacs-99a2cb05a41c66565d417e11e60f4324aaa5c5b5.zip | |
New command 'treesit-toggle-sexp-mode' (bug#76676).
* lisp/treesit.el (treesit-forward-sexp): Don't use
'treesit-sexp-type-regexp' reserved for list commands
to override their default 'list' thing.
(treesit-down-list, treesit-up-list): Use
'treesit-sexp-type-regexp' instead of 'list'
when it's non-nil.
(treesit-toggle-sexp-mode): New command.
* lisp/progmodes/c-ts-mode.el (c-ts-mode--thing-settings):
Improve 'sexp' thing settings to exclude the top-level
"translation_unit" that just moves to EOF and also "comment".
* lisp/progmodes/elixir-ts-mode.el (elixir-ts--sexp-regexp): Remove.
(elixir-ts--forward-sexp): Remove to use the default 'sexp' navigation.
(elixir-ts--with-parens-0-p, elixir-ts--with-parens-1-p):
New internal functions.
(elixir-ts-mode): Add 'treesit-thing-settings'
instead of 'forward-sexp-function' (bug#76788).
* lisp/progmodes/heex-ts-mode.el (heex-ts--sexp-regexp): Remove.
(heex-ts--forward-sexp): Remove to use the default 'sexp' navigation.
(heex-ts--thing-settings): New variable.
(heex-ts-mode): Use 'heex-ts--thing-settings'
instead of 'forward-sexp-function'.
* lisp/progmodes/java-ts-mode.el (java-ts-mode):
Improve 'sexp' thing to use settings like in c-ts-mode.
* lisp/progmodes/php-ts-mode.el (php-ts-mode):
Improve 'sexp' thing settings to exclude the top-level
"program" that just moves to EOF and also "comment".
* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode):
Improve 'sexp' thing to use settings like in c-ts-mode.
* lisp/textmodes/css-mode.el (css--treesit-thing-settings):
Add 'sexp' thing. Add "string_value" to 'text' thing.
* lisp/textmodes/html-ts-mode.el (html-ts-mode--treesit-things-settings):
Improve 'sexp' thing to use settings like in c-ts-mode.
Add "doctype" to the 'list' thing.
Diffstat (limited to 'lisp/textmodes')
| -rw-r--r-- | lisp/textmodes/css-mode.el | 10 | ||||
| -rw-r--r-- | lisp/textmodes/html-ts-mode.el | 18 |
2 files changed, 17 insertions, 11 deletions
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 02c3618d281..765589593cd 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el | |||
| @@ -1781,7 +1781,13 @@ rgb()/rgba()." | |||
| 1781 | res))))))) | 1781 | res))))))) |
| 1782 | 1782 | ||
| 1783 | (defvar css--treesit-thing-settings | 1783 | (defvar css--treesit-thing-settings |
| 1784 | `((css (list | 1784 | `((css (sexp |
| 1785 | (not (or (and named | ||
| 1786 | ,(rx bos (or "stylesheet" "comment") eos)) | ||
| 1787 | (and anonymous | ||
| 1788 | ,(rx (or "{" "}" "[" "]" | ||
| 1789 | "(" ")" ",")))))) | ||
| 1790 | (list | ||
| 1785 | ,(rx bos (or "keyframe_block_list" | 1791 | ,(rx bos (or "keyframe_block_list" |
| 1786 | "block" | 1792 | "block" |
| 1787 | "pseudo_class_arguments" | 1793 | "pseudo_class_arguments" |
| @@ -1804,7 +1810,7 @@ rgb()/rgba()." | |||
| 1804 | "declaration") | 1810 | "declaration") |
| 1805 | eos)) | 1811 | eos)) |
| 1806 | (text | 1812 | (text |
| 1807 | ,(rx bos "comment" eos)))) | 1813 | ,(rx bos (or "comment" "string_value") eos)))) |
| 1808 | "Settings for `treesit-thing-settings'.") | 1814 | "Settings for `treesit-thing-settings'.") |
| 1809 | 1815 | ||
| 1810 | (defvar css--treesit-font-lock-feature-list | 1816 | (defvar css--treesit-font-lock-feature-list |
diff --git a/lisp/textmodes/html-ts-mode.el b/lisp/textmodes/html-ts-mode.el index 30d1f080b96..ff79945b291 100644 --- a/lisp/textmodes/html-ts-mode.el +++ b/lisp/textmodes/html-ts-mode.el | |||
| @@ -90,15 +90,15 @@ | |||
| 90 | 90 | ||
| 91 | (defvar html-ts-mode--treesit-things-settings | 91 | (defvar html-ts-mode--treesit-things-settings |
| 92 | `((html | 92 | `((html |
| 93 | (sexp ,(regexp-opt '("element" | 93 | (sexp (not (or (and named |
| 94 | "text" | 94 | ,(rx bos (or "document" "tag_name") eos)) |
| 95 | "attribute" | 95 | (and anonymous |
| 96 | "value"))) | 96 | ,(rx (or "<!" "<" ">" "</")))))) |
| 97 | (list ,(rx (or | 97 | (list ,(rx (or "doctype" |
| 98 | ;; Also match script_element and style_element | 98 | ;; Also match script_element and style_element |
| 99 | "element" | 99 | "element" |
| 100 | ;; HTML comments have the element syntax | 100 | ;; HTML comments have the element syntax |
| 101 | "comment"))) | 101 | "comment"))) |
| 102 | (sentence ,(rx (and bos (or "tag_name" "attribute") eos))) | 102 | (sentence ,(rx (and bos (or "tag_name" "attribute") eos))) |
| 103 | (text ,(regexp-opt '("comment" "text"))))) | 103 | (text ,(regexp-opt '("comment" "text"))))) |
| 104 | "Settings for `treesit-thing-settings'.") | 104 | "Settings for `treesit-thing-settings'.") |