all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Perry Smith <pedz@easesoftware.com>, emacs-devel <emacs-devel@gnu.org>
Subject: Re: More Tree Sitter Questions / Problems.
Date: Mon, 26 Dec 2022 18:24:27 +0200	[thread overview]
Message-ID: <0da3ad1b-032d-ac8c-6f0a-ca2353b34cff@yandex.ru> (raw)
In-Reply-To: <365D3BA2-298F-4B99-9707-FE8BC658701F@easesoftware.com>

Hi Perry,

On 14/12/2022 22:43, Perry Smith wrote:
> All three of ruby-mode, java-mode, and c-mode indent a simple arithmetic 
> expression broken into lines like this:
> 
> foodog = 12 + 4 *
>      18 * 99 + 8
> 
> I think this is the Java sample which has the indent set to 4.  I’ll 
> call this “the old way”.
> 
> All three of ruby-ts-mode, java-ts-mode, and c-ts-mode indent it like this:
> 
> variable = 12 + 4 *
>                  18 * 99 + 8

First of all, this is IMO not too terrible, as it shows the user how the 
code is parsed, which can be helpful on different occasions.

And as apparent from practice, people who don't like this behavior (e.g. 
Rubocop frowns on it) will just break the line after "=". Seems like the 
different indentation behaviors across different editors (when the team 
uses several ones) converge on this practice anyway.

> In Ruby’s case, this rule is doing it:
> 
>             ((parent-is "binary") first-sibling 0)
> 
> If I comment that rule out, then no rule hits and so there is no indent 
> (the line is left unchanged no matter how it is indented).

As luck would have it, I'm finishing work on a feature request for 
ruby-mode for a user option which switches indentation from this sort of 
AST-aware to simpler continuations. See the latest patch in debbugs#60186.

Further, have you looked into supporting/being more-or-less compatible 
with existing indentation-related options in ruby-mode? At least those 
that affect SMIE.

It should be helpful to synchronize, both to provide a straightforward 
upgrade path for existing users, and to ensure good experience for those 
who don't build tree-sitter yet, and for users of older Emacs.



      parent reply	other threads:[~2022-12-26 16:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-14 20:43 More Tree Sitter Questions / Problems Perry Smith
2022-12-14 21:15 ` Stefan Monnier
2022-12-14 23:22   ` Perry Smith
2022-12-14 23:48     ` Yuan Fu
2022-12-14 23:53     ` Stefan Monnier
2022-12-15  6:56     ` Eli Zaretskii
2022-12-26 16:28   ` Dmitry Gutov
2022-12-15  6:05 ` Yuri Khan
2022-12-26 16:24 ` Dmitry Gutov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0da3ad1b-032d-ac8c-6f0a-ca2353b34cff@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=pedz@easesoftware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.