aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorYuan Fu2025-01-30 16:54:20 -0800
committerYuan Fu2025-01-30 21:34:31 -0800
commitef28af35bb4c43d71fe4c10d02fe93f30e830c5e (patch)
treecec88fd7cadeee6b83d2a93994e49835632a8433 /test/src
parenta5965217fc1d7b56df60f8e798edd48ae52c8624 (diff)
downloademacs-ef28af35bb4c43d71fe4c10d02fe93f30e830c5e.tar.gz
emacs-ef28af35bb4c43d71fe4c10d02fe93f30e830c5e.zip
Add treesit-add-simple-indent-rules
* lisp/treesit.el: (treesit-add-simple-indent-rules): New function. * etc/NEWS: Update NEWS. * test/src/treesit-tests.el: (treesit-test-add-simple-indent-rules): Add a test for the new function.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/treesit-tests.el21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/src/treesit-tests.el b/test/src/treesit-tests.el
index f9c64f792d1..22f53243274 100644
--- a/test/src/treesit-tests.el
+++ b/test/src/treesit-tests.el
@@ -411,6 +411,27 @@ BODY is the test body."
411 (let ((missing-bracket (treesit-node-child array -1))) 411 (let ((missing-bracket (treesit-node-child array -1)))
412 (treesit-search-forward missing-bracket "" t)))) 412 (treesit-search-forward missing-bracket "" t))))
413 413
414;;; Indent
415
416(ert-deftest treesit-test-add-simple-indent-rules ()
417 "Test `treesit-add-simple-indent-rules'."
418 (let ((treesit-simple-indent-rules
419 (copy-tree '((c (a a a) (b b b) (c c c))))))
420 (treesit-add-simple-indent-rules 'c '((d d d)))
421 (should (equal treesit-simple-indent-rules
422 '((c (d d d) (a a a) (b b b) (c c c)))))
423 (treesit-add-simple-indent-rules 'c '((e e e)) :after)
424 (should (equal treesit-simple-indent-rules
425 '((c (d d d) (a a a) (b b b) (c c c) (e e e)))))
426 (treesit-add-simple-indent-rules 'c '((f f f)) :after '(b b b))
427 (should (equal treesit-simple-indent-rules
428 '((c (d d d) (a a a) (b b b) (f f f)
429 (c c c) (e e e)))))
430 (treesit-add-simple-indent-rules 'c '((g g g)) :before '(b b b))
431 (should (equal treesit-simple-indent-rules
432 '((c (d d d) (a a a) (g g g)
433 (b b b) (f f f) (c c c) (e e e)))))))
434
414;;; Query 435;;; Query
415 436
416(defun treesit--ert-pred-last-sibling (node) 437(defun treesit--ert-pred-last-sibling (node)