unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Danny Freeman <danny@dfreeman.email>
To: emacs-devel <emacs-devel@gnu.org>
Cc: Yuan Fu <casouri@gmail.com>
Subject: Treesit Regression In ec4d29c4494f32acf0ff7c5632a1d951d957f084
Date: Sat, 09 Sep 2023 15:26:03 -0400	[thread overview]
Message-ID: <87r0n7dt34.fsf@dfreeman.email> (raw)

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



             reply	other threads:[~2023-09-09 19:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-09 19:26 Danny Freeman [this message]
2023-09-10  1:15 ` Treesit Regression In ec4d29c4494f32acf0ff7c5632a1d951d957f084 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r0n7dt34.fsf@dfreeman.email \
    --to=danny@dfreeman.email \
    --cc=casouri@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).