From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 29 15:11:38 2022 Received: (at submit) by debbugs.gnu.org; 29 Oct 2022 19:11:38 +0000 Received: from localhost ([127.0.0.1]:36675 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oorF4-0005v6-5f for submit@debbugs.gnu.org; Sat, 29 Oct 2022 15:11:38 -0400 Received: from lists.gnu.org ([209.51.188.17]:42552) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oorEz-0005uv-3G for submit@debbugs.gnu.org; Sat, 29 Oct 2022 15:11:36 -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 1oorEy-0000Um-UF for bug-gnu-emacs@gnu.org; Sat, 29 Oct 2022 15:11:32 -0400 Received: from out2.migadu.com ([188.165.223.204]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oorEx-0000Li-4k for bug-gnu-emacs@gnu.org; Sat, 29 Oct 2022 15:11:32 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill To: bug-gnu-emacs@gnu.org Subject: 29.0.50; Fix indent-line-function in tree-sitter Date: Sat, 29 Oct 2022 21:11:27 +0200 Message-ID: <87eduqsaw0.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=188.165.223.204; envelope-from=theo@thornhill.no; helo=out2.migadu.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit Cc: casouri@gmail.com 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: -2.4 (--) --=-=-= Content-Type: text/plain Hi Yuan! There were some regressions with the new indent-line-function - see attached patch. We need the point, not the indentation, and the save-excursion is actually needed. consider: ``` foo({ thing: 1, tho|ng: 2, // <--- point is | }) ``` if you indent now you want to end up like this: ``` foo({ thing: 1, tho|ng: 2, // <--- point is | }) ``` or if ``` foo({ thing: 1, |thong: 2, // <--- point is | }) ``` You want to end up like this: ``` foo({ thing: 1, |thong: 2, // <--- point is | }) ``` This patch addresses this :-) In addition there was a bug where the parent-bol didn't indent correctly, this should also be fixed now. Thanks again, Yuan! Theo --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-indent-line-function.patch Content-Description: Fix indent-line-function in tree-sitter >From b8af08cbe03b66437901af2164e3b31c7df46f04 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Sat, 29 Oct 2022 21:03:23 +0200 Subject: [PATCH] Fix indent-line-function * lisp/treesit.el (treesit-simple-indent-presets): We need the actual position, not the indentation offset from column 0. Revert earlier change. (treesit-indent): Revert earlier change to preserve behavior with similar functions for other modes. Specifically. We want to preserve position in text if we are "in front of" the indentation goal. Otherwise just jump to the correct indentation. --- lisp/treesit.el | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lisp/treesit.el b/lisp/treesit.el index dd0aca5049..4032af5f14 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -783,7 +783,8 @@ treesit-simple-indent-presets (lambda (_n parent &rest _) (save-excursion (goto-char (treesit-node-start parent)) - (current-indentation))))) + (back-to-indentation) + (point))))) (prev-sibling . ,(byte-compile (lambda (node &rest _) (treesit-node-start @@ -973,13 +974,19 @@ treesit--indent-1 (defun treesit-indent () "Indent according to the result of `treesit-indent-function'." (treesit-update-ranges) - (pcase-let* ((`(,anchor . ,offset) (treesit--indent-1))) + (pcase-let* ((orig-pos (point)) + (bol (save-excursion + (back-to-indentation) + (point))) + (`(,anchor . ,offset) (treesit--indent-1))) (when (and anchor offset) (let ((col (+ (save-excursion (goto-char anchor) (current-column)) offset))) - (indent-line-to col))))) + (if (< bol orig-pos) + (save-excursion (indent-line-to col)) + (indent-line-to col)))))) (defvar treesit--indent-region-batch-size 400 "How many lines of indent value do we precompute. -- 2.34.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 29 16:07:09 2022 Received: (at 58873) by debbugs.gnu.org; 29 Oct 2022 20:07:09 +0000 Received: from localhost ([127.0.0.1]:36745 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oos6m-0007L2-LU for submit@debbugs.gnu.org; Sat, 29 Oct 2022 16:07:08 -0400 Received: from mail-pf1-f182.google.com ([209.85.210.182]:34504) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oos6h-0007KX-M6 for 58873@debbugs.gnu.org; Sat, 29 Oct 2022 16:07:07 -0400 Received: by mail-pf1-f182.google.com with SMTP id f140so7541416pfa.1 for <58873@debbugs.gnu.org>; Sat, 29 Oct 2022 13:07:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=O4N/n+O5NznmwG/Qzolh1nP5BVL7xpDnBjmwizH47pk=; b=CRzkV3l4h8frQKouDo59h6NO6Z6PO52f2PuZdOruEYnsH01GjdnR4qL0pZpym01i13 JCZmuTOWwq4UdZXatHFL/FCgVW0Iad3WI/pYWNNu5myq3ZmLtMEWAI4mCOWBkti9966T FEnRxM8NNxOi14XEky7INu1bBKjhIG88PrNNjySM7WFlGPIRM1VHqAid3nCI6oRYF7s5 hYW9EOBe5yQhsTWzm9iKoY89KbOzj7tybXoBsOgyNNE/fVVMiEEF4KST96q2ocCCkp2J pVAO2UqTsWjSmWlgfR+JyR8alN68n5u9drAcLrFkWC9Ui9Cdd6XBkHbCMvW9Z2XLTECJ GcTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=O4N/n+O5NznmwG/Qzolh1nP5BVL7xpDnBjmwizH47pk=; b=4x6Fq0OZ3JKemrh6K6/dQ5a29MKjQmTiN/iwHWTX6IW/pKTM4axIJ12fyfMnrDrDk/ PN+1JpGVBGALocEM9xBJY4f93wenzJbRP50f+U/0wDwlTg3jeSrnq4dx9iMuyow/lh75 EzKw6CZesFFMfRvyc3F5B1+U8CTUuVnLLR7SjaoDwYtzymFSRdxjz5kvGdLGRLyskJW0 NHN8ra8k+GCmKIjadI4MZpLlWHfa/latN6fC7AwB3sorVpztjMco+kgywzQ5vBSVlQM/ 7C76Y++u3divo5w6jUVoY9tg9432I7dFSZrhXc/rjuMGoII6wSkFS//a2ov3vlkByrre 2UiA== X-Gm-Message-State: ACrzQf3P2lOJuzf70Fd73kXWdoZ0C/XzU81h7/NOwPSTGa0nk4sohAeT YR7XQrPzmCFqcyYs5XoHMis= X-Google-Smtp-Source: AMsMyM6TrjtokzqIwkUb03k3nUmqJiKjkpFTFkUxRBOEiApB78h17GcJW4S7m4Oj6HlZYRYRr+DPDw== X-Received: by 2002:a63:4a18:0:b0:46f:8e43:e959 with SMTP id x24-20020a634a18000000b0046f8e43e959mr2505171pga.184.1667074017687; Sat, 29 Oct 2022 13:06:57 -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 t4-20020a17090ad50400b002130c269b6fsm1409659pju.1.2022.10.29.13.06.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Oct 2022 13:06:56 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#58873: 29.0.50; Fix indent-line-function in tree-sitter From: Yuan Fu In-Reply-To: <87eduqsaw0.fsf@thornhill.no> Date: Sat, 29 Oct 2022 13:06:55 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <271AF531-593E-4E49-A447-B2E783A197FD@gmail.com> References: <87eduqsaw0.fsf@thornhill.no> To: Theodor Thornhill X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 58873 Cc: 58873@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 29, 2022, at 12:11 PM, Theodor Thornhill via Bug reports for = GNU Emacs, the Swiss army knife of text editors = wrote: >=20 >=20 > Hi Yuan! >=20 > There were some regressions with the new indent-line-function - see > attached patch. We need the point, not the indentation, and the > save-excursion is actually needed. >=20 > consider: >=20 > ``` > foo({ > thing: 1, > tho|ng: 2, // <--- point is | > }) > ``` >=20 > if you indent now you want to end up like this: >=20 > ``` > foo({ > thing: 1, > tho|ng: 2, // <--- point is | > }) > ``` >=20 > or if=20 >=20 > ``` > foo({ > thing: 1, > |thong: 2, // <--- point is | > }) > ``` > You want to end up like this: >=20 > ``` > foo({ > thing: 1, > |thong: 2, // <--- point is | > }) > ``` >=20 > This patch addresses this :-) >=20 > In addition there was a bug where the parent-bol didn't indent > correctly, this should also be fixed now. >=20 > Thanks again, Yuan! I applied your change (manually), thanks! Yuan= From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 12 15:33:49 2022 Received: (at 58873-done) by debbugs.gnu.org; 12 Nov 2022 20:33:49 +0000 Received: from localhost ([127.0.0.1]:49117 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otxCH-0004ir-6m for submit@debbugs.gnu.org; Sat, 12 Nov 2022 15:33:49 -0500 Received: from mail-oa1-f43.google.com ([209.85.160.43]:43854) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otxCF-0004ic-65 for 58873-done@debbugs.gnu.org; Sat, 12 Nov 2022 15:33:47 -0500 Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-13c2cfd1126so8778097fac.10 for <58873-done@debbugs.gnu.org>; Sat, 12 Nov 2022 12:33:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=5oQY6XTol9sLq3npVIEICwIuDYtY3TrgM3KMobb692o=; b=T13B7aNpbKzEm3QBrF71Uw3V3Ad81A6b0EF0jEqXmekQcfEnQ+n8kPOYgUUWelYAdu MgRfXz7jvGipxR4lCL9JHxUBMBxxFvE1VY+OE5duCo9CZwNAPjT89TT9mlvjX57o+sYg ck8EvTsnnCUZOslw03oqWU7gXwkR1PEkSVd76NiOBPhNU7JLsfwIz+O+6RjMw6ApxJWx s0dyOC/8sZu/zqPXcsjmAWtVcvsqfG4qtpU/8c2xR8T3K4A8tBHEybXhbVdwOMlBHNkJ Ghdqc7LKQYjBaMA1Z3horvhICOw3dPSUU8gWxyG89L4Pnu6vYq4qbJp01r0RNQPx2uHi 7PGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5oQY6XTol9sLq3npVIEICwIuDYtY3TrgM3KMobb692o=; b=59KzLd3cxdYPH4YlbtauskCBBfuYW19io1lr4B51uEwXEFlj3D9Ey6U2aKMd2DPAZQ G6JhebOjvvpRL2cqLKxWueNdHmMEa5PVTZpBQLkiX0BbdAAlZN50F56rh3OquMnrVf9e LPSJEAe1/z5gNlVDp27GJa1yRmfvnB+uaHsYbjKdgABPrEq9jONPY4lX1EK8G8F917Mp ELAH3g1KuloTOxvCM7tvUAIw8LxVahsnx1jLudUD+ztFwIGyObGBNH91lrepicf+7LY6 VhmlHmJlV6J+dRnkx8ReRXhTPOuY3u6zf2lPbPZ/DMj7SjaTy/OUuBqH+F4eQ4DziT8h VM+Q== X-Gm-Message-State: ANoB5pnsWaBTx6fmjKFrjg+WkU3dwBZTlW+STh5RXmFi6q7fnHuedlpI foAPQE1lEu59T48qGFQxeZrERjuhz6MIPG4I+po= X-Google-Smtp-Source: AA0mqf7G65vSuVj1IDnwV4b/q8BBlyEzj+22hD42ukEhhAUcSbzVeBGGmfq4HIC1YIVLPjkyFm0ngbO8vmvt6CFPT8A= X-Received: by 2002:a05:6870:6c15:b0:13b:8a07:2a1f with SMTP id na21-20020a0568706c1500b0013b8a072a1fmr3964932oab.199.1668285221700; Sat, 12 Nov 2022 12:33:41 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sat, 12 Nov 2022 12:33:41 -0800 From: Stefan Kangas In-Reply-To: <271AF531-593E-4E49-A447-B2E783A197FD@gmail.com> (Yuan Fu's message of "Sat, 29 Oct 2022 13:06:55 -0700") References: <87eduqsaw0.fsf@thornhill.no> <271AF531-593E-4E49-A447-B2E783A197FD@gmail.com> X-Hashcash: 1:20:221112:58873-done@debbugs.gnu.org::3Qs6MMr75A0HV75y:Dzf+ MIME-Version: 1.0 Date: Sat, 12 Nov 2022 12:33:41 -0800 Message-ID: Subject: Re: bug#58873: 29.0.50; Fix indent-line-function in tree-sitter To: Yuan Fu Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 58873-done Cc: 58873-done@debbugs.gnu.org, Theodor Thornhill 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 (-) Yuan Fu writes: > I applied your change (manually), thanks! It seems this was installed but never closed so I'm doing that now. From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 14 04:16:27 2022 Received: (at 58873-done) by debbugs.gnu.org; 14 Nov 2022 09:16:27 +0000 Received: from localhost ([127.0.0.1]:48911 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ouVZr-0003hR-Kj for submit@debbugs.gnu.org; Mon, 14 Nov 2022 04:16:27 -0500 Received: from mail-pj1-f51.google.com ([209.85.216.51]:51793) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ouVZq-0003hF-6P for 58873-done@debbugs.gnu.org; Mon, 14 Nov 2022 04:16:26 -0500 Received: by mail-pj1-f51.google.com with SMTP id o7so9796207pjj.1 for <58873-done@debbugs.gnu.org>; Mon, 14 Nov 2022 01:16:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=8wzfv5nIjv1rWGtp9rBK63i1oo5AU2+yPu4VhpzS7IU=; b=nrczkAiw5kyX9zLCP6+iagzPuKOZ1uG8SCL0oz4+egJVro66HISVUgKRA9gdti0Y6t UjXd5ZXwnEyccHB3dT3pHRNuv8+yajUyjJQGnaKaaPCiOJCgZmzsJCzIClNw89fgWKuK 91X4ilgm0mNCEr9g2ikU7M+MLOrR/NlXup1+pKnLtCs1sbLvmZ0huX+Kw70wnyBAcaBu o0MLQvPHoOb8woYOGred2sk7+S6J0BZIwEt0QUAgsK8+lYDvSbx41h36uuxWdrqe894q KiTNC5vaFLGf8POGmDsuTN7RzKW5H8qhxihdZaImUppmq8qdshrcBbSvgo4OsG5dLSRk gpow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=8wzfv5nIjv1rWGtp9rBK63i1oo5AU2+yPu4VhpzS7IU=; b=N3Mfx8nqwL9Cony+s4Lxg0s+nrda6BwJxft+5MY5XzV1hSqa4PvADPgFcadDkIuPmj HPPlPlnoAJMhdCaB0SofaSqZJnx6hkY6znWPWtLpqZxDlhUrt4a88WnYjxT8e67P96St ieDLcUqc5i5FSuOkLGiCvgE8uNEDYZUqR/1i0u5ltEq8t3n1HmGk9F9NbPfveDTEziC2 Jhp4we7wSkBXwpwDdyyWtrOCha3KCJFxMfER9/OY/JQZ4CS8TKHtYVL2i/a2ynB5Lujg axXNt/PxxSv/fmfkOm4RtWDdEr6byiP7OL0WEDTOIcbx+rAHlBScjUIpt3PduzoLF9pV V8xg== X-Gm-Message-State: ANoB5pliG5YUf05dD/h3BsAgYnnGePVAh3fldh8gprXeGRl2XS0S+59q FWR4GERtiB8AqYqvQRYl1Y0PGFtNrt0= X-Google-Smtp-Source: AA0mqf5rSRhgW+VbVmfTyWHzdMngm27jcUG82cg3xEEMoTxSmDY3Grz4jxObU8HRnBNJmC9+8WOt0Q== X-Received: by 2002:a17:902:ea85:b0:186:8bca:1d50 with SMTP id x5-20020a170902ea8500b001868bca1d50mr12621225plb.158.1668417380371; Mon, 14 Nov 2022 01:16:20 -0800 (PST) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id u12-20020a170902714c00b00186c37270f6sm6878074plm.24.2022.11.14.01.16.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Nov 2022 01:16:19 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#58873: 29.0.50; Fix indent-line-function in tree-sitter From: Yuan Fu In-Reply-To: Date: Mon, 14 Nov 2022 01:16:18 -0800 Content-Transfer-Encoding: 7bit Message-Id: <6AC8DCF3-497E-46A7-A99F-1786BC3D7534@gmail.com> References: <87eduqsaw0.fsf@thornhill.no> <271AF531-593E-4E49-A447-B2E783A197FD@gmail.com> To: Stefan Kangas X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 58873-done Cc: 58873-done@debbugs.gnu.org, Theodor Thornhill 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 Nov 12, 2022, at 12:33 PM, Stefan Kangas wrote: > > Yuan Fu writes: > >> I applied your change (manually), thanks! > > It seems this was installed but never closed so I'm doing that now. Thanks! From unknown Thu Jun 19 12:39:14 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 12 Dec 2022 12:24:14 +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