unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Treesit Regression In ec4d29c4494f32acf0ff7c5632a1d951d957f084
@ 2023-09-09 19:26 Danny Freeman
  2023-09-10  1:15 ` Yuan Fu
  0 siblings, 1 reply; 8+ messages in thread
From: Danny Freeman @ 2023-09-09 19:26 UTC (permalink / raw)
  To: emacs-devel; +Cc: Yuan Fu

Hello,

I believe I have found a regression in the treesit package introduced by
commit ec4d29c4494f32acf0ff7c5632a1d951d957f084

I noticed that indentation does not work properly on Emacs master branch
in clojure-ts-mode. After doing a git bisect on Emacs source code I
landed on the above commit.



To reproduce, I build emacs with ec4d29c44 [0][1] and load up
clojure-ts-mode from the current main branch (commit 58f3c835 [2]).

I open up a new file, say test.clj, and run `M-x clojure-ts-mode`.

In that file I can paste the following contents

(defn foo [] 1)

The buffer should have the following tree structure, which can be seen
with M-x treesit-explore-mode <RET> clojure <RET>

(source
 (list_lit close: (
  (sym_lit name: (sym_name))
  (sym_lit (sym_name))
  (vec_lit [ ])
  (num_lit) )))

If I place my cursor directly before the 1 character like so, where | is
my cursor

(defn foo [] |1)

and then press <RET>, I would expect the following indentation

(defn foo []
  |1)

Instead I get

(defn foo []
|1)

and if `treesit--indent-verbose` is set to `t` then I see these messages
in *Messages*

  Matched rule: ((parent-is "source") parent-bol 0)
  PARENT is nil, not indenting

Before this change I would see

  Matched rule: ((parent-is "source") parent-bol 0)
  Matched rule: (clojure-ts--match-expression-in-body parent 2)

While my cursor is before the 1 character, running

M-x eval-expression <RET> (treesit-node-parent (treesit-node-at (point)))

will return nil. Before this change, it would return the parent list_lit
node as I would expect.


Please let me know if you have any question, or if there is something I
can do to make this easier to test. I see the commit the git bisect
pointed me to contains changes to the C code for treesit. I do not know
C well enough to know why this breaks, unfortunately. I can only say
something is not quite right.

[0] - the configure flags I use to build emacs
https://git.sr.ht/~dannyfreeman/emacs/tree/ba4a5f3678bf83a28ce382fc33611e0d7aed2a86/item/flake.nix#L63-81
[1] - The init file I use
https://git.sr.ht/~dannyfreeman/emacs/tree/main/item/init/init.el
[2] - clojure-ts-mode version used to reproduce this error:
https://github.com/clojure-emacs/clojure-ts-mode/commit/58f3c835aeafe0378ab9693731b95096827dbb24

Thank you,
-- 
Danny Freeman



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-09-12  3:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-09 19:26 Treesit Regression In ec4d29c4494f32acf0ff7c5632a1d951d957f084 Danny Freeman
2023-09-10  1:15 ` Yuan Fu
2023-09-10  4:00   ` Danny Freeman
2023-09-10  5:26     ` Yuan Fu
2023-09-10  7:12       ` Yuan Fu
2023-09-11 12:41         ` Danny Freeman
2023-09-11 22:19           ` Yuan Fu
2023-09-12  3:49             ` Danny Freeman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).