unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Dmitry Gutov <dmitry@gutov.dev>
Cc: "theodor thornhill" <theo@thornhill.no>,
	62717@debbugs.gnu.org, "Daniel Martín" <mardani29@yahoo.es>,
	"João Távora" <joaotavora@gmail.com>,
	acm@muc.de, "Eli Zaretskii" <eliz@gnu.org>
Subject: bug#62717: 29.0.60; c-ts-mode does not indent the first line in a function after RET
Date: Mon, 10 Apr 2023 14:04:33 -0700	[thread overview]
Message-ID: <FB19C832-49BC-4B1A-8721-73B12CBBED6E@gmail.com> (raw)
In-Reply-To: <8a461864-23dc-66af-2f19-c812811330b6@gutov.dev>



> On Apr 9, 2023, at 5:36 PM, Dmitry Gutov <dmitry@gutov.dev> wrote:
> 
> On 09/04/2023 20:37, Eli Zaretskii wrote:
>>> Date: Sun, 9 Apr 2023 19:33:20 +0300
>>> Cc:mardani29@yahoo.es,theo@thornhill.no,casouri@gmail.com,
>>>  62717@debbugs.gnu.org,joaotavora@gmail.com,acm@muc.de
>>> From: Dmitry Gutov<dmitry@gutov.dev>
>>> 
>>>> If the patch solves some of the problems, passes the test suite, and
>>>> doesn't introduce any regressions you see, I think you should install
>>>> it (unless someone here objects).
>>> With this kind of change, it's hard to judge regression potential in
>>> advance. I don't really write C/C++ myself with any regularity. And our
>>> test suite doesn't really work incomplete parse trees, I think.
>>> 
>>> So if we want this in emacs-29, I think someone interested should try
>>> running with this patch applied, at least for a little bit. Maybe just
>>> wait for a couple of days, if Daniel is testing it already.
>> The pretest will be out VSN.  Maybe you should install this, and we
>> can then back it out if people complain.  FWIW, I intend to use only
>> c-ts-mode when I the pretest is out, so if there are regressions, I
>> think I will see it soon enough.
> 
> Okay, SGTM. I've pushed the patch to emacs-29.
> 
> Note that there remains a bunch of more complex cases that don't indent well while there are no closing braces in the buffer.
> 
> Examples:
> 
>  int main() {
>    for (;;) {<RET>
> 
> (including every variation where some chars are deleted from the end of the second line), or
> 
>  int main() {
>    if (2 == 2)<RET>
> 
> or
> 
>  int main() {
>    if (2 == 2)
>      foo();
>    else<RET>
> 
> etc.
> 
> Enumerating every such case to create a special indentation logic seems a little tiring. Though if 2-3 of them are determined to be the most important ones, that might be doable.
> 
> But again, as long as there is at least one '}' after point, though, indentation in all of these cases improves. Though perhaps not ideally sometimes (e.g. for parenless if/else clauses the indentation starts out without the additional level).
> 
> Anyway, the case described in the report should now be working. Whether to close the bug or not, it's up to you and other interested parties.

Thanks for working on this. Maybe we can incorporate the indent.scm method by adding another indent engine alongside the current “simple-indent”. 

Yuan




  reply	other threads:[~2023-04-10 21:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <m1355ba2xr.fsf.ref@yahoo.es>
2023-04-07 19:48 ` bug#62717: 29.0.60; c-ts-mode does not indent the first line in a function after RET Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-08  1:57   ` Dmitry Gutov
2023-04-08 18:37     ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-09  0:20       ` Dmitry Gutov
2023-04-09  5:19         ` Eli Zaretskii
2023-04-09 16:33           ` Dmitry Gutov
2023-04-09 17:37             ` Eli Zaretskii
2023-04-10  0:36               ` Dmitry Gutov
2023-04-10 21:04                 ` Yuan Fu [this message]
2023-04-09 11:05         ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-09 16:30           ` 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=FB19C832-49BC-4B1A-8721-73B12CBBED6E@gmail.com \
    --to=casouri@gmail.com \
    --cc=62717@debbugs.gnu.org \
    --cc=acm@muc.de \
    --cc=dmitry@gutov.dev \
    --cc=eliz@gnu.org \
    --cc=joaotavora@gmail.com \
    --cc=mardani29@yahoo.es \
    --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).