unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 61502@debbugs.gnu.org, casouri@gmail.com, pankaj@codeisgreat.org
Subject: bug#61502: 29.0.60; c-ts-mode auto-indent not working
Date: Wed, 15 Feb 2023 13:41:47 +0100	[thread overview]
Message-ID: <873577qewk.fsf@thornhill.no> (raw)
In-Reply-To: <838rgzce0c.fsf@gnu.org>

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Theodor Thornhill <theo@thornhill.no>
>> Cc: pankaj@codeisgreat.org, casouri@gmail.com, 61502@debbugs.gnu.org
>> Date: Tue, 14 Feb 2023 21:21:33 +0100
>> 
>> int
>> main
>> {
>>   for (;;)|
>> ```
>> 
>> Now type RET
>> 
>> ```
>> int
>> main
>> {
>>   for (;;)
>> |
>> ```
>> 
>> Now type {
>> 
>> ```
>> int
>> main
>> {
>>   for (;;)
>>     {|
>> ```
>> 
>> Now type RET
>> 
>> ```
>> int
>> main
>> {
>>   for (;;)
>>     {
>> |
>> ```
>> 
>> Which is what I consider a little confusing.  We get different
>> indentation with and without the closed scope.
>
> Any idea why it doesn't choose the 'for' node?  That's what a naïve
> user would expect, I think.

That's what any user should expect, IMO. It's due to
treesit-node-on. See its docstring:

  "Return the smallest node covering BEG to END.

BEWARE!  Calling this function on an empty line that is not
inside any top-level construct (function definition, etc.) most
probably will give you the root node, because the root node is
the smallest node that covers that empty line.  You probably want
to use `treesit-node-at' instead.

Return nil if none was found.  If NAMED is non-nil, only look for
named node.

If PARSER-OR-LANG is a parser, use that parser; if PARSER-OR-LANG
is a language, find the first parser for that language in the
current buffer, or create one if none exists; If PARSER-OR-LANG
is nil, try to guess the language at BEG using `treesit-language-at'."


Rather selecting the first node "above" point sounds more reasonable?

Theo





  reply	other threads:[~2023-02-15 12:41 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-14  4:36 bug#61502: 29.0.60; c-ts-mode auto-indent not working Pankaj Jangid
2023-02-14 13:16 ` Eli Zaretskii
2023-02-14 19:41   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-14 20:02     ` Eli Zaretskii
2023-02-14 20:21       ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-15 12:24         ` Eli Zaretskii
2023-02-15 12:41           ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-02-15 13:35             ` Dmitry Gutov
2023-02-15 14:03             ` Eli Zaretskii
2023-02-15 14:21               ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-15 14:27                 ` Eli Zaretskii
2023-02-15 14:53                   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-15 15:02                     ` Eli Zaretskii
2023-02-15 15:48                       ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-15 15:57                         ` Dmitry Gutov
2023-02-15 17:11                           ` Eli Zaretskii
2023-02-15 17:57                             ` Dmitry Gutov
2023-02-15 18:11                               ` Eli Zaretskii
2023-02-15 18:18                                 ` Dmitry Gutov
2023-02-15 17:09                         ` Eli Zaretskii
2023-02-15 17:14                           ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-15 17:30                             ` Eli Zaretskii
2023-02-15 17:52                               ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-14 20:59     ` Dmitry Gutov
2023-02-14 21:00       ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-15  0:12         ` Dmitry Gutov
2023-02-14 23:57     ` Dmitry Gutov
2023-02-15  6:07       ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors

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=873577qewk.fsf@thornhill.no \
    --to=bug-gnu-emacs@gnu.org \
    --cc=61502@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=eliz@gnu.org \
    --cc=pankaj@codeisgreat.org \
    --cc=theo@thornhill.no \
    /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).