Theodor Thornhill <theo@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Received: (at 60602) by debbugs.gnu.org; 20 Jan 2023 21:52:51 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jan 20 16:52:51 2023 Received: from localhost ([127.0.0.1]:47360 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pIzJb-0008Ts-74 for submit <at> debbugs.gnu.org; Fri, 20 Jan 2023 16:52:51 -0500 Received: from out2.migadu.com ([188.165.223.204]:30311) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <theo@HIDDEN>) id 1pIzJY-0008Ti-Ig for 60602 <at> debbugs.gnu.org; Fri, 20 Jan 2023 16:52:49 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1674251566; 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: in-reply-to:in-reply-to:references:references; bh=m6mqNBMkkXX4rmOCuCEZoFsz+croL36tzz+NY9GoS80=; b=t3EFsQ7fbC+EjlUC+OGP0uSDH+3e+V/btyXCLhD8T51BoyoQi9ehZZ2xAEogG6Wjq0LT05 BHQd9o5PgC6Td2RTM5xLhdNlJqvGrAiSdolze5DpST2KC/McF2WBFQ1na/wC4KHMiZWVx9 vjTPtg+pmNKj/TnZb3/Fe7oc+a5J4Gx4yxtaD5gzom7Alu7BYxGClVv2zpB+ffifkk6JYo +E/PFazGnDDR5rmjswRGBAFtPwQyLYrzv/IxUzMrekigLCw9bqJHH70kmQP4HIWHjs/JFI sV9bnt7h1VuGn7oCJCOsMUEh/BfikwcX1z9T1n8ZkiUVn4oyyoRaRoT9Yf/k6g== From: Theodor Thornhill <theo@HIDDEN> To: Dmitry Gutov <dgutov@HIDDEN>, Yuan Fu <casouri@HIDDEN> Subject: Re: bug#60602: 29.0.60; treesit-simple-indent doesn't work for top-level nodes In-Reply-To: <5b3502d6-beb5-1255-2075-d8c79a74e24c@HIDDEN> References: <CAGExNxEThMeWwf3R0dWnP8=kVnTopeDK7bupCDp94zHsHVYkoQ@HIDDEN> <82D8F312-D95D-446B-B549-E2778ED9AFA0@HIDDEN> <875yd06g0s.fsf_-_@HIDDEN> <5b3502d6-beb5-1255-2075-d8c79a74e24c@HIDDEN> Date: Fri, 20 Jan 2023 22:52:44 +0100 Message-ID: <8735846fgz.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 60602 Cc: 60602 <at> debbugs.gnu.org, piotr.trojanek@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Dmitry Gutov <dgutov@HIDDEN> writes: > On 20/01/2023 23:40, Theodor Thornhill wrote: >> You okay with this patch, Piotr and Dmitry? > > LGTM. Ok, installing on emacs-29, Thanks, Theo
bug-gnu-emacs@HIDDEN
:bug#60602
; Package emacs
.
Full text available.Received: (at 60602) by debbugs.gnu.org; 20 Jan 2023 21:45:47 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jan 20 16:45:47 2023 Received: from localhost ([127.0.0.1]:47355 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pIzCl-0008Ff-Du for submit <at> debbugs.gnu.org; Fri, 20 Jan 2023 16:45:47 -0500 Received: from mail-wr1-f48.google.com ([209.85.221.48]:46837) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <raaahh@HIDDEN>) id 1pIzCj-0008FR-Mj for 60602 <at> debbugs.gnu.org; Fri, 20 Jan 2023 16:45:46 -0500 Received: by mail-wr1-f48.google.com with SMTP id e3so5952081wru.13 for <60602 <at> debbugs.gnu.org>; Fri, 20 Jan 2023 13:45:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=vNwUJpXLhHEH4WJs3J7Wm7GupD5zEAPDHwgeiHeTNZk=; b=CQiQtqGKShr85osjXznDk0Q+vqHBdCb3qkodkURr6EjizTO7rdVwbiVqGn0t759zJ9 slrROieRAP03dkLFHdHlYC053rX2BrwrHnD+Mr/bY4ZqLSvEDJKiCorMQ1iAS95QRe0f sKPQUK84to8rcop30Oq6LWE4uZzyaglXvMOFF3S+irQvbcClUROdX4C6ACZHefLnuxMC EnKz+iHKYQ5tQHFbNtjEPcDhBaPI7DEEzbCIjPHnhixgMaWbCsHGR9I8ZC8bLm2dbdzA TNnq7ynuIV+u4S1RK6eHEZjOfMs8PVYMmpdml9ivc9JVBg/M+nQfzvRmSvp+YpLsKgMe F+mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vNwUJpXLhHEH4WJs3J7Wm7GupD5zEAPDHwgeiHeTNZk=; b=2S6DS3kHlWi6KyO67BwZd2ZO+NJ4JazvzzVttkwY1lXjKvFGpzL3yFkHxRqDKfCvh5 Hgfgcu/kvZTX08aNvCT27GBiMyajDtotoR2jA970Bv/n/u8Y+lmyiBDXWk0ScZ/pC4v+ tsJl3IQdnihN1/KIUYb/DFOAPkOd5o3xmpCEMg7FGqNokhPklELoHQzQb7cVASCUXttX PCRfp83n2W8enZou+SrohR8kOZGbLXEs6y+uW0bYsfj8372vmMuUkJNRYCrQmYyc0NZI 8QatgpAtTi5jo+ML5TfP3NiDVJT8jfNxO1Y2W3Q0K1/pAtN4KYsnoWGGZd1aSC88KURb gBqA== X-Gm-Message-State: AFqh2kr8mrJNHLcB6PtBO8ivkSydeb4HpbVbzg8i1fMs38TUFL6VHKC7 uqmxL4+UiU7EAgwESYSeupc= X-Google-Smtp-Source: AMrXdXstlArUbFXYN5s2P+N25itb3YHgWiDUkRmgybuYphT1+B5aOtMONnpCQl2nf0sAaHC1YqN6GQ== X-Received: by 2002:adf:dd8e:0:b0:2be:3a65:c868 with SMTP id x14-20020adfdd8e000000b002be3a65c868mr7789033wrl.44.1674251139589; Fri, 20 Jan 2023 13:45:39 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id n16-20020a5d4010000000b002bbed1388a5sm31529235wrp.15.2023.01.20.13.45.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Jan 2023 13:45:38 -0800 (PST) Message-ID: <5b3502d6-beb5-1255-2075-d8c79a74e24c@HIDDEN> Date: Fri, 20 Jan 2023 23:45:36 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#60602: 29.0.60; treesit-simple-indent doesn't work for top-level nodes Content-Language: en-US To: Theodor Thornhill <theo@HIDDEN>, Yuan Fu <casouri@HIDDEN> References: <CAGExNxEThMeWwf3R0dWnP8=kVnTopeDK7bupCDp94zHsHVYkoQ@HIDDEN> <82D8F312-D95D-446B-B549-E2778ED9AFA0@HIDDEN> <875yd06g0s.fsf_-_@HIDDEN> From: Dmitry Gutov <dgutov@HIDDEN> In-Reply-To: <875yd06g0s.fsf_-_@HIDDEN> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.9 (/) X-Debbugs-Envelope-To: 60602 Cc: 60602 <at> debbugs.gnu.org, piotr.trojanek@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.9 (-) On 20/01/2023 23:40, Theodor Thornhill wrote: > You okay with this patch, Piotr and Dmitry? LGTM.
bug-gnu-emacs@HIDDEN
:bug#60602
; Package emacs
.
Full text available.Received: (at 60602) by debbugs.gnu.org; 20 Jan 2023 21:40:57 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jan 20 16:40:57 2023 Received: from localhost ([127.0.0.1]:47351 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pIz84-00088G-IS for submit <at> debbugs.gnu.org; Fri, 20 Jan 2023 16:40:56 -0500 Received: from out-1.mta0.migadu.com ([91.218.175.1]:50949) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <theo@HIDDEN>) id 1pIz82-000887-UF for 60602 <at> debbugs.gnu.org; Fri, 20 Jan 2023 16:40:56 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1674250852; 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: in-reply-to:in-reply-to:references:references; bh=Dts6NQWMgVbHQkzA1+1irYjog2TlV+1NcARQB3yECzk=; b=dpaQ8zlQg3iaNVaOwR7kXDd5HvqLiR0xvz4G0KDBJpD2++B451K4EkU3hYpOes7zz1d259 WFSD9qAQRiWQ2Vv1nfB6pLTxDAw2rY8A/JDKeNHJmiVFqOuBhReCCsRg7wnnIlfABUE8Lo MbiffsOE0Wf1t+tLVeGJ+mJGUKT8Z90TzBF25m0OfLHx1d0BeMFgss5DakVNGxmmdFWHgz X2W9lHE2RQ0HdVxMUropHzsQcjXWPgZZVrHwsg1q/bSZOEStloxMMYXUh9bTcwBCWtea83 2mZjQlb7vQYKN9RLIdjBdgHMVPxwGLXVY2mxcFpnHupZVSASOglutxI9qUqo/Q== From: Theodor Thornhill <theo@HIDDEN> To: Yuan Fu <casouri@HIDDEN> Subject: Re: bug#60602: 29.0.60; treesit-simple-indent doesn't work for top-level nodes In-Reply-To: <82D8F312-D95D-446B-B549-E2778ED9AFA0@HIDDEN> (Yuan Fu's message of "Sun, 8 Jan 2023 19:13:38 -0800") References: <CAGExNxEThMeWwf3R0dWnP8=kVnTopeDK7bupCDp94zHsHVYkoQ@HIDDEN> <82D8F312-D95D-446B-B549-E2778ED9AFA0@HIDDEN> Date: Fri, 20 Jan 2023 22:40:51 +0100 Message-ID: <875yd06g0s.fsf_-_@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 60602 Cc: Dmitry Gutov <dgutov@HIDDEN>, 60602 <at> debbugs.gnu.org, piotr.trojanek@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Hi there! Yuan Fu <casouri@HIDDEN> writes: > Piotr Trojanek <piotr.trojanek@HIDDEN> writes: > >> This problem can be reproduced with a correctly configured c-ts-mode, >> which fails to indent the first line of a code like this, i.e. with >> extra space at the very beginning of file and cursor positioned at >> "main"): >> >> === >> int main (int argc, char *argv[]) >> { >> return 0; >> } >> === >> >> The intent of c-ts-mode--indent-styles is clearly to indent this line >> to 0th column: >> >> (defun c-ts-mode--indent-styles (mode) >> ... >> `(((parent-is "translation_unit") parent-bol 0) >> >> However, when indenting this line treesit-simple-indent is called with >> node=translation_unit and parent=nil. It exits too early and doesn't >> consider any indentation rules: >> >> (defun treesit-simple-indent (node parent bol) >> "..." >> (if (null parent) >> (progn (when treesit--indent-verbose >> (message "PARENT is nil, not indenting")) >> (cons nil nil)) >> >> Note that other tree-sitter modes have similar indentation rules, e.g. >> ruby-ts-mode.el: >> >> ;; Slam all top level nodes to the left margin >> ((parent-is "program") parent 0) >> >> and same for typescript-ts-mode.el: >> >> ((parent-is "program") parent-bol 0) >> >> Perhaps the early exit from treesit-simple-indent could be removed, so >> the indentation rules can decide how to handle a nil parent. > > Now NODE is never the root node, so parent is never nil. I believe this > is the best approach. And personally I think the rule should be > > ((parent-is "program") point-min 0) > > Yuan You okay with this patch, Piotr and Dmitry? Theo --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Use-point-min-to-anchor-top-level-constructs-bug-606.patch From ab13b78f02452e8e1be633593a6792d9f8b6050c Mon Sep 17 00:00:00 2001 From: Theodor Thornhill <theo@HIDDEN> Date: Fri, 20 Jan 2023 22:37:47 +0100 Subject: [PATCH] Use point-min to anchor top-level constructs (bug#60602) * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): New anchor. * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): New anchor. * lisp/progmodes/ruby-ts-mode.el (ruby-ts--indent-rules): New anchor. * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode--indent-rules): New anchor. --- lisp/progmodes/c-ts-mode.el | 2 +- lisp/progmodes/java-ts-mode.el | 2 +- lisp/progmodes/ruby-ts-mode.el | 2 +- lisp/progmodes/typescript-ts-mode.el | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 348d027af1..2370a2c964 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -115,7 +115,7 @@ c-ts-mode--indent-styles "Indent rules supported by `c-ts-mode'. MODE is either `c' or `cpp'." (let ((common - `(((parent-is "translation_unit") parent-bol 0) + `(((parent-is "translation_unit") point-min 0) ((node-is ")") parent 1) ((node-is "]") parent-bol 0) ((node-is "else") parent-bol 0) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 03093e0980..6bcf5d1253 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -69,7 +69,7 @@ java-ts-mode--syntax-table (defvar java-ts-mode--indent-rules `((java - ((parent-is "program") parent-bol 0) + ((parent-is "program") point-min 0) ((node-is "}") (and parent parent-bol) 0) ((node-is ")") parent-bol 0) ((node-is "]") parent-bol 0) diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index f0337775d5..809f0da2a0 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -535,7 +535,7 @@ ruby-ts--indent-rules (let ((common `( ;; Slam all top level nodes to the left margin - ((parent-is "program") parent 0) + ((parent-is "program") point-min 0) ;; Do not indent here docs or the end. Not sure why it ;; takes the grand-parent but ok fine. diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index f7bf7ed7e4..c0c18d65cc 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -69,7 +69,7 @@ typescript-ts-mode--indent-rules "Rules used for indentation. Argument LANGUAGE is either `typescript' or `tsx'." `((,language - ((parent-is "program") parent-bol 0) + ((parent-is "program") point-min 0) ((node-is "}") parent-bol 0) ((node-is ")") parent-bol 0) ((node-is "]") parent-bol 0) -- 2.34.1 --=-=-=--
bug-gnu-emacs@HIDDEN
:bug#60602
; Package emacs
.
Full text available.Received: (at 60602) by debbugs.gnu.org; 9 Jan 2023 03:13:50 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 08 22:13:50 2023 Received: from localhost ([127.0.0.1]:35348 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pEibe-0000ND-4d for submit <at> debbugs.gnu.org; Sun, 08 Jan 2023 22:13:50 -0500 Received: from mail-pj1-f52.google.com ([209.85.216.52]:34753) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <casouri@HIDDEN>) id 1pEiba-0000Mw-9H for 60602 <at> debbugs.gnu.org; Sun, 08 Jan 2023 22:13:48 -0500 Received: by mail-pj1-f52.google.com with SMTP id cp9-20020a17090afb8900b00226a934e0e5so10132419pjb.1 for <60602 <at> debbugs.gnu.org>; Sun, 08 Jan 2023 19:13:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=/2df08FUiI+Xl4bXzpk9ibYuEhsCX3QZ4xZXaYmYKGo=; b=DwLbDiQQkUk9I2iIzzG7tLsFAEbJ01LFe0b2zY4ryBP5mY9WERbg0Dzb2mH6KkNws1 eeLAQKZZJP+4CUKucyYCx4Qs6ZnQKzgDalr0cQA/O5yK8AinstmkWzc0F1QgOMEEevIW 0/fs3NPVdM9vIZTr/mkh/FhD3lgu2zpBh5eaYC5IShdpLS1RGqNyROJQiRYdCQfwQrtu KFsPRhZN5eXRb7nK4RR6PLbIzQGvUo2TNxqyQtumRCd3jQ/0+mAcHfaJY/Cy2wnrlG/M sAPEvzsbWSUazQg5cdDykp5ZV3d3/RZIkJne3o9F7d8bXL/1keAcH5H/CNapX5r+nulh mizw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/2df08FUiI+Xl4bXzpk9ibYuEhsCX3QZ4xZXaYmYKGo=; b=KZYK86tbkDihcNF3fQvY2Parq4MDye/3dzggUWpa5WaKqScO6gHbpuJ5Ec2+V0Tqdz 8jcVjPlpWn/mQ1x4iJlQjH/DtGEqyZ3rVCxbySfyNXiFiwajb3MzWmlaceqUXHpt62Xx kulnk8XdmMABzN3XGljnuxpep+mMT/2+v4YT+XsNwybYszSFUU5OGdf5NOFHKMpGSSP6 TokobWoTZ3zD6Add02wlbni/AzkAlX0wvLigJ0mSH3R1qLz7o5gOSGupqSqklmYvfWwG dmK+x6dLLuhrabM0JHlT9/AT8ffsvGHs2y1mUJPOTkBLGFvRv5czh7X/KlHUKzlYj839 kHJw== X-Gm-Message-State: AFqh2kp6Bw0hVMYlDLZGm1Q6jlcIWOg2y068ENsjivsFq/+4jMN3Wz51 SEIMCUoV5qNHO/7XsuEFMVk= X-Google-Smtp-Source: AMrXdXuCQJar1+XUv/Bf8rw+LWCjOBhKAv+T9OEAHle4PBaLPp+b/d7r4kX31ayKfHdiK3d6xP86Dw== X-Received: by 2002:a17:902:eb91:b0:18f:b812:5df7 with SMTP id q17-20020a170902eb9100b0018fb8125df7mr72381102plg.28.1673234020261; Sun, 08 Jan 2023 19:13:40 -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 o6-20020a170902d4c600b0019280bac7a6sm4771255plg.152.2023.01.08.19.13.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Jan 2023 19:13:39 -0800 (PST) From: Yuan Fu <casouri@HIDDEN> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: bug#60602: 29.0.60; treesit-simple-indent doesn't work for top-level nodes Message-Id: <82D8F312-D95D-446B-B549-E2778ED9AFA0@HIDDEN> Date: Sun, 8 Jan 2023 19:13:38 -0800 To: piotr.trojanek@HIDDEN X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 60602 Cc: 60602 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Piotr Trojanek <piotr.trojanek@HIDDEN> writes: > This problem can be reproduced with a correctly configured c-ts-mode, > which fails to indent the first line of a code like this, i.e. with > extra space at the very beginning of file and cursor positioned at > "main"): > > === > int main (int argc, char *argv[]) > { > return 0; > } > === > > The intent of c-ts-mode--indent-styles is clearly to indent this line > to 0th column: > > (defun c-ts-mode--indent-styles (mode) > ... > `(((parent-is "translation_unit") parent-bol 0) > > However, when indenting this line treesit-simple-indent is called with > node=translation_unit and parent=nil. It exits too early and doesn't > consider any indentation rules: > > (defun treesit-simple-indent (node parent bol) > "..." > (if (null parent) > (progn (when treesit--indent-verbose > (message "PARENT is nil, not indenting")) > (cons nil nil)) > > Note that other tree-sitter modes have similar indentation rules, e.g. > ruby-ts-mode.el: > > ;; Slam all top level nodes to the left margin > ((parent-is "program") parent 0) > > and same for typescript-ts-mode.el: > > ((parent-is "program") parent-bol 0) > > Perhaps the early exit from treesit-simple-indent could be removed, so > the indentation rules can decide how to handle a nil parent. Now NODE is never the root node, so parent is never nil. I believe this is the best approach. And personally I think the rule should be ((parent-is "program") point-min 0) Yuan
bug-gnu-emacs@HIDDEN
:bug#60602
; Package emacs
.
Full text available.Received: (at 60602) by debbugs.gnu.org; 6 Jan 2023 14:55:18 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jan 06 09:55:18 2023 Received: from localhost ([127.0.0.1]:54267 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pDo7p-0005H0-SR for submit <at> debbugs.gnu.org; Fri, 06 Jan 2023 09:55:18 -0500 Received: from mail-wm1-f41.google.com ([209.85.128.41]:38793) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <raaahh@HIDDEN>) id 1pDo7n-0005FI-Pl for 60602 <at> debbugs.gnu.org; Fri, 06 Jan 2023 09:55:16 -0500 Received: by mail-wm1-f41.google.com with SMTP id fm16-20020a05600c0c1000b003d96fb976efso3702138wmb.3 for <60602 <at> debbugs.gnu.org>; Fri, 06 Jan 2023 06:55:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=PHK7lxMbJ+ER13fun36CZjyJr0E97f54CbnKKg28328=; b=IXilvRCxaYBEEBvBfbePINj7uL+SQxNJOiAHVMSj9g94pfj2/J/NBT7WkJmYvIfiz/ XrZBVNzP1oa18EX6bxE3qu5kFuwXoYhbciTS9Rj6UuQyM59WFlUIj8e+drs8SBroylHj L4TgC7rP9bV9k1lpZfhWioOh1zLJjRS8dsjo7KXK5w427n2DknEd0CwY4+hN967PDTWr E7FqOSQOKBkRcPEFeKpaI5c7NhMykVG9LQDxOJfpB7f0E99QPKfYdjQTLjZxz2OzgCEV 74K8v1Rho+mzCsE8FnQG5GYoDklco1yEPEDHpqmvM+iQuqFx8esodb07NeBIYi05FUDC rSiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PHK7lxMbJ+ER13fun36CZjyJr0E97f54CbnKKg28328=; b=3U+7Fc06NkVVDVKsi+Jq5R5b6j+BGG55D5bIbAEdGq/g6o7eLVw/ty+goBeMUwH475 deqR2vzuVw+1fJpwqLmRqOH5WDT2UnDDgl2at0UxR0U7d5WZ1SQSvZmZdyeeuHL82WrR 0/QkYnEoMUZeK9VyXl5WOJrfmONLcK4qetf/alHQc3j11a+URezjFWk9+xTnac1eA0XD 8sRUIPPrg3AuRGGdVFZm729njAyEJ/Vc1j7JIhWbEuauFjDeScypSA0DjXpbPgefqN59 AqW0YpoQrC5NYm4uMhYwH3Ra37M8e+xUkQt6cquQob/bcHATMlt396Uk5d5oOonEcsIp Y5tg== X-Gm-Message-State: AFqh2kpap8Ew3jCOgq3/sQ/hzblQCOeUi1KjP03tdUPzo/UzZ6+7HMK+ J0uuFTTqez3dWGGOL1DVeVw= X-Google-Smtp-Source: AMrXdXuTAisa+g/yLbIiRCeJnS2FGo+q7dkWLe/iIZ+5Np9goeaVGCIWH3yOVJpc0tNDpXuMwsl/Zw== X-Received: by 2002:a05:600c:254:b0:3d2:2c86:d2b2 with SMTP id 20-20020a05600c025400b003d22c86d2b2mr48898859wmj.24.1673016909891; Fri, 06 Jan 2023 06:55:09 -0800 (PST) Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id bg24-20020a05600c3c9800b003cfa3a12660sm15185755wmb.1.2023.01.06.06.55.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Jan 2023 06:55:09 -0800 (PST) Message-ID: <93abc08e-33c8-75f2-aa71-5add3f0c836c@HIDDEN> Date: Fri, 6 Jan 2023 16:55:07 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: bug#60602: 29.0.60; treesit-simple-indent doesn't work for top-level nodes Content-Language: en-US To: Piotr Trojanek <piotr.trojanek@HIDDEN>, 60602 <at> debbugs.gnu.org References: <CAGExNxEThMeWwf3R0dWnP8=kVnTopeDK7bupCDp94zHsHVYkoQ@HIDDEN> From: Dmitry Gutov <dgutov@HIDDEN> In-Reply-To: <CAGExNxEThMeWwf3R0dWnP8=kVnTopeDK7bupCDp94zHsHVYkoQ@HIDDEN> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.9 (/) X-Debbugs-Envelope-To: 60602 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.9 (-) On 06/01/2023 15:40, Piotr Trojanek wrote: > Note that other tree-sitter modes have similar indentation rules, e.g. > ruby-ts-mode.el: > > ;; Slam all top level nodes to the left margin > ((parent-is "program") parent 0) > > and same for typescript-ts-mode.el: > > ((parent-is "program") parent-bol 0) Probably relatedly, in ruby-ts-mode (and probably others), when the first child of a block node (e.g. sequence statements) is reindended, it's often that its parent is passed to the rules, not that actual child. Which makes the indentation rules irregular, forcing us to add extra cases. Note this comment at ruby-ts-mode:635: ;; well as statements. Note that the first statement of a ;; body_statement hits the node as "body_statement" and not ;; as the assignment, etc. and the rules below. Not sure if there is an easy fix for this, however, given that both body_statement and its first child start at the same position. Perhaps a translation step before the rules are applied? E.g. in case of Ruby body_statement or block_body we would translate to the first child node first, to then apply the rules to it. Same for 'program', I guess.
bug-gnu-emacs@HIDDEN
:bug#60602
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 6 Jan 2023 13:41:09 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jan 06 08:41:09 2023 Received: from localhost ([127.0.0.1]:54094 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pDmy5-0003Lm-98 for submit <at> debbugs.gnu.org; Fri, 06 Jan 2023 08:41:09 -0500 Received: from lists.gnu.org ([209.51.188.17]:52014) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <piotr.trojanek@HIDDEN>) id 1pDmy2-0003Lc-In for submit <at> debbugs.gnu.org; Fri, 06 Jan 2023 08:41:07 -0500 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 <piotr.trojanek@HIDDEN>) id 1pDmy1-0005xH-52 for bug-gnu-emacs@HIDDEN; Fri, 06 Jan 2023 08:41:06 -0500 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <piotr.trojanek@HIDDEN>) id 1pDmxz-0001co-8p for bug-gnu-emacs@HIDDEN; Fri, 06 Jan 2023 08:41:04 -0500 Received: by mail-pj1-x102c.google.com with SMTP id v23so1520842pju.3 for <bug-gnu-emacs@HIDDEN>; Fri, 06 Jan 2023 05:41:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=JWyFPHM00IX+aRK9vjgZKpBq6+ztu8IBPUaW74H/ofI=; b=M6RN/QYw4Xrz4EDtIYN8PhoZZH5G0zEWbR0U/l/zIYEGAkVIIFZvAvoO4zhKjOQ3lY 8TJNkX+cYLRrUKUQqlM1jOmjFu8osOZcUTxbwqzmeGMyxl0thDqlc22yqfAA6ChebP/B Kqe+LWFmgK8EnBI4WbRVrA0pa+sBhkZA2UbE0Yg8rbS7N7QGeUfE85hDvc1x3QiztpXa ZL5BRDSmGj0Z08bTy0MFd6f7KkDdx96z67+wJTKON3GCutvscTUJN16sO2LyIxuzkwAq ZyP9pn5LMSjpcpzRWd7Qp1aJvRIB8DLd/+ys7VVmSdYH0DK/kWzMv2myz72O61mvQgmA O6TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=JWyFPHM00IX+aRK9vjgZKpBq6+ztu8IBPUaW74H/ofI=; b=0nnDx+Wpd8ber8udGAWGFKmmfchsA2FbOJi/d8+qsSfnUEMBvljW7acT+JXON1BZHO LRAIY96WePRVCrrC9ZVktNRiBb8Gfn86Hx19YFe5h1BmWP8sKtQxtoFyLdO/tYRJG6/+ aC5VTQ2+o+dv+b3cM5T7Y4pb+eo6TXGC4+GBxQAyt5or+oz5vvXm/U3elEFMbc/6jpkh 6l1S6GBnuMIkeZK/kZ+1YZ0Iam2AvyBEtFDOS+y41zUxU0Uwgtl0i/jDY8pK6kuJcN5C fgZf7XW09MupHAOA2bTefK4z4qJoC2AaMIKkDAsdFfKxyQgftLOwWQhmlG+7+7m3XIr6 jTcg== X-Gm-Message-State: AFqh2koNEj+YnXsnH5do9oTrmi2yty10VPVthTf9KkZK14WzGRLC/+eS xFA3iVUGwTfevyWUmxx7Q5JvJe6dzD9reTVmvlib0IWYz58= X-Google-Smtp-Source: AMrXdXs7JPFLwc8pSMJpa/oUoeJPD9GHC8eV75CcvJ8+wHvTiufuqyDmmGf+MWdOXdzuCX1+l/+NM1vcr+q4NGKYQEk= X-Received: by 2002:a17:902:d355:b0:189:97e9:c8e with SMTP id l21-20020a170902d35500b0018997e90c8emr2391137plk.63.1673012460908; Fri, 06 Jan 2023 05:41:00 -0800 (PST) MIME-Version: 1.0 From: Piotr Trojanek <piotr.trojanek@HIDDEN> Date: Fri, 6 Jan 2023 14:40:49 +0100 Message-ID: <CAGExNxEThMeWwf3R0dWnP8=kVnTopeDK7bupCDp94zHsHVYkoQ@HIDDEN> Subject: 29.0.60; treesit-simple-indent doesn't work for top-level nodes To: bug-gnu-emacs@HIDDEN Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=piotr.trojanek@HIDDEN; helo=mail-pj1-x102c.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.3 (--) This problem can be reproduced with a correctly configured c-ts-mode, which fails to indent the first line of a code like this, i.e. with extra space at the very beginning of file and cursor positioned at "main"): === int main (int argc, char *argv[]) { return 0; } === The intent of c-ts-mode--indent-styles is clearly to indent this line to 0th column: (defun c-ts-mode--indent-styles (mode) ... `(((parent-is "translation_unit") parent-bol 0) However, when indenting this line treesit-simple-indent is called with node=translation_unit and parent=nil. It exits too early and doesn't consider any indentation rules: (defun treesit-simple-indent (node parent bol) "..." (if (null parent) (progn (when treesit--indent-verbose (message "PARENT is nil, not indenting")) (cons nil nil)) Note that other tree-sitter modes have similar indentation rules, e.g. ruby-ts-mode.el: ;; Slam all top level nodes to the left margin ((parent-is "program") parent 0) and same for typescript-ts-mode.el: ((parent-is "program") parent-bol 0) Perhaps the early exit from treesit-simple-indent could be removed, so the indentation rules can decide how to handle a nil parent. In GNU Emacs 29.0.60 (build 4, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0) of 2023-01-06 built on mobile Repository revision: 7420b6dcc379617ca9691049c16bfb2d158f9496 Repository branch: emacs-29 Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Debian GNU/Linux 11 (bullseye) Configured using: 'configure --prefix=/opt/emacs-29 --with-tree-sitter' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB
Piotr Trojanek <piotr.trojanek@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#60602
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.