Subject: Re: bug#76534: [PATCH] ; Cleanup sexp things in 'lua-ts-mode'

From: john muhl <[email-masked]>
Date: Mon, 24 Feb 2025 15:41:47 -0600

>From c2d2cecb68fa4612eeb0a7b819d6c4247d6fdd37 Mon Sep 17 00:00:00 2001
From: john muhl <[email-masked]>
Date: Mon, 24 Feb 2025 15:21:38 -0600
Subject: [PATCH] ; Cleanup sexp things in 'lua-ts-mode'

* lisp/progmodes/lua-ts-mode.el (lua-ts-mode): Remove some
nonsensical entries from 'treesit-thing-settings'.
* test/lisp/progmodes/lua-ts-mode-resources/movement.erts:
Add missing tests for 'backward-sexp'.  (Bug#76534)
---
 lisp/progmodes/lua-ts-mode.el                 | 13 +----
 .../lua-ts-mode-resources/movement.erts       | 58 +++++++++++++++++--
 2 files changed, 56 insertions(+), 15 deletions(-)

diff --git a/lisp/progmodes/lua-ts-mode.el b/lisp/progmodes/lua-ts-mode.el
index d4c1f70dec3..25b8b2fbd3f 100644
--- a/lisp/progmodes/lua-ts-mode.el
+++ b/lisp/progmodes/lua-ts-mode.el
@@ -785,8 +785,7 @@ lua-ts-mode
                 `((lua
                    (function ,(rx (or "function_declaration"
                                       "function_definition")))
-                   (keyword ,(regexp-opt lua-ts--keywords
-                                         'symbols))
+                   (keyword ,(regexp-opt lua-ts--keywords 'symbols))
                    (loop-statement ,(rx (or "do_statement"
                                             "for_statement"
                                             "repeat_statement"
@@ -804,18 +803,10 @@ lua-ts-mode
                              keyword
                              loop-statement
                              ,(rx (or "arguments"
-                                      "break_statement"
-                                      "expression_list"
-                                      "false"
-                                      "identifier"
-                                      "nil"
-                                      "number"
                                       "parameters"
                                       "parenthesized_expression"
                                       "string"
-                                      "table_constructor"
-                                      "true"
-                                      "vararg_expression"))))
+                                      "table_constructor"))))
                    (text "comment"))))
 
     ;; Imenu/Outline/Which-function.
diff --git a/test/lisp/progmodes/lua-ts-mode-resources/movement.erts b/test/lisp/progmodes/lua-ts-mode-resources/movement.erts
index 11e86f12926..6e2ffb21d0e 100644
--- a/test/lisp/progmodes/lua-ts-mode-resources/movement.erts
+++ b/test/lisp/progmodes/lua-ts-mode-resources/movement.erts
@@ -436,9 +436,9 @@ function f(a, b)| end
 Name: forward-sexp moves over strings
 
 =-=
-print("|1, 2, 3")
+print(|"1, 2, 3")
 =-=
-print("1, 2, 3|")
+print("1, 2, 3"|)
 =-=-=
 
 Name: forward-sexp moves over tables
@@ -557,9 +557,9 @@ function f|(a, b) end
 Name: backward-sexp moves over strings
 
 =-=
-print("1, 2, 3|")
+print("1, 2, 3"|)
 =-=
-print("|1, 2, 3")
+print(|"1, 2, 3")
 =-=-=
 
 Name: backward-sexp moves over tables
@@ -601,3 +601,53 @@ end|
     end
 end
 =-=-=
+
+Name: backward-sexp moves over do statements
+
+=-=
+do
+  print(a + 1)
+end|
+=-=
+|do
+  print(a + 1)
+end
+=-=-=
+
+Name: backward-sexp moves over for statements
+
+=-=
+for k,v in pairs({}) do
+  print(k, v)
+end|
+=-=
+|for k,v in pairs({}) do
+  print(k, v)
+end
+=-=-=
+
+Name: backward-sexp moves over repeat statements
+
+=-=
+repeat
+  n = n + 1
+until n > 10|
+=-=
+|repeat
+  n = n + 1
+until n > 10
+=-=-=
+
+Name: backward-sexp moves over while statements
+
+=-=
+while n < 99
+do
+  n = n+1
+end|
+=-=
+|while n < 99
+do
+  n = n+1
+end
+=-=-=
-- 
2.48.1

[email-masked] writes:

> Tags: patch
>
> This removes some entities from treesit-thing-settings that don’t
> make sense to consider as s-expressions (probably leftovers from
> debugging or something) and didn’t have tests. It also adds tests
> for some backward-sexp cases that were missing them.
>
> Should apply cleanly to emacs-30 or master.