all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Konstantin Kharlamov <hi-angel@yandex.ru>
To: Theodor Thornhill <theo@thornhill.no>,
	emacs-devel@gnu.org, Po Lu <luangruo@yahoo.com>,
	Eli Zaretskii <eliz@gnu.org>
Cc: Holger Schurig <holgerschurig@gmail.com>
Subject: Re: tree-sitter: conceptional problem solvable at Emacs' level?
Date: Sun, 16 Apr 2023 22:21:03 +0300	[thread overview]
Message-ID: <4b31fd663886857221ec88cec2b0ae6644cf94b6.camel@yandex.ru> (raw)
In-Reply-To: <0768E0D7-6D58-40AC-A1D4-784C27CE0D7F@thornhill.no>

On Sat, 2023-02-11 at 07:51 +0100, Theodor Thornhill wrote:
>
>
> On 11 February 2023 07:36:26 CET, Konstantin Kharlamov <hi-angel@yandex.ru>
> wrote:
> > On Sat, 2023-02-11 at 09:25 +0300, Konstantin Kharlamov wrote:
> > > On Sat, 2023-02-11 at 10:17 +0800, Po Lu wrote:
> > > > Eli Zaretskii <eliz@gnu.org> writes:
> > > >
> > > > > However, I meant the IDEs which are using tree-sitter and support
> > > > > developing C/C++ programs.  I believe some do.
> > > >
> > > > I think most of those have similar problems supporting macros.
> > > > Who knows their names? I may be able to ask some of their users.
> > >
> > > From my experience on and off work, there are just two IDEs (as in, not
> > > editors)
> > > used most widely for C++ code: QtCreator and Visual Studio. The first you
> > > discussed, the second is proprietary.
> > >
> > > Then again, people most often code in C++ and C with text editors, in that
> > > case
> > > popular choices from my experience: Sublime Text and VS Code. These two
> > > have
> > > don't use tree-sitter either.
> >
> > I installed Sublime Text on my Archlinux and tested with the C++ code OP
> > posted.
> >
> > What I see is that ST does seem confused about indentation, while trying to
> > make
> > a newline right after `slots:` line.
> >
> > However, if you try to make a newline after the `void someSlot() {};` line,
> > it
> > will use the indentation used on the previous line.
> >
> > The default cc-mode in Emacs works similarly. The cc-ts-mode on the other
> > hand
> > doesn't make use of the previous indentation, and I think it should. It
> > would
> > resolve that problem and others, because in my experience it happens very
> > often
> > in C and C++ code that you want some custom indentation level, so you just
> > make
> > one and you expect the editor to keep it while creating more new lines.
> >
>
> That last statement sounds easily solvable. Can you send me a short example
> describing exactly what you want in a code snippet and I'll add it.
>
> Thanks,
> Theo

Incidentally, I'm reading Stefan Monnier's paper presenting SMIE¹, and it has the
following example:

> […] It also means that the indentation code should strive to obey previous choices
> that the user made. For example if the user wants to indent its code in the
> following unconventional way:
>
>  longfunctionname(argument1, argument2,
>                      argument3,
>                      argument4);
>
> while the user should not be surprised if the auto-indenter tries to align
> ‘argument3’ with ‘argument1’, it would be reasonable for them to expect that
> ‘argument4’ stays put by simply aligning it with its nearest sibling rather than
> with the earlier ‘argument1’.

That is to say: yeah, the previous indentation level should be used by default if 
present.

1: https://arxiv.org/abs/2006.03103




  parent reply	other threads:[~2023-04-16 19:21 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-09  8:09 tree-sitter: conceptional problem solvable at Emacs' level? Holger Schurig
2023-02-09  8:17 ` Po Lu
2023-02-09  8:50   ` Eli Zaretskii
2023-02-09 10:13     ` Po Lu
2023-02-09 10:55       ` Eli Zaretskii
2023-02-10  7:33   ` Yuan Fu
2023-02-10  8:42     ` Eli Zaretskii
     [not found]       ` <CAOpc7mHX6s0B8vdDee+9FMvQejGTSL3jzgwVekS7Esg-AOf=jw@mail.gmail.com>
2023-02-10 11:48         ` Eli Zaretskii
2023-02-11  2:17           ` Po Lu
2023-02-11  6:25             ` Konstantin Kharlamov
2023-02-11  6:36               ` Konstantin Kharlamov
2023-02-11  6:51                 ` Theodor Thornhill
2023-02-11  7:11                   ` Konstantin Kharlamov
2023-02-11  7:53                     ` Konstantin Kharlamov
2023-02-11  8:22                     ` Konstantin Kharlamov
2023-02-11  8:41                       ` Theodor Thornhill
2023-02-11  9:37                         ` Konstantin Kharlamov
2023-02-11 10:25                           ` Konstantin Kharlamov
2023-02-11  8:43                     ` Eli Zaretskii
2023-04-16 19:21                   ` Konstantin Kharlamov [this message]
2023-02-11  9:34       ` Ihor Radchenko
2023-02-11 10:42         ` Eli Zaretskii
2023-02-11 13:58         ` Lynn Winebarger
2023-02-09 16:25 ` Ergus
2023-02-09 20:09   ` Dmitry Gutov
2023-02-10  7:41     ` Holger Schurig

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=4b31fd663886857221ec88cec2b0ae6644cf94b6.camel@yandex.ru \
    --to=hi-angel@yandex.ru \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=holgerschurig@gmail.com \
    --cc=luangruo@yahoo.com \
    --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 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.