From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Treesit Regression In ec4d29c4494f32acf0ff7c5632a1d951d957f084 Date: Sat, 9 Sep 2023 18:15:59 -0700 Message-ID: <68CFCC60-F71F-41E3-AF2A-E78E00EB3FD2@gmail.com> References: <87r0n7dt34.fsf@dfreeman.email> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35587"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel To: Danny Freeman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Sep 10 03:17:32 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 1qf94s-00093p-PU for ged-emacs-devel@m.gmane-mx.org; Sun, 10 Sep 2023 03:17:30 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qf93v-0005Dk-HE; Sat, 09 Sep 2023 21:16:31 -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 1qf93t-0005DN-HJ for emacs-devel@gnu.org; Sat, 09 Sep 2023 21:16:29 -0400 Original-Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qf93d-0002Bw-Cb for emacs-devel@gnu.org; Sat, 09 Sep 2023 21:16:28 -0400 Original-Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-6bee392fe9dso2279199a34.1 for ; Sat, 09 Sep 2023 18:16:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694308571; x=1694913371; darn=gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+YPciNNv6LxsXVe79bLWOF2M3Xu0v05fnyN11FJLp3I=; b=IZ6wJhQ7Bb4ulvtT98i2b5wMu3yBQ0Unu0MJgg7CFasWAoNba8Id+r4kNekH2XjLlA D/DgC902kj9UoOdiYH8CctMT0KntCes4I+g4prWNJcL/1XDDOaC+s399iKPrZwDPbzao zxuilchUD1JDxekWraFtO3/5CjkF/u1r1wqBbuvS/oyHhgoVF/dta0BNNpJ2MhwUdgkW ADNrDwcs3wnq8MmQaseVz5P04DivQmJ/fNCdjrY/1V7MTPNrC9GNtQ+iUymZRcujLYhA ez55qougLTbqaqs51uSOwb6BwB6zdwnAwyq9CeyUuV+axvpb+XjywLXX8l1veNXloBe1 ameA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694308571; x=1694913371; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+YPciNNv6LxsXVe79bLWOF2M3Xu0v05fnyN11FJLp3I=; b=PSWzPJQ/L7QwL0Qu1LncSrKioshMyOUrDxpCqbyq96rFvX0zI2MZ2cEN1qUR1rBCCX 5xHOzad7yhRHPUkRtWlcJq5pBk3ZiT/Wka2xuffy3X8Wuoibq8XFlYwJWEfIPVpJwRLC Xh3KhC0B9S5/7REwThvrJCNhDHnTGx8TO8eHgmzTnSg7Qk1H115GugQC6FBGH+N5j8FX YaJ0COr/PjgyP33iZJZDm2EBFzYGTAxTnXGThjRSi2BkbucEJJpfm7nBRcChPSjBQF2d ml57oDlYNoQm7xr2WQ43vzdyofPaEIZS5oY5IIKJK2ub6OuMHXKuyBG+W3WQKXdq7Mco JZmw== X-Gm-Message-State: AOJu0YxDlgxKOPP0294bHCQ6ofI1g/1pYxoJcxqbmK4FbmI8uXvNwO6m tL2Sl2Pgz7vS9vHcB7P0Zt01+M17SEw= X-Google-Smtp-Source: AGHT+IFx4f15VSjpHwaH4H/j3DVYwwHxwadRrR+WR73tqazgtL7TQ8XiFHILUqLFUbJnoJP0ZBSFjA== X-Received: by 2002:a9d:6644:0:b0:6b7:518a:1672 with SMTP id q4-20020a9d6644000000b006b7518a1672mr7247409otm.34.1694308571181; Sat, 09 Sep 2023 18:16:11 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id z18-20020a056a001d9200b0068fbaea118esm97124pfw.45.2023.09.09.18.16.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Sep 2023 18:16:10 -0700 (PDT) In-Reply-To: <87r0n7dt34.fsf@dfreeman.email> X-Mailer: Apple Mail (2.3731.700.6) Received-SPF: pass client-ip=2607:f8b0:4864:20::32a; envelope-from=casouri@gmail.com; helo=mail-ot1-x32a.google.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, FREEMAIL_FROM=0.001, 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:310428 Archived-At: > On Sep 9, 2023, at 12:26 PM, Danny Freeman = wrote: >=20 > Hello, >=20 > I believe I have found a regression in the treesit package introduced = by > commit ec4d29c4494f32acf0ff7c5632a1d951d957f084 >=20 > 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. >=20 >=20 >=20 > To reproduce, I build emacs with ec4d29c44 [0][1] and load up > clojure-ts-mode from the current main branch (commit 58f3c835 [2]). >=20 > I open up a new file, say test.clj, and run `M-x clojure-ts-mode`. >=20 > In that file I can paste the following contents >=20 > (defn foo [] 1) >=20 > The buffer should have the following tree structure, which can be seen > with M-x treesit-explore-mode clojure >=20 > (source > (list_lit close: ( > (sym_lit name: (sym_name)) > (sym_lit (sym_name)) > (vec_lit [ ]) > (num_lit) ))) >=20 > If I place my cursor directly before the 1 character like so, where | = is > my cursor >=20 > (defn foo [] |1) >=20 > and then press , I would expect the following indentation >=20 > (defn foo [] > |1) >=20 > Instead I get >=20 > (defn foo [] > |1) >=20 > and if `treesit--indent-verbose` is set to `t` then I see these = messages > in *Messages* >=20 > Matched rule: ((parent-is "source") parent-bol 0) > PARENT is nil, not indenting >=20 > Before this change I would see >=20 > Matched rule: ((parent-is "source") parent-bol 0) > Matched rule: (clojure-ts--match-expression-in-body parent 2) >=20 > While my cursor is before the 1 character, running >=20 > M-x eval-expression (treesit-node-parent (treesit-node-at = (point))) >=20 > will return nil. Before this change, it would return the parent = list_lit > node as I would expect. >=20 >=20 > 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. >=20 > [0] - the configure flags I use to build emacs > = https://git.sr.ht/~dannyfreeman/emacs/tree/ba4a5f3678bf83a28ce382fc33611e0= d7aed2a86/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/58f3c835aeafe0378a= b9693731b95096827dbb24 >=20 > Thank you, > --=20 > Danny Freeman Hmmm, I can=E2=80=99t reproduce this. I=E2=80=99m getting Matched rule: ((parent-is "source") parent-bol 0) Matched rule: (clojure-ts--match-expression-in-body parent 2) The commit you pointed to does change treesit-node-parent, so it does = match with parent-is matcher not working. Might be because I recently upgraded to a newer tree-sitter library. If = you compile with the newest tree-sitter build (from their repo), do you = still see this problem? Yuan=