From: Perry Smith <pedz@easesoftware.com>
To: emacs-devel <emacs-devel@gnu.org>
Subject: More Tree Sitter Questions / Problems.
Date: Wed, 14 Dec 2022 14:43:09 -0600 [thread overview]
Message-ID: <365D3BA2-298F-4B99-9707-FE8BC658701F@easesoftware.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 1341 bytes --]
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
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).
While I think the new way is ultra cool… I am 100% positive I am in the vast minority on this topic. Most prefer to have it indented the old way.
I’ve developed two new rules but I believe these will not solve the issue 100%:
((ancestor-is "parenthesized_statements") (ancestor "parenthesized_statements") 1)
((ancestor-is "assignment") (ancestor "assignment") ruby-ts-mode-indent-offset)
I also wrote ancestor-is and ancestor so now I get:
eddie = (a + b *
c * d + 12)
bobby = a + b *
c * d + 12
I fear as I test and play with this more I’m going to need more rules to catch all the cases where a line starts with a term of an arithmetic expression.
Perry
[-- Attachment #1.2: Type: text/html, Size: 3064 bytes --]
[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next reply other threads:[~2022-12-14 20:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-14 20:43 Perry Smith [this message]
2022-12-14 21:15 ` More Tree Sitter Questions / Problems 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
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=365D3BA2-298F-4B99-9707-FE8BC658701F@easesoftware.com \
--to=pedz@easesoftware.com \
--cc=emacs-devel@gnu.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).