From unknown Sat Sep 06 09:45:51 2025 X-Loop: help-debbugs@gnu.org Subject: bug#60602: 29.0.60; treesit-simple-indent doesn't work for top-level nodes Resent-From: Piotr Trojanek Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 06 Jan 2023 13:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 60602 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 60602@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.167301246912887 (code B ref -1); Fri, 06 Jan 2023 13:42:02 +0000 Received: (at submit) by debbugs.gnu.org; 6 Jan 2023 13:41:09 +0000 Received: from localhost ([127.0.0.1]:54094 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pDmy5-0003Lm-98 for submit@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 ) id 1pDmy2-0003Lc-In for submit@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 ) id 1pDmy1-0005xH-52 for bug-gnu-emacs@gnu.org; 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 ) id 1pDmxz-0001co-8p for bug-gnu-emacs@gnu.org; Fri, 06 Jan 2023 08:41:04 -0500 Received: by mail-pj1-x102c.google.com with SMTP id v23so1520842pju.3 for ; 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 Date: Fri, 6 Jan 2023 14:40:49 +0100 Message-ID: Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=piotr.trojanek@gmail.com; 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-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.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 From unknown Sat Sep 06 09:45:51 2025 X-Loop: help-debbugs@gnu.org Subject: bug#60602: 29.0.60; treesit-simple-indent doesn't work for top-level nodes Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 06 Jan 2023 14:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60602 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Piotr Trojanek , 60602@debbugs.gnu.org Received: via spool by 60602-submit@debbugs.gnu.org id=B60602.167301691820281 (code B ref 60602); Fri, 06 Jan 2023 14:56:02 +0000 Received: (at 60602) by debbugs.gnu.org; 6 Jan 2023 14:55:18 +0000 Received: from localhost ([127.0.0.1]:54267 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pDo7p-0005H0-SR for submit@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 ) id 1pDo7n-0005FI-Pl for 60602@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@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@yandex.ru> 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 Content-Language: en-US References: From: Dmitry Gutov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.9 (/) 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.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. From unknown Sat Sep 06 09:45:51 2025 X-Loop: help-debbugs@gnu.org Subject: bug#60602: 29.0.60; treesit-simple-indent doesn't work for top-level nodes References: In-Reply-To: Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 09 Jan 2023 03:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60602 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: piotr.trojanek@gmail.com Cc: 60602@debbugs.gnu.org Received: via spool by 60602-submit@debbugs.gnu.org id=B60602.16732340301443 (code B ref 60602); Mon, 09 Jan 2023 03:14:01 +0000 Received: (at 60602) by debbugs.gnu.org; 9 Jan 2023 03:13:50 +0000 Received: from localhost ([127.0.0.1]:35348 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEibe-0000ND-4d for submit@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 ) id 1pEiba-0000Mw-9H for 60602@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@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 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\)) Message-Id: <82D8F312-D95D-446B-B549-E2778ED9AFA0@gmail.com> Date: Sun, 8 Jan 2023 19:13:38 -0800 X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Score: 0.0 (/) 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 (-) Piotr Trojanek 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 From unknown Sat Sep 06 09:45:51 2025 X-Loop: help-debbugs@gnu.org Subject: bug#60602: 29.0.60; treesit-simple-indent doesn't work for top-level nodes Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 20 Jan 2023 21:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60602 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Yuan Fu Cc: Dmitry Gutov , 60602@debbugs.gnu.org, piotr.trojanek@gmail.com Received: via spool by 60602-submit@debbugs.gnu.org id=B60602.167425085731268 (code B ref 60602); Fri, 20 Jan 2023 21:41:02 +0000 Received: (at 60602) by debbugs.gnu.org; 20 Jan 2023 21:40:57 +0000 Received: from localhost ([127.0.0.1]:47351 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pIz84-00088G-IS for submit@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 ) id 1pIz82-000887-UF for 60602@debbugs.gnu.org; Fri, 20 Jan 2023 16:40:56 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=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 In-Reply-To: <82D8F312-D95D-446B-B549-E2778ED9AFA0@gmail.com> (Yuan Fu's message of "Sun, 8 Jan 2023 19:13:38 -0800") References: <82D8F312-D95D-446B-B549-E2778ED9AFA0@gmail.com> Date: Fri, 20 Jan 2023 22:40:51 +0100 Message-ID: <875yd06g0s.fsf_-_@thornhill.no> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) 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 (-) --=-=-= Content-Type: text/plain Hi there! Yuan Fu writes: > Piotr Trojanek 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 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 --=-=-=-- From unknown Sat Sep 06 09:45:51 2025 X-Loop: help-debbugs@gnu.org Subject: bug#60602: 29.0.60; treesit-simple-indent doesn't work for top-level nodes Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 20 Jan 2023 21:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60602 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Theodor Thornhill , Yuan Fu Cc: 60602@debbugs.gnu.org, piotr.trojanek@gmail.com Received: via spool by 60602-submit@debbugs.gnu.org id=B60602.167425114731727 (code B ref 60602); Fri, 20 Jan 2023 21:46:02 +0000 Received: (at 60602) by debbugs.gnu.org; 20 Jan 2023 21:45:47 +0000 Received: from localhost ([127.0.0.1]:47355 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pIzCl-0008Ff-Du for submit@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 ) id 1pIzCj-0008FR-Mj for 60602@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@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@yandex.ru> 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 Content-Language: en-US References: <82D8F312-D95D-446B-B549-E2778ED9AFA0@gmail.com> <875yd06g0s.fsf_-_@thornhill.no> From: Dmitry Gutov In-Reply-To: <875yd06g0s.fsf_-_@thornhill.no> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.9 (/) 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.9 (-) On 20/01/2023 23:40, Theodor Thornhill wrote: > You okay with this patch, Piotr and Dmitry? LGTM. From unknown Sat Sep 06 09:45:51 2025 X-Loop: help-debbugs@gnu.org Subject: bug#60602: 29.0.60; treesit-simple-indent doesn't work for top-level nodes Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 20 Jan 2023 21:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60602 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov , Yuan Fu Cc: 60602@debbugs.gnu.org, piotr.trojanek@gmail.com Received: via spool by 60602-submit@debbugs.gnu.org id=B60602.167425157132608 (code B ref 60602); Fri, 20 Jan 2023 21:53:02 +0000 Received: (at 60602) by debbugs.gnu.org; 20 Jan 2023 21:52:51 +0000 Received: from localhost ([127.0.0.1]:47360 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pIzJb-0008Ts-74 for submit@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 ) id 1pIzJY-0008Ti-Ig for 60602@debbugs.gnu.org; Fri, 20 Jan 2023 16:52:49 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=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 In-Reply-To: <5b3502d6-beb5-1255-2075-d8c79a74e24c@yandex.ru> References: <82D8F312-D95D-446B-B549-E2778ED9AFA0@gmail.com> <875yd06g0s.fsf_-_@thornhill.no> <5b3502d6-beb5-1255-2075-d8c79a74e24c@yandex.ru> Date: Fri, 20 Jan 2023 22:52:44 +0100 Message-ID: <8735846fgz.fsf@thornhill.no> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) 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 (-) Dmitry Gutov 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 From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 20 16:58:49 2023 Received: (at control) by debbugs.gnu.org; 20 Jan 2023 21:58:49 +0000 Received: from localhost ([127.0.0.1]:47365 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pIzPN-0000Dc-0x for submit@debbugs.gnu.org; Fri, 20 Jan 2023 16:58:49 -0500 Received: from out2.migadu.com ([188.165.223.204]:35570) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pIzPK-0000DR-Bi for control@debbugs.gnu.org; Fri, 20 Jan 2023 16:58:47 -0500 Date: Fri, 20 Jan 2023 22:58:44 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1674251925; h=from:from:reply-to:subject:subject:date:date:to:to:cc; bh=w1pQifgge+j9l+6Pws2+/NZUaXyGkHWq+Z8F+hhvm/Q=; b=bVEwm8F7EY4DCF4EuPxW8kbQeMdT1YpZfKhmc1Q98FRPRtztcTt1RVO5y002ERhBSdBAac 9XklVLQJgslBlEA03FDRXoCAut8NFIMsW4TJ0+Rxaz/VENqWObgJVWKIjiKH//bHZARiOJ JJXJClHgh032HhPwowkpGQ8V8665ASihmw4B92WhYPMNzermU3qVCxjTLwxm7N4opBofNq ncLgYcGVMw0wcR1R4fQeqLbi5gINK00b+qGO4nhR0Gg8Hpp2AyUnYLTcixeOR2ueynwOED H2FPEoOYm+JMu+4yscHqwYaO8Sz3B1NGuS9o90MNZfbq7wRAAC8nHuQn0s+UvA== To: control@debbugs.gnu.org X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Theodor Thornhill Subject: control message for bug #60602 X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: control 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" Message-Id: X-Spam-Score: -1.0 (-) fixed 60602 30.1 quit From unknown Sat Sep 06 09:45:51 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Piotr Trojanek Subject: bug#60602: closed (Re: bug#60602: 29.0.60; treesit-simple-indent doesn't work for top-level nodes) Message-ID: References: X-Gnu-PR-Message: they-closed 60602 X-Gnu-PR-Package: emacs Reply-To: 60602@debbugs.gnu.org Date: Wed, 06 Sep 2023 00:10:01 +0000 Content-Type: multipart/mixed; boundary="----------=_1693959001-1306-1" This is a multi-part message in MIME format... ------------=_1693959001-1306-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #60602: 29.0.60; treesit-simple-indent doesn't work for top-level nodes which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 60602@debbugs.gnu.org. --=20 60602: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D60602 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1693959001-1306-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 60602-done) by debbugs.gnu.org; 6 Sep 2023 00:09:16 +0000 Received: from localhost ([127.0.0.1]:60031 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdg6d-0000Jq-W0 for submit@debbugs.gnu.org; Tue, 05 Sep 2023 20:09:16 -0400 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]:47372) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdg6a-0000JX-1d for 60602-done@debbugs.gnu.org; Tue, 05 Sep 2023 20:09:14 -0400 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-5008faf4456so4931446e87.3 for <60602-done@debbugs.gnu.org>; Tue, 05 Sep 2023 17:09:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693958945; x=1694563745; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=ZTSTtvGxL4MXYL9pZXUHxsKXGVj9m8QM+ON6Fs0PYis=; b=JyvUDtR6gPV2U8eAP/jSMUPHerlSFfwuZAHLAn/VyiGle0knCSuGc1qTd9FHKB+INV aTDsa4p0fANArodtFgCbHtI96ITab9r+Bdv79tYG7W8oyZDszuGI89J4HER2GvgiPo5v /xqlCgpgBc4AtI9mw9EPMYIMDtONB0RImrePV0FwScUeQhxGMGMsrAxB4L0DIfyFLXP5 N3oKzKHW4dBuZKZO9Lkw3yQz9Ms+gbeQ8ynD+JizAXEG02Ot5I49Kv8Y3ZYOk+FndBLi cNqSYjvaDD4CNMFDGBkFpsQ6RCexbUmtoUfqBCUH4iUzVVNM2CfBTfljNfl00Qak/cnt Bl8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693958945; x=1694563745; 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=ZTSTtvGxL4MXYL9pZXUHxsKXGVj9m8QM+ON6Fs0PYis=; b=CJBf2YB60ziyp2f1KT67GkN0f/2gbIzbYprIXMcNKLQr/B5P6qBMWvcRAPTtUSJLGD q7Ay5nju4dqULjuE7kSrKYHHe5APMRatQAXTThQY4FyHbgZdeJSko8hQAkH5iWq/gtAn P5F1UDDLGGdp76/zeJ8CO2HIgmkKvFbNuCEDYatJ/suO2z4FJrUoaHfh40MwpSeog5bA EL1qjwy3yUKBjaadcWZd320c/1GhrfUIS6lopwQeoh+B8+N9ONf+C4UK2mnso53g5vVz dLU+4bFOcmsPKKMkdZdgqbfzAdrCgL84vxpUQrkfiuhnl6Ppjj0LHvk8KimzDce9ltYE znjg== X-Gm-Message-State: AOJu0YxpdJvBGvDcbZSq01yrzv9XKXBSfAB6kfELdiwyS7a3n4DUyrA/ fPZUnLfgMbq8uOgfcLyQ+z1LoVb9KGsxc0WBil0= X-Google-Smtp-Source: AGHT+IErRdl+jSMEjuH5GQoSppVAJWG1yBf7uEHz7zz+CedW66qXEWMfqLe+henCQ3ZE4SpGhdFQfQDavIRjtz7gmyA= X-Received: by 2002:a05:6512:474:b0:500:a789:cff2 with SMTP id x20-20020a056512047400b00500a789cff2mr972236lfd.19.1693958945375; Tue, 05 Sep 2023 17:09:05 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Tue, 5 Sep 2023 17:09:04 -0700 From: Stefan Kangas In-Reply-To: <8735846fgz.fsf@thornhill.no> (Theodor Thornhill's message of "Fri, 20 Jan 2023 22:52:44 +0100") References: <82D8F312-D95D-446B-B549-E2778ED9AFA0@gmail.com> <875yd06g0s.fsf_-_@thornhill.no> <5b3502d6-beb5-1255-2075-d8c79a74e24c@yandex.ru> <8735846fgz.fsf@thornhill.no> MIME-Version: 1.0 Date: Tue, 5 Sep 2023 17:09:04 -0700 Message-ID: Subject: Re: bug#60602: 29.0.60; treesit-simple-indent doesn't work for top-level nodes To: Theodor Thornhill Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 60602-done Cc: Yuan Fu , 60602-done@debbugs.gnu.org, piotr.trojanek@gmail.com, Dmitry Gutov 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 (-) Theodor Thornhill writes: > Dmitry Gutov 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 This seems to have been fixed already. I'm therefore closing this bug report. If this conclusion is incorrect and this is still an issue, please reply to this email (use "Reply to all" in your email client) and we can reopen the bug report. ------------=_1693959001-1306-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 6 Jan 2023 13:41:09 +0000 Received: from localhost ([127.0.0.1]:54094 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pDmy5-0003Lm-98 for submit@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 ) id 1pDmy2-0003Lc-In for submit@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 ) id 1pDmy1-0005xH-52 for bug-gnu-emacs@gnu.org; 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 ) id 1pDmxz-0001co-8p for bug-gnu-emacs@gnu.org; Fri, 06 Jan 2023 08:41:04 -0500 Received: by mail-pj1-x102c.google.com with SMTP id v23so1520842pju.3 for ; 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 Date: Fri, 6 Jan 2023 14:40:49 +0100 Message-ID: Subject: 29.0.60; treesit-simple-indent doesn't work for top-level nodes To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=piotr.trojanek@gmail.com; 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@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.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 ------------=_1693959001-1306-1--