GNU bug report logs - #60602
29.0.60; treesit-simple-indent doesn't work for top-level nodes

Previous Next

Package: emacs;

Reported by: Piotr Trojanek <piotr.trojanek <at> gmail.com>

Date: Fri, 6 Jan 2023 13:42:02 UTC

Severity: normal

Found in version 29.0.60

Fixed in version 30.1

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Piotr Trojanek <piotr.trojanek <at> gmail.com>, 60602 <at> debbugs.gnu.org
Subject: bug#60602: 29.0.60; treesit-simple-indent doesn't work for top-level nodes
Date: Fri, 6 Jan 2023 16:55:07 +0200
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.




This bug report was last modified 1 year and 338 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.