From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Danny Freeman Newsgroups: gmane.emacs.devel Subject: Treesit Regression In ec4d29c4494f32acf0ff7c5632a1d951d957f084 Date: Sat, 09 Sep 2023 15:26:03 -0400 Message-ID: <87r0n7dt34.fsf@dfreeman.email> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12138"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Yuan Fu To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Sep 09 21:51:36 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qf3zT-0002zC-Qi for ged-emacs-devel@m.gmane-mx.org; Sat, 09 Sep 2023 21:51:36 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qf3yc-0007kt-TH; Sat, 09 Sep 2023 15:50:42 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qf3yb-0007kb-0Q for emacs-devel@gnu.org; Sat, 09 Sep 2023 15:50:41 -0400 Original-Received: from out-216.mta1.migadu.com ([95.215.58.216]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qf3yY-0005iD-0s for emacs-devel@gnu.org; Sat, 09 Sep 2023 15:50:40 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dfreeman.email; s=key1; t=1694289028; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=JFzEezSFt/Ql2cjqqS6pzSZxXfg/STzDRpwNlSjLK+g=; b=ck3uIEC4EP/yoUnNhsllfSRws5favuAZqZ/6g1KSbKwZGqRqy9utD5woPgfusf5FBG+QYm QRRvj3B1YIwU+BHatx53EQaEJ3nvSKnBKXJNg2Vi0m0AB3+vete/RVrGG3gNdgToQ0x215 lxVE7e20LhcQ1ACz48035qr81z/utYk= X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=95.215.58.216; envelope-from=danny@dfreeman.email; helo=out-216.mta1.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:310421 Archived-At: 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 clojure (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 , 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 (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