all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: theo@thornhill.no, casouri@gmail.com, spacibba@aol.com,
	 emacs-devel@gnu.org
Subject: Re: c-ts-mode
Date: Fri, 8 Sep 2023 13:38:58 +0100	[thread overview]
Message-ID: <CALDnm53dN6r=jLJggYCO60bQ3X3UY-w=667y3zJtr8PTW+-gMw@mail.gmail.com> (raw)
In-Reply-To: <838r9gykia.fsf@gnu.org>

On Fri, Sep 8, 2023 at 12:26 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: João Távora <joaotavora@gmail.com>
> > Cc: Theodor Thornhill <theo@thornhill.no>,  casouri@gmail.com,
> >   spacibba@aol.com,  emacs-devel@gnu.org
> > Date: Fri, 08 Sep 2023 08:25:50 +0100
> >
> > > What I had in mind was a simple alist, like CC Mode uses, with an
> > > infrastructure function to install it.  Patches are welcome.
> >
> > It would certainly work for me, at least for my very simple case, and I
> > would be happy for this.  Not sure it is half as powerful, for example
> > how would you make that simple alist express cases where you want to add
> > the rules _after_ the base set?
>
> How does CC Mode support this (if it does)?

No idea, I don't know CC Mode's styling interface well beyond
the trivial example I showed.

It does seems like CC Mode have different mechanics?
Maybe order doesn't matter there?

> Anything beyond that is, of course, welcome, but it is
> less important from my POV.

Sure makes sense.  As I said I'm just conjecturing someone
will need that flexibility because rule ordering is a fundamental
part of the mechanics in TS and I don't think we abstract it
away.  But personally, for those ridiculous two rules, I didn't
need it at all, adding at the front was just fine

Anyway, it's worth pointing out that unless you're extremely adept
at crafting indentation styles for Emacs, you're always in a losing
battle when working on multiple projects, since many projects
nowadays (not just C/C++) use an external format definition.
A .clang-format  (even we have one since 2017) or other similar
files.  These are understood by other editors and tools.

Maybe in the past CC Mode's styles were very useful, but I don't
think they attract the same interest today because there are these
external tools.  For the same reason, I don't predict ts
indentation styles to become widely used.

Of course, this is a big annoyance, because there always multiple
competing sources of indentation rules.  Emacs TAB use one thing,
everyone else uses something else.

Personally I've not been fighting this, i.e. I gave up.  I use
Emacs indentation rules to more or less align the file with the rules
and then make sure to run the tool (maybe via eglot-format)
before committing.  It'd be great if I could rely on indent-region
or C-M-q to produce the canonical indentation like I do in
Lisp modes, but I can't.

A more promising solution to this whole problem would be
to somehow bring these external formatter's rules to meet Emacs's
idea of "just indent these lines".

I tried to do that with Eglot (and Theo helped out) via
indent-region-function but we alas it didn't work very well,
because -- at least for clangd -- the LSP formatter (which
delegates to clang-format under the hood) has a tendency to add
and remove newlines even if you ask it to stay within the
same line.  So basic things like indenting an empty line is
essentially impossible.

João



  reply	other threads:[~2023-09-08 12:38 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <r6t7xfcchagyl72ltdrcavncbpvba7badcoh4yimleoynmzfvb.ref@elkspm3vozuv>
2023-08-30 23:52 ` c-ts-mode Ergus
2023-09-01  4:14   ` c-ts-mode Yuan Fu
2023-09-07  9:25     ` c-ts-mode João Távora
2023-09-07  9:37       ` c-ts-mode Eli Zaretskii
2023-09-07 15:58         ` c-ts-mode João Távora
2023-09-07 17:10           ` c-ts-mode Eli Zaretskii
2023-09-07 17:53             ` c-ts-mode João Távora
2023-09-07 18:13               ` c-ts-mode Eli Zaretskii
2023-09-07 18:23                 ` c-ts-mode João Távora
2023-09-07 18:32                   ` c-ts-mode Eli Zaretskii
2023-09-07 22:01                     ` c-ts-mode João Távora
2023-09-08  6:14                       ` c-ts-mode Eli Zaretskii
2023-09-08  7:25                         ` c-ts-mode João Távora
2023-09-08 11:25                           ` c-ts-mode Eli Zaretskii
2023-09-08 12:38                             ` João Távora [this message]
2023-09-08 13:11                               ` c-ts-mode Eli Zaretskii
2023-09-08 13:32                                 ` c-ts-mode Eli Zaretskii
2023-09-08 15:15                                   ` c-ts-mode João Távora
2023-09-08 15:34                                     ` c-ts-mode Eli Zaretskii
2023-09-08 15:56                                       ` c-ts-mode João Távora
2023-09-08 18:23                                         ` c-ts-mode Eli Zaretskii
2023-09-08 18:30                                           ` c-ts-mode João Távora
2023-09-08 18:54                                             ` c-ts-mode Eli Zaretskii
2023-09-08 19:42                                               ` c-ts-mode João Távora
2023-09-09  6:09                                                 ` c-ts-mode Eli Zaretskii
2023-09-08 19:58                               ` c-ts-mode Petteri Hintsanen
2023-09-08 20:27                                 ` c-ts-mode João Távora
2023-09-09  6:19                                 ` c-ts-mode Eli Zaretskii
2023-09-13 16:15                                   ` c-ts-mode Petteri Hintsanen
2023-09-12  0:34                             ` c-ts-mode Yuan Fu
2023-09-12  7:45                               ` c-ts-mode João Távora
2023-09-12  8:00                                 ` c-ts-mode Po Lu
2023-09-12  9:51                                   ` c-ts-mode João Távora

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='CALDnm53dN6r=jLJggYCO60bQ3X3UY-w=667y3zJtr8PTW+-gMw@mail.gmail.com' \
    --to=joaotavora@gmail.com \
    --cc=casouri@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=spacibba@aol.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.