From unknown Fri Sep 05 16:40:34 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#66431 <66431@debbugs.gnu.org> To: bug#66431 <66431@debbugs.gnu.org> Subject: Status: [PATCH] Fix reset treesit--explorer-last-node when explorer buffer was killed Reply-To: bug#66431 <66431@debbugs.gnu.org> Date: Fri, 05 Sep 2025 23:40:34 +0000 retitle 66431 [PATCH] Fix reset treesit--explorer-last-node when explorer b= uffer was killed reassign 66431 emacs submitter 66431 nvp severity 66431 normal tag 66431 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Oct 10 02:03:52 2023 Received: (at submit) by debbugs.gnu.org; 10 Oct 2023 06:03:52 +0000 Received: from localhost ([127.0.0.1]:33833 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qq5qR-0006Ew-VC for submit@debbugs.gnu.org; Tue, 10 Oct 2023 02:03:52 -0400 Received: from lists.gnu.org ([2001:470:142::17]:53520) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qq5qN-0006Ef-NK for submit@debbugs.gnu.org; Tue, 10 Oct 2023 02:03:49 -0400 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 1qq5px-0001Nz-4E for bug-gnu-emacs@gnu.org; Tue, 10 Oct 2023 02:03:21 -0400 Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qq5pd-0004b5-C0 for bug-gnu-emacs@gnu.org; Tue, 10 Oct 2023 02:03:17 -0400 Received: by mail-ot1-x330.google.com with SMTP id 46e09a7af769-6c0b8f42409so3638966a34.0 for ; Mon, 09 Oct 2023 23:03:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696917779; x=1697522579; darn=gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=NE5mT8SpCb3XS2f1MaUiu3w3F+JEVxC9drOHRiiGe74=; b=jF720ANLV/m8D6KBiRVHGV7kaVvkTipiX5xC5jPCNSL/zmMyGd7/2ikTs0ZTBmgz+w snqJ1D1azKarlNd6MD0+sYUGHD5WyMjbZKTKeq84qtSxQBfpzPc0mQbcCBMZQuf8BHpz Lq8b9VqFCG/NIDNo0N98/ArrDqFPQvBOI4znuGjYTkpHtXp1q/kDq3/KSfMafUWT8p3B QiiRGdTtaTPDqKA6jUF+slQEj4o5Zm+YUHFGYCI7YvffI+KHrxi/4terQjO9PRsh3sEG w7s28f8djB227y6FNdnmz/KQizaYJ9juBrj2nV8jpB2NMQU7Y8RzRqhMbmCWeD0i4df6 zHmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696917779; x=1697522579; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=NE5mT8SpCb3XS2f1MaUiu3w3F+JEVxC9drOHRiiGe74=; b=AGNfftUO9R+wi2vBY3eyBWyALb9Q0kqUhsqbhB5Vy+yU468z/4n7hQdgzGpTBcpN3c Xn92IUtSwC20sYY7GWEwtQG/Ad+gekfuYqCK9wMJfXjk9LLPnqTp2Gkr2NyybpmMMHrZ 3UnSH83Y5bzEeVQgRpsRbiIZmlYep12K7Nm0oz/x9z3EhrfMxTgActWamUaxxCnZQmd9 NEXMFL/hoGQeDIEA4CHGcV7WuVWJ5VsAxL2sQ3WAgQpwthWuWq3OVwEva7IavH6hU3eG +d/iH4tPOc9kuryJmdnSHQEfWMjAXxFbKlOn+Km6bmKI1Fw26rc2zv8sH4FKO2/wxqo/ CmOg== X-Gm-Message-State: AOJu0YzO7rLgGTQxfdh66DJZO40tVwLoJcNOPnwxWlT2QNOjNoGM/E0Y sndINSHOrdGRopJ6cyFQWlrgMJ0PYhe+T9HoXZYK7UL4LeMzd/Id X-Google-Smtp-Source: AGHT+IFWS/MNm6N9W8BFtOMAR3bH1jTnRLqnCEDQriBvwf7vsqPPQYSi4+oPRVrlxOJdgiK6o+Bmu/Mz7Fg5oUwLWtE= X-Received: by 2002:a05:6871:ae81:b0:1e9:732e:d6ba with SMTP id zs1-20020a056871ae8100b001e9732ed6bamr81225oab.15.1696917779253; Mon, 09 Oct 2023 23:02:59 -0700 (PDT) MIME-Version: 1.0 From: nvp Date: Mon, 9 Oct 2023 23:02:48 -0700 Message-ID: Subject: [PATCH] Fix reset treesit--explorer-last-node when explorer buffer was killed To: bug-gnu-emacs@gnu.org Content-Type: multipart/mixed; boundary="0000000000007220cf06075675ae" Received-SPF: pass client-ip=2607:f8b0:4864:20::330; envelope-from=noah.v.peart@gmail.com; helo=mail-ot1-x330.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, HTML_MESSAGE=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --0000000000007220cf06075675ae Content-Type: multipart/alternative; boundary="0000000000007220cd06075675ac" --0000000000007220cd06075675ac Content-Type: text/plain; charset="UTF-8" Tags: patch Bug: After `treesit-explorer-mode` is enabled in a buffer and its associated `treesit--explorer-buffer` is killed, a subsequent call to `treesit-explorer-mode` initially displays an empty explorer buffer b/c `treesit--explorer-refresh` sees old value for `treesit--explorer-last-node`. * lisp/treesit.el (treesit-explorer-mode): reset `treesit--explorer-last-node` when `treesit--explorer-buffer` was killed In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0) of 2023-10-05 built on noah-X580VD Repository revision: 505c80623049d9e181918acdac8229c9a2041b1e Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101004 System Description: Ubuntu 22.04.3 LTS Configured using: 'configure --prefix=/usr/local --with-modules --with-tree-sitter --with-threads --with-x-toolkit=gtk3 --with-xwidgets --with-gnutls --with-json --with-mailutils --with-jpeg --with-png --with-rsvg --with-tiff --with-xml2 --with-xpm --with-imagemagick CC=gcc-12 CXX=gcc-12' --0000000000007220cd06075675ac Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Tags: patch


Bug: After `treesit-explorer-m= ode` is enabled in a buffer and its
associated `treesit--explorer-buffer= ` is killed, a subsequent call
to `treesit-explorer-mode` initially disp= lays an empty explorer
buffer b/c `treesit--explorer-refresh` sees old v= alue for
`treesit--explorer-last-node`.

* lisp/treesit.el (treesi= t-explorer-mode): reset
`treesit--explorer-last-node` when `treesit--exp= lorer-buffer` was killed

In GNU Emacs 30.0.50 (build 1, x86_64-pc-li= nux-gnu, GTK+ Version
3.24.33, cairo version 1.16.0) of 2023-10-05 built= on noah-X580VD
Repository revision: 505c80623049d9e181918acdac8229c9a20= 41b1e
Repository branch: master
Windowing system distributor 'The= X.Org Foundation', version 11.0.12101004
System Description: Ubuntu= 22.04.3 LTS

Configured using:
=C2=A0'configure --prefix=3D/u= sr/local --with-modules --with-tree-sitter
--with-threads --with-x-toolk= it=3Dgtk3 --with-xwidgets --with-gnutls
--with-json --with-mailutils --w= ith-jpeg --with-png --with-rsvg
--with-tiff --with-xml2 --with-xpm --wit= h-imagemagick CC=3Dgcc-12
CXX=3Dgcc-12'

--0000000000007220cd06075675ac-- --0000000000007220cf06075675ae Content-Type: text/x-patch; charset="US-ASCII"; name="fix-treesit-explorer-last-node.patch" Content-Disposition: attachment; filename="fix-treesit-explorer-last-node.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lnjwzeur0 RnJvbSBmMGQ0MjAxMzNiNThkMDUwNjE3M2YyZjE1Mzk4NjdiMmQ5ZTdmMDE0IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBudmVybm8gPG5vYWgudi5wZWFydEBnbWFpbC5jb20+CkRhdGU6 IE1vbiwgOSBPY3QgMjAyMyAyMjo1MjozOCAtMDcwMApTdWJqZWN0OiBbUEFUQ0hdIEZpeCByZXNl dCB0cmVlc2l0LS1leHBsb3Jlci1sYXN0LW5vZGUKCi0tLQogbGlzcC90cmVlc2l0LmVsIHwgMSAr CiAxIGZpbGUgY2hhbmdlZCwgMSBpbnNlcnRpb24oKykKCmRpZmYgLS1naXQgYS9saXNwL3RyZWVz aXQuZWwgYi9saXNwL3RyZWVzaXQuZWwKaW5kZXggNDAyNDE3YzZjYTkuLmU3OThhYmFjMDc5IDEw MDY0NAotLS0gYS9saXNwL3RyZWVzaXQuZWwKKysrIGIvbGlzcC90cmVlc2l0LmVsCkBAIC0zMTky LDYgKzMxOTIsNyBAQCB0cmVlc2l0LWV4cGxvcmUtbW9kZQogICAgICAgICAgICAgICAgICAgICAg ICAgIChmb3JtYXQgIip0cmVlLXNpdHRlciBleHBsb3JlciBmb3IgJXMqIgogICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgKGJ1ZmZlci1uYW1lKSkpKQogICAgICAgICAgICAgKHNldHEt bG9jYWwgdHJlZXNpdC0tZXhwbG9yZXItbGFuZ3VhZ2UgbGFuZ3VhZ2UpCisgICAgICAgICAgICAo c2V0cS1sb2NhbCB0cmVlc2l0LS1leHBsb3Jlci1sYXN0LW5vZGUgbmlsKQogICAgICAgICAgICAg KHdpdGgtY3VycmVudC1idWZmZXIgdHJlZXNpdC0tZXhwbG9yZXItYnVmZmVyCiAgICAgICAgICAg ICAgICh0cmVlc2l0LS1leHBsb3Jlci10cmVlLW1vZGUpKSkKICAgICAgICAgICAoZGlzcGxheS1i dWZmZXIgdHJlZXNpdC0tZXhwbG9yZXItYnVmZmVyCi0tIAoyLjM0LjEKCg== --0000000000007220cf06075675ae-- From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 14 04:18:13 2023 Received: (at 66431) by debbugs.gnu.org; 14 Oct 2023 08:18:13 +0000 Received: from localhost ([127.0.0.1]:47829 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qrZqf-0006iS-I3 for submit@debbugs.gnu.org; Sat, 14 Oct 2023 04:18:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38232) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qrZqd-0006iD-On for 66431@debbugs.gnu.org; Sat, 14 Oct 2023 04:18:12 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qrZqA-0003I1-UQ; Sat, 14 Oct 2023 04:17:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=kJ9ec5YVbplTugcU+c5PM9EXZa7U37Rz6Ni7FfXQtSI=; b=q+EIhPKYD9Nu cbbbobWKX5qYA4a9bxa2EVVkZ9idLuCZ4clZS0ltQC+n2UD8+UUEQbQMthK/+AwuT3uAZ3wEnVLEF eUXkuvsngEdeEK2h66I5+xEP6N1Hj1bgTm7hf7dtEoOPxnR/xr/3qeurtv4g+YLxuSbHkD7Ytf8UZ zCydtuztiqPbbWGepKHsTTPPU/ZubOwMhE+7UYFARwo8J3a/iqEGQUIB9Y+I9kjMeh0g67kur4Kbm ML7KP4AbYC8Yhwz0c5SLQA5SQ1K5DqStzJHOLGSMuHPrL8I16+P0QQN6ddmSJ7CwdykmTCeVHd4Qo 5tp5D1Y6j6tstBH9hmuhyg==; Date: Sat, 14 Oct 2023 11:17:42 +0300 Message-Id: <83a5slsjmh.fsf@gnu.org> From: Eli Zaretskii To: nvp , Yuan Fu In-Reply-To: (message from nvp on Mon, 9 Oct 2023 23:02:48 -0700) Subject: Re: bug#66431: [PATCH] Fix reset treesit--explorer-last-node when explorer buffer was killed References: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 66431 Cc: 66431@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: nvp > Date: Mon, 9 Oct 2023 23:02:48 -0700 > > Tags: patch > > Bug: After `treesit-explorer-mode` is enabled in a buffer and its > associated `treesit--explorer-buffer` is killed, a subsequent call > to `treesit-explorer-mode` initially displays an empty explorer > buffer b/c `treesit--explorer-refresh` sees old value for > `treesit--explorer-last-node`. > > * lisp/treesit.el (treesit-explorer-mode): reset > `treesit--explorer-last-node` when `treesit--explorer-buffer` was killed > > In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version > 3.24.33, cairo version 1.16.0) of 2023-10-05 built on noah-X580VD > Repository revision: 505c80623049d9e181918acdac8229c9a2041b1e > Repository branch: master > Windowing system distributor 'The X.Org Foundation', version 11.0.12101004 > System Description: Ubuntu 22.04.3 LTS Yuan, could you please look into this? Is the patch OK to go in, and if so, should it be installed on emacs-29? From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 14 13:08:54 2023 Received: (at 66431) by debbugs.gnu.org; 14 Oct 2023 17:08:54 +0000 Received: from localhost ([127.0.0.1]:50337 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qri8E-0002do-1k for submit@debbugs.gnu.org; Sat, 14 Oct 2023 13:08:54 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]:60660) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qri8A-0002dW-DT for 66431@debbugs.gnu.org; Sat, 14 Oct 2023 13:08:53 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6b6f4c118b7so954843b3a.0 for <66431@debbugs.gnu.org>; Sat, 14 Oct 2023 10:08:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697303301; x=1697908101; darn=debbugs.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=GvKPropiW1ou3lVays5dJUCwU4Nl1ftb8skQA04p6Xc=; b=BY+JHqeWWsDRCpcqItlsgAtcADK3uJV08W74RObzsnmmTbHspBKqKPMugpdXW4fNLd /Z0YWg4DSd+A4e14NRc3J0JwkIAU/FFPtBV4E2NBag8rVB4tEoY5yA/YV18RbqeRQDsG 3Nsbw05x6A5QUcp6GSJRMWyoYVQVJCWrZ+5dUC+7ouukyWx24AoclLlBJYSEL/3JlKiz 4psIF4IiiPyqcq27XPyEq4RYO3c56qug53K7qI9uSvNPsPXgC72B1mHRvNPgonQnxuaA mmOyGoyYb1ihD+YXmug2+azP6ep3eL7Eq4nEjDWkBbSfjon/9QJhzK7SsUfGEMElGvyO osmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697303301; x=1697908101; 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=GvKPropiW1ou3lVays5dJUCwU4Nl1ftb8skQA04p6Xc=; b=tVcluNNcxwGJATTIWfCbtE6pz2MEyZnFVRBJC6ThMFgIpfi5OzmYFyyFTvC09NKHw6 m5kKN0PUVHHrHVr96I3s3z4S3UGnRGgT9CmsmLc7XGVqYloqsA6yI0op1pnnt3xFp3IO 8os9YoWnvDcBqyabqICFCwtRKs6ThT87fzAyZPWOmazrhIghZtCjOkTZ3NsOAfMJhHL5 hGvkwv6c2vG6NYkcP47RGdyT0DOXU2vkID90NNXvDNO0IkS+2ufYCG+NC0R1kOxz+dFY dpTXoP6XMhVr4YleitflkDpCgtZWU42vl5WaCThNi40DzCvpsj+vO8F5pzsgmld4gn6P wl6g== X-Gm-Message-State: AOJu0YwYnzv/aCpTVf1iTyXM8mJt/UjdQNt3emwhcdLrR3lQ9+0S2mUs Jp9bKhdCw7iLSC0I7t8gH8g= X-Google-Smtp-Source: AGHT+IFWBBQpojym8Lp2uVqTg5B5UT9JyvpQbSFM/WkK7MJ5OHHStPGIwU/IOFiQgMZBAny8I15zYg== X-Received: by 2002:a05:6a00:1409:b0:68f:dd50:aef8 with SMTP id l9-20020a056a00140900b0068fdd50aef8mr30697041pfu.4.1697303300629; Sat, 14 Oct 2023 10:08:20 -0700 (PDT) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id x24-20020aa79ad8000000b006b341144ad0sm2979319pfp.102.2023.10.14.10.08.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 Oct 2023 10:08:20 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Subject: Re: bug#66431: [PATCH] Fix reset treesit--explorer-last-node when explorer buffer was killed From: Yuan Fu In-Reply-To: Date: Sat, 14 Oct 2023 10:08:09 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <25E47103-A348-4F93-8968-67D84F06B35D@gmail.com> References: To: nvp X-Mailer: Apple Mail (2.3731.700.6) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 66431 Cc: 66431@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On Oct 9, 2023, at 11:02 PM, nvp wrote: >=20 > Tags: patch >=20 >=20 > Bug: After `treesit-explorer-mode` is enabled in a buffer and its > associated `treesit--explorer-buffer` is killed, a subsequent call > to `treesit-explorer-mode` initially displays an empty explorer > buffer b/c `treesit--explorer-refresh` sees old value for > `treesit--explorer-last-node`. >=20 > * lisp/treesit.el (treesit-explorer-mode): reset > `treesit--explorer-last-node` when `treesit--explorer-buffer` was = killed Hmm, I can=E2=80=99t reproduce what you described. Besides, = treesit--explorer-last-node is only set in the source buffer, not the = explorer buffer. But the patch tries to reset it for the explorer = buffer. Also treesit--explorer-last-node is reset at the end of = treesit-explore-mode. We can start from reliably reproducing the bug you are seeing, and see = what=E2=80=99s the true cause of it. Yuan= From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 14 13:09:26 2023 Received: (at 66431) by debbugs.gnu.org; 14 Oct 2023 17:09:26 +0000 Received: from localhost ([127.0.0.1]:50341 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qri8k-0002ew-Di for submit@debbugs.gnu.org; Sat, 14 Oct 2023 13:09:26 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:45118) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qri8g-0002eh-90 for 66431@debbugs.gnu.org; Sat, 14 Oct 2023 13:09:25 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-694ed847889so2554600b3a.2 for <66431@debbugs.gnu.org>; Sat, 14 Oct 2023 10:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697303333; x=1697908133; darn=debbugs.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=RnOIvrosil521qqtCa9rmbowYTFH3IAvKZv3nfxq35E=; b=BUZu85r8BnjnoC4U/O1/PJ+a6FbfY0jlnDce9HUnXR3xIoiO1VUjJW02CX7f7EKpae gR1OiBI3GmSBY5q2aCWIBKGOfFBz7ThlrAzbGatqeTriv25mFXiu6g2qBwJ7uytfq5AK 8tvSDqykLK0Ih3EHdA+ws57iKu5UXCg35we6hbn6QTPrWHg/m/Fi6jKWsi6BCpRzo5Lb 3duj4vXvvqEZ67VXVmkEMsW60XR2QPwunQL4tUnr0SgFbE3wm03khLPeNbT0IR5rcMEv CstWLZXiJGjkvZz6k/1l7s0ZUNtJQfSXY9e1Os6vGyReHGpm+HVbaa/g8v+gfgTKA3tK iE8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697303333; x=1697908133; 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=RnOIvrosil521qqtCa9rmbowYTFH3IAvKZv3nfxq35E=; b=KYgHhl6vS+X1tNOBpLlUZKKGT7d658wARxV6vvZZESbcPq2Qw3+IWcAZ0UrXoI342G G27rLMu1HHwDT0D/rNp9aPu1qRDkH6tFOAAcJ25VJjcwPqol8hJ0yHuvOyEIgYIR4f6a 1wR5Z/9jnUtf39NXHUKxuy20B/kLw9r1ERAoBCbBsgeADUlm6g0DvePSavDl0RvvsFyd nS+rVhOPJAsGCdB5lRNSoH40EWmBrdpCDgb6ujraGL+5JFRAOaFn/ZnvK65PAw/xF19C QPmlTgHZoySMQQSoMxwKarbkc5aPiUU0P9X5Sv+GoELqgJHkLbOGZSYbzO4ayf+ScV+H DUWw== X-Gm-Message-State: AOJu0YxROanF6FhdzJ6Av8CGRztWkmNPO6tIQecNle2VheT9/REP8D5i dxTEaQVcPWPjNLkYf2lJblk= X-Google-Smtp-Source: AGHT+IEf6IxX/YM4GLys1HMJ89M3m2FOtev5yZ6OSut+e1TpUUJ9L6qxk5jMyQBdHiYbrBk7GyDk4A== X-Received: by 2002:a05:6a00:18a3:b0:6bc:c242:7915 with SMTP id x35-20020a056a0018a300b006bcc2427915mr1126938pfh.28.1697303332749; Sat, 14 Oct 2023 10:08:52 -0700 (PDT) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id x24-20020aa79ad8000000b006b341144ad0sm2979319pfp.102.2023.10.14.10.08.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 Oct 2023 10:08:52 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Subject: Re: bug#66431: [PATCH] Fix reset treesit--explorer-last-node when explorer buffer was killed From: Yuan Fu In-Reply-To: <83a5slsjmh.fsf@gnu.org> Date: Sat, 14 Oct 2023 10:08:41 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <76FD5982-60CC-48D2-9823-C235CCEC2EEC@gmail.com> References: <83a5slsjmh.fsf@gnu.org> To: Eli Zaretskii X-Mailer: Apple Mail (2.3731.700.6) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 66431 Cc: nvp , 66431@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On Oct 14, 2023, at 1:17 AM, Eli Zaretskii wrote: >=20 >> From: nvp >> Date: Mon, 9 Oct 2023 23:02:48 -0700 >>=20 >> Tags: patch >>=20 >> Bug: After `treesit-explorer-mode` is enabled in a buffer and its >> associated `treesit--explorer-buffer` is killed, a subsequent call >> to `treesit-explorer-mode` initially displays an empty explorer >> buffer b/c `treesit--explorer-refresh` sees old value for >> `treesit--explorer-last-node`. >>=20 >> * lisp/treesit.el (treesit-explorer-mode): reset >> `treesit--explorer-last-node` when `treesit--explorer-buffer` was = killed >>=20 >> In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version >> 3.24.33, cairo version 1.16.0) of 2023-10-05 built on noah-X580VD >> Repository revision: 505c80623049d9e181918acdac8229c9a2041b1e >> Repository branch: master >> Windowing system distributor 'The X.Org Foundation', version = 11.0.12101004 >> System Description: Ubuntu 22.04.3 LTS >=20 > Yuan, could you please look into this? Is the patch OK to go in, and > if so, should it be installed on emacs-29? I=E2=80=99ll look at it, thanks for the reminder. Yuan From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 15 00:21:18 2023 Received: (at 66431) by debbugs.gnu.org; 15 Oct 2023 04:21:18 +0000 Received: from localhost ([127.0.0.1]:51063 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qrscv-0002Mz-IB for submit@debbugs.gnu.org; Sun, 15 Oct 2023 00:21:18 -0400 Received: from mail-oo1-xc35.google.com ([2607:f8b0:4864:20::c35]:46212) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qrsct-0002Mj-7G for 66431@debbugs.gnu.org; Sun, 15 Oct 2023 00:21:16 -0400 Received: by mail-oo1-xc35.google.com with SMTP id 006d021491bc7-57f02eeabcaso2131095eaf.0 for <66431@debbugs.gnu.org>; Sat, 14 Oct 2023 21:20:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697343645; x=1697948445; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=WMRHIxH0U6Hod3RQadnN4A/vcEgfdZ+o5NdSCEKHT2E=; b=HuOU0T8xr+TjI5s2hG6mjLNzdl42wm9PyiDWuOj5DuSMzTE8J2Py9TpAvNV7pg+Dqp TmDPX6OM+Bfzowvk0e7jOOXihUuc+H9ttp5v6nL5vz8exctYnTcPDLE6Dmm67fuOcAsL zNGloRfFVngGg3kDcSUrEcV5OkY3P5PeVbwZkz7VQ75w1mP3yN7VlA/lshoJ7Q2g+nyJ BlXsHkejjdZkE/+tQCabISiGJiCNbvEJRPNvr/O59HCPJ9nic7g5YiAb7JVBlgKipPjH i9G2FkBTLjwkgowrx/JUmljSFXCSscmiORs7r8q+iyfCFHu6effjZUaFvYvCNL7QtIyq xqkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697343645; x=1697948445; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WMRHIxH0U6Hod3RQadnN4A/vcEgfdZ+o5NdSCEKHT2E=; b=tQk6KWNImsGqnq5DZxosx3QhtWRHSIIHS1w64iQcDQOLqg3QyD2J+IR7n8rmjkm0uH jraLcwbs0urD+dgc3hvsUNn21I+2TbDFecqTCJlg95Q/jPogObPHWGNq9N84j7meNoHT qyHJwbz0+C16naNFJyCjsZ2KTWMz8ujeVU+phur8D57VLHsc0egWCFDfkJDtwjCfxNfk eYHNHPRoxdtkQrl8wNc16kF3XgNC31rl59CS3sGN55EPPVfRrdv918Tee+MfxxVFDrvr 03ziyLdzM5xBiwP+VWYqZmB3+BGPXkQjYpTWUkzZlphYDkGzRtz5+F89HZhVa+zDkblJ rZIw== X-Gm-Message-State: AOJu0Yzw5pzmixdcazGMrTEfdshorcrqpFcnU8Gv+BvHgkq7OXwz5zJk CzDEE9cjixnWonbp0d/5sY/jyWRN04foWsxkV0aqNnuo7S8= X-Google-Smtp-Source: AGHT+IHHrDEKyqnOZ6McVpU4aaR/85bD/k4G9VkQNlts2FVqUKk3LrvX3vp0gFO5/0m0ezi3M/hJnyc0g0crnjhbWu4= X-Received: by 2002:a05:6870:11cb:b0:1e9:c10e:401f with SMTP id 11-20020a05687011cb00b001e9c10e401fmr7374566oav.12.1697343645094; Sat, 14 Oct 2023 21:20:45 -0700 (PDT) MIME-Version: 1.0 References: <83a5slsjmh.fsf@gnu.org> <76FD5982-60CC-48D2-9823-C235CCEC2EEC@gmail.com> In-Reply-To: <76FD5982-60CC-48D2-9823-C235CCEC2EEC@gmail.com> From: nvp Date: Sat, 14 Oct 2023 21:20:34 -0700 Message-ID: Subject: Re: bug#66431: [PATCH] Fix reset treesit--explorer-last-node when explorer buffer was killed To: Yuan Fu Content-Type: multipart/alternative; boundary="0000000000000718ea0607b99dc4" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 66431 Cc: Eli Zaretskii , 66431@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --0000000000000718ea0607b99dc4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, The patch is supposed to reset `treesit--explorer-last-node` in the source buffer, just before the `(with-current-buffer treesit--explorer-buffer ...)`. Upon trying to reproduce it now, I realized it's harder to reproduce than I had thought -- sorry about that. I noticed the bug (if it is a bug) initially when I was adding a function to jump b/w source and explorer buffers, like the following: (defun my-treesit-explorer-jump () "Pop b/w source and explorer buffers." (interactive) (let ((buf (cond ((eq major-mode 'treesit--explorer-tree-mode) (when (buffer-live-p treesit--explorer-source-buffer) treesit--explorer-source-buffer)) (t (unless (and treesit-explore-mode (buffer-live-p treesit--explorer-buffer)) ;; *** Without the reset here, the explorer buffer doesn't ;; get redrawn the first time, when treesit--explorer-last-nod= e ;; is non-nil in the source buffer *** ;; (setq-local treesit--explorer-last-node nil) (cl-letf (((symbol-function (function completing-read)) (lambda (&rest _) (symbol-name (treesit-language-at (point)))))) (treesit-explore-mode 1))) treesit--explorer-buffer)))) (pop-to-buffer buf))) Let me give a more precise recipe to reproduce: 1. From a c++-ts-mode buffer, call `treesit-explorer-mode`, select `cpp`. Now there should be an explorer buffer. 2. Kill the associated explorer buffer. 3. Now, back in the c++-ts-mode buffer, `treesit--explorer-last-node` should still have a value. 4. From that c++-ts-mode buffer, call `my-treesit-explorer-jump`, and the explorer buffer should be empty, until switching back to the source buffer. This seems to me to be caused by `treesit--explorer-post-command` not running until the source buffer is active again. On Sat, Oct 14, 2023 at 10:08=E2=80=AFAM Yuan Fu wrote: > > > > On Oct 14, 2023, at 1:17 AM, Eli Zaretskii wrote: > > > >> From: nvp > >> Date: Mon, 9 Oct 2023 23:02:48 -0700 > >> > >> Tags: patch > >> > >> Bug: After `treesit-explorer-mode` is enabled in a buffer and its > >> associated `treesit--explorer-buffer` is killed, a subsequent call > >> to `treesit-explorer-mode` initially displays an empty explorer > >> buffer b/c `treesit--explorer-refresh` sees old value for > >> `treesit--explorer-last-node`. > >> > >> * lisp/treesit.el (treesit-explorer-mode): reset > >> `treesit--explorer-last-node` when `treesit--explorer-buffer` was kill= ed > >> > >> In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version > >> 3.24.33, cairo version 1.16.0) of 2023-10-05 built on noah-X580VD > >> Repository revision: 505c80623049d9e181918acdac8229c9a2041b1e > >> Repository branch: master > >> Windowing system distributor 'The X.Org Foundation', version > 11.0.12101004 > >> System Description: Ubuntu 22.04.3 LTS > > > > Yuan, could you please look into this? Is the patch OK to go in, and > > if so, should it be installed on emacs-29? > > I=E2=80=99ll look at it, thanks for the reminder. > > Yuan > > --0000000000000718ea0607b99dc4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,
The patch is supposed to reset `treesit--explorer-= last-node` in the source buffer, just before the `(with-current-buffer tree= sit--explorer-buffer ...)`.
Upon trying to reproduce it now, I re= alized it's harder to reproduce=C2=A0than I=C2=A0had thought -- sorry a= bout that.=C2=A0=C2=A0
I noticed the bug (if it is a bug) initial= ly when I was adding a function to jump b/w source and explorer buffers, li= ke the following:

(defun my-treesit-explorer-jump = ()
=C2=A0 "Pop b/w source and explorer buffers."
=C2=A0 (in= teractive)
=C2=A0 (let ((buf
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(cond<= br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ((eq major-mode 'treesit--explore= r-tree-mode)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(when (buffer-live= -p treesit--explorer-source-buffer)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0treesit--explorer-source-buffer))
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (t
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(unless (and tree= sit-explore-mode
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 (buffer-live-p treesit--explorer-buffer))
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; *** Without the reset he= re, the explorer buffer doesn't
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0;; get redrawn the first time, when treesit--explorer-last-nod= e
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; is non-nil i= n the source buffer ***
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= ;; (setq-local treesit--explorer-last-node nil)
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0(cl-letf (((symbol-function (function completing-re= ad))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 (lambda (&rest _) (symbol-name (treesit-language-at (= point))))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(tree= sit-explore-mode 1)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0treesit--= explorer-buffer))))
=C2=A0 =C2=A0 (pop-to-buffer buf)))

Let me give a more precise recipe to reproduce:
1. From = a c++-ts-mode buffer, call `treesit-explorer-mode`, select `cpp`.=C2=A0 Now= there should be an explorer buffer.
2. Kill the associated explo= rer buffer.
3. Now, back in the c++-ts-mode buffer, `treesit--exp= lorer-last-node` should still have a value.
4. From that c++-ts-m= ode buffer, call `my-treesit-explorer-jump`, and the explorer buffer should= be empty, until
switching back to the source buffer.
<= br>
This seems to me to be caused by `treesit--explorer-post-comm= and` not running until the source=C2=A0
buffer is active again.


On Sat, Oct 14, 2023 at 10:08=E2=80=AFAM Yuan Fu <casouri@gmail.com> wrote:


> On Oct 14, 2023, at 1:17 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>
>> From: nvp <noah.v.peart@gmail.com>
>> Date: Mon, 9 Oct 2023 23:02:48 -0700
>>
>> Tags: patch
>>
>> Bug: After `treesit-explorer-mode` is enabled in a buffer and its<= br> >> associated `treesit--explorer-buffer` is killed, a subsequent call=
>> to `treesit-explorer-mode` initially displays an empty explorer >> buffer b/c `treesit--explorer-refresh` sees old value for
>> `treesit--explorer-last-node`.
>>
>> * lisp/treesit.el (treesit-explorer-mode): reset
>> `treesit--explorer-last-node` when `treesit--explorer-buffer` was = killed
>>
>> In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version >> 3.24.33, cairo version 1.16.0) of 2023-10-05 built on noah-X580VD<= br> >> Repository revision: 505c80623049d9e181918acdac8229c9a2041b1e
>> Repository branch: master
>> Windowing system distributor 'The X.Org Foundation', versi= on 11.0.12101004
>> System Description: Ubuntu 22.04.3 LTS
>
> Yuan, could you please look into this?=C2=A0 Is the patch OK to go in,= and
> if so, should it be installed on emacs-29?

I=E2=80=99ll look at it, thanks for the reminder.

Yuan

--0000000000000718ea0607b99dc4-- From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 19 00:36:35 2023 Received: (at 66431) by debbugs.gnu.org; 19 Oct 2023 04:36:35 +0000 Received: from localhost ([127.0.0.1]:35400 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtKlu-000697-Oj for submit@debbugs.gnu.org; Thu, 19 Oct 2023 00:36:35 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:56464) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtKls-00068u-HW for 66431@debbugs.gnu.org; Thu, 19 Oct 2023 00:36:33 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1cab2c24ecdso4156285ad.0 for <66431@debbugs.gnu.org>; Wed, 18 Oct 2023 21:36:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697690160; x=1698294960; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=JapYjnlPeH0faFz1wN4jS7xRlXLmqPHdbYdeFlqSakw=; b=To30cdWrTUIvd7eg06TvMiUkCPxPBRmHsPfyhFItq2jkUdj3Fmj1yBZA/2ega9Ackx SWw6NSVbYLGhpsgoVqIhGYzHcklJH4hOy6ZP/+jh5N3lmyhbLslzSgTfsWyOYfwPbeWG RsFkxKH4MZx/Bn/u1t3tAbdoEZK5xpTPu5IvbKbKaTLeinCHXwoe9kjjDBgVNOirA+pM Upjf2aEzKi0Xe2cLO1zp3ITFxXTfdA2QmlfVN/7RwE42c29eqmaqis3rqjRUbKmbe1Ek UuwbE83FJ8Jxdk3hkuANl/ZyobgX8ZzW5zBEDwAxwZDdrK5ip42fdzngsiRXgn7agV/5 w9UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697690160; x=1698294960; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JapYjnlPeH0faFz1wN4jS7xRlXLmqPHdbYdeFlqSakw=; b=L0l7yE3Bzb0AKuN4BzMCIa1TSqIzgWwQIi971BvhcUr2WTtrYAg2oml4vx7BEhiBGa UiKY6q2ZN1JAClr76QxlGCICFuQ6GzuCBBOoR/0hszosYFIbJ/w7JaqJYw2R6fB5xcXf 2a8A9n8f21+jgzoaC3tglfeKqb89WshsjwQ/2OEmLFe8G6DU3gLjQZKd8IlCitmLf94o dJxlqplqqaLeLhcZ5yYlgH3Q48fI0LnOLyYoGqBU/DeBnaxqhUKFA6hjYGI1qRyFZmmc QWrdHaXYY97NidjaxvIe0/NAS1Trs3LLdjG77OXrHNAPmA1Csgkef8mm1zQHHcrAhNCk RfXA== X-Gm-Message-State: AOJu0YxCmKy9UQqxtzxxqHJJ6Lggt5rAUd3T3WxfaljezvnqlpPXZTUB 774zcOQR0mSbfZ24EcgaLMU= X-Google-Smtp-Source: AGHT+IEs+LJ5NKnVwKp71CZZKicIuETK7zDX76eIe8/VGl1Sl5RLKZxf+IYxrh5cBLwtuUz/8NJwSQ== X-Received: by 2002:a17:902:c614:b0:1c3:1f0c:fb82 with SMTP id r20-20020a170902c61400b001c31f0cfb82mr965002plr.41.1697690160029; Wed, 18 Oct 2023 21:36:00 -0700 (PDT) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id iy2-20020a170903130200b001c731b62403sm774107plb.218.2023.10.18.21.35.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Oct 2023 21:35:59 -0700 (PDT) From: Yuan Fu Message-Id: <029D1797-AE78-4E45-BE25-0BEC8AF47321@gmail.com> Content-Type: multipart/mixed; boundary="Apple-Mail=_A2C4F754-EF7D-4669-BF1B-A2B65D6F47F0" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Subject: Re: bug#66431: [PATCH] Fix reset treesit--explorer-last-node when explorer buffer was killed Date: Wed, 18 Oct 2023 21:35:48 -0700 In-Reply-To: To: nvp References: <83a5slsjmh.fsf@gnu.org> <76FD5982-60CC-48D2-9823-C235CCEC2EEC@gmail.com> X-Mailer: Apple Mail (2.3731.700.6) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 66431 Cc: Eli Zaretskii , 66431@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Apple-Mail=_A2C4F754-EF7D-4669-BF1B-A2B65D6F47F0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Oct 14, 2023, at 9:20 PM, nvp wrote: >=20 > Hi, > The patch is supposed to reset `treesit--explorer-last-node` in the = source buffer, just before the `(with-current-buffer = treesit--explorer-buffer ...)`. > Upon trying to reproduce it now, I realized it's harder to reproduce = than I had thought -- sorry about that. =20 > I noticed the bug (if it is a bug) initially when I was adding a = function to jump b/w source and explorer buffers, like the following: >=20 > (defun my-treesit-explorer-jump () > "Pop b/w source and explorer buffers." > (interactive) > (let ((buf > (cond > ((eq major-mode 'treesit--explorer-tree-mode) > (when (buffer-live-p treesit--explorer-source-buffer) > treesit--explorer-source-buffer)) > (t > (unless (and treesit-explore-mode > (buffer-live-p treesit--explorer-buffer)) > ;; *** Without the reset here, the explorer buffer = doesn't > ;; get redrawn the first time, when = treesit--explorer-last-node > ;; is non-nil in the source buffer *** > ;; (setq-local treesit--explorer-last-node nil) > (cl-letf (((symbol-function (function completing-read)) > (lambda (&rest _) (symbol-name = (treesit-language-at (point)))))) > (treesit-explore-mode 1))) > treesit--explorer-buffer)))) > (pop-to-buffer buf))) >=20 > Let me give a more precise recipe to reproduce: > 1. =46rom a c++-ts-mode buffer, call `treesit-explorer-mode`, select = `cpp`. Now there should be an explorer buffer. > 2. Kill the associated explorer buffer. > 3. Now, back in the c++-ts-mode buffer, `treesit--explorer-last-node` = should still have a value. > 4. =46rom that c++-ts-mode buffer, call `my-treesit-explorer-jump`, = and the explorer buffer should be empty, until > switching back to the source buffer. >=20 > This seems to me to be caused by `treesit--explorer-post-command` not = running until the source=20 > buffer is active again. Thank you, I think I see the problem now. Could you try the below patch = and see it fixes your problem? Also, sorry for the late reply, I meant = to reply sooner but couldn=E2=80=99t find the time to figure out what = exact was the cause :-) I was initially a bit confused since we already = do set last-node to nil. Yuan --Apple-Mail=_A2C4F754-EF7D-4669-BF1B-A2B65D6F47F0 Content-Disposition: attachment; filename=fix-last-node.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="fix-last-node.diff" Content-Transfer-Encoding: 7bit diff --git a/lisp/treesit.el b/lisp/treesit.el index c73ac9912d6..9f7e8bacd35 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -3198,13 +3198,13 @@ treesit-explore-mode (treesit--explorer-tree-mode))) (display-buffer treesit--explorer-buffer (cons nil '((inhibit-same-window . t)))) + (setq-local treesit--explorer-last-node nil) (treesit--explorer-refresh) ;; Set up variables and hooks. (add-hook 'post-command-hook #'treesit--explorer-post-command 0 t) (add-hook 'kill-buffer-hook #'treesit--explorer-kill-explorer-buffer 0 t) - (setq-local treesit--explorer-last-node nil) ;; Tell `desktop-save' to not save explorer buffers. (when (boundp 'desktop-modes-not-to-save) (unless (memq 'treesit--explorer-tree-mode --Apple-Mail=_A2C4F754-EF7D-4669-BF1B-A2B65D6F47F0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail=_A2C4F754-EF7D-4669-BF1B-A2B65D6F47F0-- From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 20 17:23:26 2023 Received: (at 66431) by debbugs.gnu.org; 20 Oct 2023 21:23:26 +0000 Received: from localhost ([127.0.0.1]:41766 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtwxp-0006fC-IX for submit@debbugs.gnu.org; Fri, 20 Oct 2023 17:23:26 -0400 Received: from mail-ot1-x32b.google.com ([2607:f8b0:4864:20::32b]:55609) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qtwxl-0006ew-KR for 66431@debbugs.gnu.org; Fri, 20 Oct 2023 17:23:24 -0400 Received: by mail-ot1-x32b.google.com with SMTP id 46e09a7af769-6ce2fc858feso832536a34.3 for <66431@debbugs.gnu.org>; Fri, 20 Oct 2023 14:22:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697836968; x=1698441768; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=cFt6EgQsSVwo2T6r/dkqNpBd6ftXzAgbV2qOPv5Rais=; b=crszRBGY1UQtm/Nh0Op7Xkmgti+e2CsUxDRHZHvhOiZ9P6vWiasLfHRN0hRCEyKq/L myNog3BgAZpIXHqvp5XrdzDwtjXqO0Vt0C1QB9DVxbDxTzXxVu3KlGv/7C2b5krUAC5p FxISL/L8bU23juMjW7uH7pCzyOJKx6R/hnXbnmPT7041Se0acayaLnjMq3bHq3f7KLYe 7D5Pl1ik79d7blbs9j/t/3mML3zxc+JlSB0wkgCUmC7cx/OCoCA7jQfpTDivdNkqLrTe 274P4ChU3nL8D6vxklvemMz5gR/0JTp0rlB74umQoHaz53CZno1AfmyVD3X/oDRPs/xt Nsig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697836968; x=1698441768; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cFt6EgQsSVwo2T6r/dkqNpBd6ftXzAgbV2qOPv5Rais=; b=gexpsAwteiw7TVkaVv5MLp7hQgS1hrqRZjdeu0FTfB8wIWkir0H7fQLgL/1AQbfC4d 4h4n+jjsFfw8mWgLUjxH65mCo7i8Jq6COb/T6ODaBHI1XdT/Nk8k8bsnJVa4xw7uk8dB h56SzJAw1/Lpp6Ou/yqbY4GnVrK05v20BAplEzblnWUu42uRojVFYKW2vPfhLwdAn0wi flgbPPFnbVH7OKluaLDhWJD+9eWSilIhiVZ8R3X0wnJfKQU3/xEUORICfGuQbz9LRHsx wnvE+0zUWIktiwFS9je7PgckHeM3I9eD+d/YALuMwreNzNNgVtv++la8/bdQNpmeOnBd yZ4g== X-Gm-Message-State: AOJu0YyRufWrYFTVRSqHNU4SPCOrBxcAhEOQFCocOwxbKJeLMR3963qE pnRpvbAcry6ogwBRv04i3+VIxx8hjMEUrAHDqN4= X-Google-Smtp-Source: AGHT+IEancAPK0uIQURCg7OVWp9uP6NPSp/vMmfjbr09zRWujUZm3KycTYw6Z40Tf60MLhRmmpTgg57MJu4xukWaTTM= X-Received: by 2002:a05:6870:8a27:b0:1e9:8a35:8635 with SMTP id p39-20020a0568708a2700b001e98a358635mr3645729oaq.21.1697836968394; Fri, 20 Oct 2023 14:22:48 -0700 (PDT) MIME-Version: 1.0 References: <83a5slsjmh.fsf@gnu.org> <76FD5982-60CC-48D2-9823-C235CCEC2EEC@gmail.com> <029D1797-AE78-4E45-BE25-0BEC8AF47321@gmail.com> In-Reply-To: <029D1797-AE78-4E45-BE25-0BEC8AF47321@gmail.com> From: nvp Date: Fri, 20 Oct 2023 14:22:37 -0700 Message-ID: Subject: Re: bug#66431: [PATCH] Fix reset treesit--explorer-last-node when explorer buffer was killed To: Yuan Fu Content-Type: multipart/alternative; boundary="0000000000006344f006082c7941" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 66431 Cc: Eli Zaretskii , 66431@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --0000000000006344f006082c7941 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable That fixes the problem! However, the reason I initially put the reset inside the `(unless (buffer-live-p treesit--explorer-buffer) ...)` in `treesit-explore-mode` was b/c it looked like there was an optimization happening in `treesit--explorer-refresh` where it does this check ;; If we didn't edit the buffer nor change the top-level ;; node, don't redraw the whole syntax tree. (highlight-only (treesit-node-eq top-level treesit--explorer-last-node)) I don't know if that is something you'd want to keep, but just pointing it out in case. I think the initial patch works as well, but still allows that check to work when the explorer buffer hasn't been killed. Thankyou! On Wed, Oct 18, 2023 at 9:36=E2=80=AFPM Yuan Fu wrote: > > > > On Oct 14, 2023, at 9:20 PM, nvp wrote: > > > > Hi, > > The patch is supposed to reset `treesit--explorer-last-node` in the > source buffer, just before the `(with-current-buffer > treesit--explorer-buffer ...)`. > > Upon trying to reproduce it now, I realized it's harder to reproduce > than I had thought -- sorry about that. > > I noticed the bug (if it is a bug) initially when I was adding a > function to jump b/w source and explorer buffers, like the following: > > > > (defun my-treesit-explorer-jump () > > "Pop b/w source and explorer buffers." > > (interactive) > > (let ((buf > > (cond > > ((eq major-mode 'treesit--explorer-tree-mode) > > (when (buffer-live-p treesit--explorer-source-buffer) > > treesit--explorer-source-buffer)) > > (t > > (unless (and treesit-explore-mode > > (buffer-live-p treesit--explorer-buffer)) > > ;; *** Without the reset here, the explorer buffer doesn't > > ;; get redrawn the first time, when > treesit--explorer-last-node > > ;; is non-nil in the source buffer *** > > ;; (setq-local treesit--explorer-last-node nil) > > (cl-letf (((symbol-function (function completing-read)) > > (lambda (&rest _) (symbol-name > (treesit-language-at (point)))))) > > (treesit-explore-mode 1))) > > treesit--explorer-buffer)))) > > (pop-to-buffer buf))) > > > > Let me give a more precise recipe to reproduce: > > 1. From a c++-ts-mode buffer, call `treesit-explorer-mode`, select > `cpp`. Now there should be an explorer buffer. > > 2. Kill the associated explorer buffer. > > 3. Now, back in the c++-ts-mode buffer, `treesit--explorer-last-node` > should still have a value. > > 4. From that c++-ts-mode buffer, call `my-treesit-explorer-jump`, and > the explorer buffer should be empty, until > > switching back to the source buffer. > > > > This seems to me to be caused by `treesit--explorer-post-command` not > running until the source > > buffer is active again. > > Thank you, I think I see the problem now. Could you try the below patch > and see it fixes your problem? Also, sorry for the late reply, I meant to > reply sooner but couldn=E2=80=99t find the time to figure out what exact = was the > cause :-) I was initially a bit confused since we already do set last-nod= e > to nil. > > Yuan > > > > --0000000000006344f006082c7941 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
That fixes the problem!

However, the re= ason I initially put the reset inside the `(unless (buffer-live-p treesit--= explorer-buffer) ...)`
in `treesit-explore-mode` was b/c it looke= d like there was an optimization happening in=C2=A0
`treesit--exp= lorer-refresh` where it does this check=C2=A0

=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; If we didn't edit the buffer n= or change the top-level
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; node= , don't redraw the whole syntax tree.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0(highlight-only (treesit-node-eq
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 t= op-level treesit--explorer-last-node))

I don&#= 39;t know if that is something you'd want to keep, but just pointing it= out in case.=C2=A0 I think
the initial patch works as well, but = still allows that check to work when the explorer buffer=C2=A0hasn't=C2= =A0
been killed.

Thankyou!
On Wed, = Oct 18, 2023 at 9:36=E2=80=AFPM Yuan Fu <casouri@gmail.com> wrote:


> On Oct 14, 2023, at 9:20 PM, nvp <noah.v.peart@gmail.com> wrote:
>
> Hi,
> The patch is supposed to reset `treesit--explorer-last-node` in the so= urce buffer, just before the `(with-current-buffer treesit--explorer-buffer= ...)`.
> Upon trying to reproduce it now, I realized it's harder to reprodu= ce than I had thought -- sorry about that.=C2=A0
> I noticed the bug (if it is a bug) initially when I was adding a funct= ion to jump b/w source and explorer buffers, like the following:
>
> (defun my-treesit-explorer-jump ()
>=C2=A0 =C2=A0"Pop b/w source and explorer buffers."
>=C2=A0 =C2=A0(interactive)
>=C2=A0 =C2=A0(let ((buf
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (cond
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((eq major-mode 'treesit--= explorer-tree-mode)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (when (buffer-live-p treesit-= -explorer-source-buffer)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 treesit--explorer-sour= ce-buffer))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(t
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (unless (and treesit-explore-= mode
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0(buffer-live-p treesit--explorer-buffer))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; *** Without the res= et here, the explorer buffer doesn't
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; get redrawn the fir= st time, when treesit--explorer-last-node
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; is non-nil in the s= ource buffer ***
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; (setq-local treesit= --explorer-last-node nil)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (cl-letf (((symbol-fun= ction (function completing-read))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0(lambda (&rest _) (symbol-name (treesit-language-at= (point))))))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (treesit-explor= e-mode 1)))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 treesit--explorer-buffer))))<= br> >=C2=A0 =C2=A0 =C2=A0(pop-to-buffer buf)))
>
> Let me give a more precise recipe to reproduce:
> 1. From a c++-ts-mode buffer, call `treesit-explorer-mode`, select `cp= p`.=C2=A0 Now there should be an explorer buffer.
> 2. Kill the associated explorer buffer.
> 3. Now, back in the c++-ts-mode buffer, `treesit--explorer-last-node` = should still have a value.
> 4. From that c++-ts-mode buffer, call `my-treesit-explorer-jump`, and = the explorer buffer should be empty, until
> switching back to the source buffer.
>
> This seems to me to be caused by `treesit--explorer-post-command` not = running until the source
> buffer is active again.

Thank you, I think I see the problem now. Could you try the below patch and= see it fixes your problem? Also, sorry for the late reply, I meant to repl= y sooner but couldn=E2=80=99t find the time to figure out what exact was th= e cause :-) I was initially a bit confused since we already do set last-nod= e to nil.

Yuan



--0000000000006344f006082c7941-- From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 21 14:34:08 2023 Received: (at 66431) by debbugs.gnu.org; 21 Oct 2023 18:34:08 +0000 Received: from localhost ([127.0.0.1]:45027 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quGnY-0007cg-CX for submit@debbugs.gnu.org; Sat, 21 Oct 2023 14:34:08 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:53287) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quGnV-0007c6-Gw for 66431@debbugs.gnu.org; Sat, 21 Oct 2023 14:34:06 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-6b5cac99cfdso1626492b3a.2 for <66431@debbugs.gnu.org>; Sat, 21 Oct 2023 11:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697913212; x=1698518012; darn=debbugs.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=+v9EASCdl7arNr3HZsRwkU97GmEElcdNamNMi+gPzSU=; b=fVzTJcpkuym2vFzxvYEBHfewyQreb89wD04DeOT6LkXXk+DVAEQgpithDBVyuN5bmv OcK8rdfJ3rtVF5dQv+1livuwbIst9yc3P6M/xLh6jiKLQQ4GqHOwkR8WkFM0RWCNx29X bnBvlFldjXWDm4S+PyHUC20ehCOy3SdNNrqirmZBFX4/TLegv5ZU47N24d6DI86NdRcu EQCRl1OjAIVwGwGF6TdoXTLBizkNKzSkkb8im1M6nC6o3AXj20o4za6Ex3gIcouE16OL wO4B7hoA29EhMp/tmjGP6tRrhcxHutow+Bo6b2aixUjHnPYRLidRt0IQDrvKJ54OfPuU ML7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697913212; x=1698518012; 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=+v9EASCdl7arNr3HZsRwkU97GmEElcdNamNMi+gPzSU=; b=hS9SiU36nNE1HUcQtQSAGIqNdmReuXDGFYz06TUOYqLo95fUUV+rN6zQI/Jie1jiYV hu9/XJ4mTrhJeltT4UJpfnCwVRg0f4JiNTwVa65y1nw3gkGgbSc9fZ07Lc+GxXzXVGZ4 GiTKJbw9fGONIP9NIY0MPIDEuyucuIkInw3kiRo4XKsRowyghHdOGPf9T20yBG/oxXzF /02o3MxzPt/gB5nzPatd4VrY3Sln5fDHmrdRxlKrUznJfkeTdBkDtvfh22NPICxAU6jB 1TvXrMGELnmOOn4pCeEARV4P6tyxWg208jxqWutflBdeMKbdsN6BmfE4AFsgehXpw0Od U/RA== X-Gm-Message-State: AOJu0Ywk60S5A5fjETt7cb1ABXDRT2BLE/1AL4IxqLgmUn0UfrKPUMB7 N/tPju4noDdd24RYjyWbraXmSt9rJI8= X-Google-Smtp-Source: AGHT+IHWf3MlmEyKudY+uT+OEFFFT5qACVYJvVSn/ZOfLtinwDiLWjGIVE8MifknhaS9PUgAaUN8aA== X-Received: by 2002:aa7:88d0:0:b0:68e:41e9:10be with SMTP id k16-20020aa788d0000000b0068e41e910bemr4329361pff.20.1697913211792; Sat, 21 Oct 2023 11:33:31 -0700 (PDT) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id c15-20020aa7952f000000b0068fe7e07190sm3535556pfp.3.2023.10.21.11.33.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Oct 2023 11:33:31 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Subject: Re: bug#66431: [PATCH] Fix reset treesit--explorer-last-node when explorer buffer was killed From: Yuan Fu In-Reply-To: Date: Sat, 21 Oct 2023 11:33:20 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: References: <83a5slsjmh.fsf@gnu.org> <76FD5982-60CC-48D2-9823-C235CCEC2EEC@gmail.com> <029D1797-AE78-4E45-BE25-0BEC8AF47321@gmail.com> To: nvp X-Mailer: Apple Mail (2.3731.700.6) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 66431 Cc: Eli Zaretskii , 66431@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On Oct 20, 2023, at 2:22 PM, nvp wrote: >=20 > That fixes the problem! >=20 > However, the reason I initially put the reset inside the `(unless = (buffer-live-p treesit--explorer-buffer) ...)` > in `treesit-explore-mode` was b/c it looked like there was an = optimization happening in=20 > `treesit--explorer-refresh` where it does this check=20 >=20 > ;; If we didn't edit the buffer nor change the top-level > ;; node, don't redraw the whole syntax tree. > (highlight-only (treesit-node-eq > top-level treesit--explorer-last-node)) >=20 > I don't know if that is something you'd want to keep, but just = pointing it out in case. I think > the initial patch works as well, but still allows that check to work = when the explorer buffer hasn't=20 > been killed. Oh that=E2=80=99s fine, treesit-explore-mode always wipes everything and = start from a clean slate. That optimization is for when the user moves = point in the source buffer when explore-mode is on. If you=E2=80=99d = like to send a patch that does roughly what I did in the patch I sent, = I=E2=80=99d love to merge it. Otherwise I can fix it myself, too. The initial patch could be a bit confusing to the readers since it sets = last-node twice, and it=E2=80=99s not clear why. Thanks, Yuan= From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 21 20:41:29 2023 Received: (at 66431) by debbugs.gnu.org; 22 Oct 2023 00:41:29 +0000 Received: from localhost ([127.0.0.1]:45237 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quMX3-00088u-6O for submit@debbugs.gnu.org; Sat, 21 Oct 2023 20:41:29 -0400 Received: from mail-oa1-x31.google.com ([2001:4860:4864:20::31]:51221) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quMX0-00088g-Gl for 66431@debbugs.gnu.org; Sat, 21 Oct 2023 20:41:27 -0400 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-1e9b6f39f9eso1644822fac.2 for <66431@debbugs.gnu.org>; Sat, 21 Oct 2023 17:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697935252; x=1698540052; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=aqlXlyzKOFui1WxvXmxEgHjADYcHKUtzvUcjCrGJACw=; b=LeptqHBeK5yX6Mcgri6zPboHDsBOmSIWQmm/4PWExK50Adh+eTYvK+ZNnVns0XcteA AsstmaTNBq7XcwYJlwHOEy3DcworvuAscdhzGPDt0Nt2tf5IesONI16quMS1DtikGBs2 GT5+GOeAXCF99HjMqAr1Xfm4nqIAZ8+fMQ8PkfjpW1QcSmYyYhwcd3+wBMjOGac9HxTn C36P3fEI+psP8VffDYgmgrHbDCfOyVpgcVvGAzsiEQRQElC9O7ZKjN17LBer7TmrIh5j mcvK4naCKtsVnU/Xz92m4XoiTQFJNnFupx6Kxm7SxUeDc1M4PyRxTRSPJFZJBQIJdpp2 s79A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697935252; x=1698540052; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aqlXlyzKOFui1WxvXmxEgHjADYcHKUtzvUcjCrGJACw=; b=urIaARU1BdbeNGDjHAqlojrRLzq93bQwu16fgTpXLkZaqulSzgbLHtB8eHVn9LXC8F w4hvOWMaJJfp3x6zgMINUJSMaJDFFF3fKygSl4mPWQRf3QonHOgw7A+xL1mqDE1gaIb0 NbeI9qGdM+mO+2Tn8vbdd5phoyjUYc0WY9gCtF3kTPjTL1lj9EYJYtdNwnM2x5EEgME8 4vyTa5+iDS3PDQO0xbszfQDZducNWvVfAuveu0kKKaQrgETYlhnWfj277jKPaqcE3p7R +pVFtndCbhg4v7QmB0wBbqvcfQzfxAm0aQWSXzbVv2G8g/VzZ0zmCJNH+gDfHPYb4MCw C/4w== X-Gm-Message-State: AOJu0YzYdhMBC/BhPmnw8pjpgSCVzXcuJmOIyHXf4dOGbT55tkM0fe1S eM3FWENDfMTiG5AkhnSup8pOSzK2c2zhqehVpZI= X-Google-Smtp-Source: AGHT+IEAyLDDhCA3wMQRB3YFeLyp401/BAVWKPLZ1lgi389Q9PdM97lc8QC/n4aN+vjs4Q/MK5I7UkLmuNiTickTJto= X-Received: by 2002:a05:6870:289b:b0:1e9:b2e2:8754 with SMTP id gy27-20020a056870289b00b001e9b2e28754mr7283558oab.2.1697935251921; Sat, 21 Oct 2023 17:40:51 -0700 (PDT) MIME-Version: 1.0 References: <83a5slsjmh.fsf@gnu.org> <76FD5982-60CC-48D2-9823-C235CCEC2EEC@gmail.com> <029D1797-AE78-4E45-BE25-0BEC8AF47321@gmail.com> In-Reply-To: From: nvp Date: Sat, 21 Oct 2023 17:40:40 -0700 Message-ID: Subject: Re: bug#66431: [PATCH] Fix reset treesit--explorer-last-node when explorer buffer was killed To: Yuan Fu Content-Type: multipart/alternative; boundary="0000000000008adeb10608435bf9" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 66431 Cc: Eli Zaretskii , 66431@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --0000000000008adeb10608435bf9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Ok that makes sense, thanks for clearing that up for me, your fix looks good. I'm loving this package! On Sat, Oct 21, 2023 at 11:33=E2=80=AFAM Yuan Fu wrote: > > > > On Oct 20, 2023, at 2:22 PM, nvp wrote: > > > > That fixes the problem! > > > > However, the reason I initially put the reset inside the `(unless > (buffer-live-p treesit--explorer-buffer) ...)` > > in `treesit-explore-mode` was b/c it looked like there was an > optimization happening in > > `treesit--explorer-refresh` where it does this check > > > > ;; If we didn't edit the buffer nor change the top-level > > ;; node, don't redraw the whole syntax tree. > > (highlight-only (treesit-node-eq > > top-level treesit--explorer-last-node)) > > > > I don't know if that is something you'd want to keep, but just pointing > it out in case. I think > > the initial patch works as well, but still allows that check to work > when the explorer buffer hasn't > > been killed. > > Oh that=E2=80=99s fine, treesit-explore-mode always wipes everything and = start > from a clean slate. That optimization is for when the user moves point in > the source buffer when explore-mode is on. If you=E2=80=99d like to send = a patch > that does roughly what I did in the patch I sent, I=E2=80=99d love to mer= ge it. > Otherwise I can fix it myself, too. > > The initial patch could be a bit confusing to the readers since it sets > last-node twice, and it=E2=80=99s not clear why. > > Thanks, > Yuan --0000000000008adeb10608435bf9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Ok that makes sense, thanks for clearing that up for me,= =C2=A0your fix=C2=A0looks good. I'm loving this package!

On Sat, Oct 21,= 2023 at 11:33=E2=80=AFAM Yuan Fu <= casouri@gmail.com> wrote:


> On Oct 20, 2023, at 2:22 PM, nvp <noah.v.peart@gmail.com> wrote:
>
> That fixes the problem!
>
> However, the reason I initially put the reset inside the `(unless (buf= fer-live-p treesit--explorer-buffer) ...)`
> in `treesit-explore-mode` was b/c it looked like there was an optimiza= tion happening in
> `treesit--explorer-refresh` where it does this check
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; If we didn't edit the = buffer nor change the top-level
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; node, don't redraw the= whole syntax tree.
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (highlight-only (treesit-node= -eq
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0top-level treesit--explorer-last-node)) >
> I don't know if that is something you'd want to keep, but just= pointing it out in case.=C2=A0 I think
> the initial patch works as well, but still allows that check to work w= hen the explorer buffer hasn't
> been killed.

Oh that=E2=80=99s fine, treesit-explore-mode always wipes everything and st= art from a clean slate. That optimization is for when the user moves point = in the source buffer when explore-mode is on. If you=E2=80=99d like to send= a patch that does roughly what I did in the patch I sent, I=E2=80=99d love= to merge it. Otherwise I can fix it myself, too.

The initial patch could be a bit confusing to the readers since it sets las= t-node twice, and it=E2=80=99s not clear why.

Thanks,
Yuan
--0000000000008adeb10608435bf9-- From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 21 23:36:39 2023 Received: (at 66431-done) by debbugs.gnu.org; 22 Oct 2023 03:36:39 +0000 Received: from localhost ([127.0.0.1]:45279 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quPGZ-0005WD-1a for submit@debbugs.gnu.org; Sat, 21 Oct 2023 23:36:39 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]:42299) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quPGX-0005W0-KH for 66431-done@debbugs.gnu.org; Sat, 21 Oct 2023 23:36:38 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1c9daca2b85so15627055ad.1 for <66431-done@debbugs.gnu.org>; Sat, 21 Oct 2023 20:36:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697945763; x=1698550563; darn=debbugs.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=9o5twOXDo7R3m6UHsC1W/OPSe+Hx3+Lz8Ntpd8RJ7FI=; b=hfAeDe9kOinNMdTAzNHT5pBvBVS9aOI0WZV5fxgF9pShxz4QS7oMXmQWAf6o5ucntr V5WcVQ99CpRC5aUZu+pkiqG7tt8i6YcBsNiHS8OTXWFIq+XoY99vv5ljLVT2NhC852IS Vwv1jHoqtgOVlW+KOQa+3yySSvhe2Q3gkgBMyHmRXHwfNHyDIYig63zQj8UmhIqnJGE6 bs1wCV1RJRZzwHTiHQFLyc5a7R1G2rJ4u59F+ZloFjNGJ0FSxgxddjdbsZmtMzGtdWLr UvKcQhPADGTSRQllUlH3Tiqa09ORV75vZxaS8jyn1kog8Tm2Tkyyjo1JHaR5+jR4wEin JqcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697945763; x=1698550563; 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=9o5twOXDo7R3m6UHsC1W/OPSe+Hx3+Lz8Ntpd8RJ7FI=; b=VuWTFJY7AooM1zqeRsRNNwGlVP/jQbwhpazEptEzrTHCAVCKLiilg5RsCVh+PceRhc 0V4edNscvzw/7qOFFNQgFOuA+6SvGTLfbkccvFmsJY+97Vjw6s7IHQz5Fq1zMZb54rx9 EonDXu9KcYNX3v9rs6DJI71LSSPuNMtf4iy/ySfgKlTaqReCbA2CUu3vutes4Ifa7T7i PWvgKkTxKdfvO3cI01mHd0X2LofUJbx3QhT22jHs4LPuDSPR6+JhRP9UbmkAdEPr8EmJ gdcjTN43VEXLI+jQH35I6zYU9NezXSoBPgiY21KP/qinmSH1wl5TIpFpYO1KP844PEek WCug== X-Gm-Message-State: AOJu0YwS/luW5HHl0WlUM9D9htfA9buoNKXYztT66y+0WAgfBTnkXTQs lhtTiuFCmgd9QLOClmnDogY= X-Google-Smtp-Source: AGHT+IELIxmMTp0uRIPBGBfyXPQGeprrMa/RL4Qf1ordBpu64eG5mShASejC446D6KfTxQ80Lc2JeA== X-Received: by 2002:a17:902:c404:b0:1c3:e2eb:f79d with SMTP id k4-20020a170902c40400b001c3e2ebf79dmr13750888plk.8.1697945763346; Sat, 21 Oct 2023 20:36:03 -0700 (PDT) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id iw3-20020a170903044300b001b9f7bc3e77sm3822049plb.189.2023.10.21.20.36.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Oct 2023 20:36:02 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Subject: Re: bug#66431: [PATCH] Fix reset treesit--explorer-last-node when explorer buffer was killed From: Yuan Fu In-Reply-To: Date: Sat, 21 Oct 2023 20:35:48 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: References: <83a5slsjmh.fsf@gnu.org> <76FD5982-60CC-48D2-9823-C235CCEC2EEC@gmail.com> <029D1797-AE78-4E45-BE25-0BEC8AF47321@gmail.com> To: nvp X-Mailer: Apple Mail (2.3731.700.6) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 66431-done Cc: 66431-done@debbugs.gnu.org, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On Oct 21, 2023, at 5:40 PM, nvp wrote: >=20 > Ok that makes sense, thanks for clearing that up for me, your fix = looks good. I'm loving this package! Thanks, I pushed the fix to emacs-29. I=E2=80=99m glad you are finding = it useful! Yuan= From unknown Fri Sep 05 16:40:34 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 19 Nov 2023 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator