From: Juri Linkov Date: Thu, 1 May 2025 18:03:34 +0000 (+0300) Subject: Improve elixir-ts--thing-settings. X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1922fc65eb8506ffb4a17edc2ef1775204c700b1;p=emacs.git Improve elixir-ts--thing-settings. * lisp/progmodes/elixir-ts-mode.el (elixir-ts--thing-settings): Add extra grouping "keywords" to named sexp nodes. Add "," to anonymous sexp nodes. Use bos/eos. * lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode): Use bos/eos for anonymous sexp nodes for better disambiguation. * test/lisp/progmodes/heex-ts-mode-tests.el (heex-ts-mode-test-indentation): Skip the test when 'elixir' is missing since 'heex-ts-mode' depends on the 'elixir' grammar. (cherry picked from commit cd557d6f6480cae81c39a451b2a2aaee720ba985) --- diff --git a/lisp/progmodes/elixir-ts-mode.el b/lisp/progmodes/elixir-ts-mode.el index 52744f194a2..7edf42c2489 100644 --- a/lisp/progmodes/elixir-ts-mode.el +++ b/lisp/progmodes/elixir-ts-mode.el @@ -590,10 +590,12 @@ (defvar elixir-ts--thing-settings `((sexp (not (or (and named - ,(rx bos (or "source" "comment") eos)) + ,(rx bos (or "source" "keywords" "comment") + eos)) (and anonymous - ,(rx (or "{" "}" "[" "]" "(" ")" - "do" "end")))))) + ,(rx bos (or "{" "}" "[" "]" "(" ")" "," + "do" "end") + eos))))) (list (or (and "\\`arguments\\'" ,#'elixir-ts--with-parens-0-p) (and "\\`unary_operator\\'" ,#'elixir-ts--with-parens-1-p) diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index e0f2520e837..30882f055d3 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -1179,11 +1179,12 @@ leading double colon is not added." "then") eos)) (and anonymous - ,(rx (or "do" "begin" - "if" "unless" - "def" "end" - "(" ")" "[" "]" - "{" "}" "|" "," ";")))))) + ,(rx bos (or "do" "begin" + "if" "unless" + "def" "end" + "(" ")" "[" "]" + "{" "}" "|" "," ";") + eos))))) (list ,(cons (rx bos (or diff --git a/test/lisp/progmodes/heex-ts-mode-tests.el b/test/lisp/progmodes/heex-ts-mode-tests.el index 01c7ed0fcf1..816d4dd7158 100644 --- a/test/lisp/progmodes/heex-ts-mode-tests.el +++ b/test/lisp/progmodes/heex-ts-mode-tests.el @@ -24,7 +24,7 @@ (require 'treesit) (ert-deftest heex-ts-mode-test-indentation () - (skip-unless (treesit-ready-p 'heex)) + (skip-unless (and (treesit-ready-p 'heex) (treesit-ready-p 'elixir))) (ert-test-erts-file (ert-resource-file "indent.erts"))) (provide 'heex-ts-mode-tests)