unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* A note about clang-format
@ 2023-08-22 14:55 Gerd Möllmann
  2023-08-22 18:29 ` Corwin Brust
  0 siblings, 1 reply; 10+ messages in thread
From: Gerd Möllmann @ 2023-08-22 14:55 UTC (permalink / raw)
  To: emacs-devel

FYI, maybe it's helpful

// clang-format off
// clang-format on

can be used to keep clang-format from touching regions of code, also
when used via Eglot + clangd.  Works for me.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: A note about clang-format
  2023-08-22 14:55 A note about clang-format Gerd Möllmann
@ 2023-08-22 18:29 ` Corwin Brust
  2023-08-22 18:34   ` João Távora
  2023-08-22 19:02   ` Gerd Möllmann
  0 siblings, 2 replies; 10+ messages in thread
From: Corwin Brust @ 2023-08-22 18:29 UTC (permalink / raw)
  To: Gerd Möllmann; +Cc: emacs-devel

Thank you Gerd!

On Tue, Aug 22, 2023 at 9:55 AM Gerd Möllmann <gerd.moellmann@gmail.com> wrote:
>
> FYI, maybe it's helpful

Definitely helpful.

>
> // clang-format off
> // clang-format on
>
> can be used to keep clang-format from touching regions of code, also
> when used via Eglot + clangd.  Works for me.
>

A user was on IRC asking how to "stopping Elgot from messing with my
C++", just minutes after I received your email.   Surrounding the code
with these comments solved the issue.  In any event, I wanted to let
you know this definitely helped at least one person already; I've
included Sacha in BCC in case this may be of interest for EmacsNews.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: A note about clang-format
  2023-08-22 18:29 ` Corwin Brust
@ 2023-08-22 18:34   ` João Távora
  2023-08-22 18:59     ` Gerd Möllmann
  2023-08-22 19:02   ` Gerd Möllmann
  1 sibling, 1 reply; 10+ messages in thread
From: João Távora @ 2023-08-22 18:34 UTC (permalink / raw)
  To: Corwin Brust; +Cc: Gerd Möllmann, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 783 bytes --]

On Tue, Aug 22, 2023, 19:29 Corwin Brust <corwin@bru.st> wrote:

>
> > FYI, maybe it's helpful
>
> Definitely helpful.
>
> A user was on IRC asking how to "stopping Elgot from messing with my
> C++", just minutes after I received your email.   Surrounding the code
> with these comments solved the issue.  In any event, I wanted to let
> you know this definitely helped at least one person already; I've
> included Sacha in BCC in case this may be of interest for EmacsNews.
>

Yep, definitely helpful. That user might also be interested in knowing that
the reason that Eglot is so eager to reformat on type is because the server
eagerly provides that capability itself.

But it can be ignored via 'eglot-ignored-server-capabilities', which see.

João



>

[-- Attachment #2: Type: text/html, Size: 1444 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: A note about clang-format
  2023-08-22 18:34   ` João Távora
@ 2023-08-22 18:59     ` Gerd Möllmann
  2023-08-22 19:07       ` João Távora
  0 siblings, 1 reply; 10+ messages in thread
From: Gerd Möllmann @ 2023-08-22 18:59 UTC (permalink / raw)
  To: João Távora; +Cc: Corwin Brust, emacs-devel

João Távora <joaotavora@gmail.com> writes:

> But it can be ignored via 'eglot-ignored-server-capabilities', which see.

Actually, I found that auto-formatting quite nice when I switched from
lsp-mode to eglot today, so I didn't want to suppress this.  But the
DEFUNs in Emacs' C code are something from another world.  I don't know
if any formatter can cope with them.

Might be good to start using this in the Emacs sources, too, if that's
ok.  The existence of a .clang-format makes me think some users might
appreciate it.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: A note about clang-format
  2023-08-22 18:29 ` Corwin Brust
  2023-08-22 18:34   ` João Távora
@ 2023-08-22 19:02   ` Gerd Möllmann
  1 sibling, 0 replies; 10+ messages in thread
From: Gerd Möllmann @ 2023-08-22 19:02 UTC (permalink / raw)
  To: Corwin Brust; +Cc: emacs-devel

On 22.08.23 20:29, Corwin Brust wrote:
> Thank you Gerd!

👍



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: A note about clang-format
  2023-08-22 18:59     ` Gerd Möllmann
@ 2023-08-22 19:07       ` João Távora
  2023-08-22 19:44         ` Gerd Möllmann
  2023-08-23  2:27         ` Eli Zaretskii
  0 siblings, 2 replies; 10+ messages in thread
From: João Távora @ 2023-08-22 19:07 UTC (permalink / raw)
  To: Gerd Möllmann; +Cc: Corwin Brust, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 913 bytes --]

On Tue, Aug 22, 2023, 19:59 Gerd Möllmann <gerd.moellmann@gmail.com> wrote:

> João Távora <joaotavora@gmail.com> writes:
>
> > But it can be ignored via 'eglot-ignored-server-capabilities', which see.
>
> Actually, I found that auto-formatting quite nice when I switched from
> lsp-mode to eglot today, so I didn't want to suppress this.  But the
> DEFUNs in Emacs' C code are something from another world.  I don't know
> if any formatter can cope with them.
>
> Might be good to start using this in the Emacs sources, too, if that's
> ok.  The existence of a .clang-format makes me think some users might
> appreciate it.
>

I think we (meaning you) should lobby Eli for compile_commands.json
generation first :)

M-x eglot in Emacs sources still doesn't work oob and there's little reason
for that (well, apart from some understandable llvm aversion, but there are
other servers...).

[-- Attachment #2: Type: text/html, Size: 1478 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: A note about clang-format
  2023-08-22 19:07       ` João Távora
@ 2023-08-22 19:44         ` Gerd Möllmann
  2023-08-22 20:13           ` João Távora
  2023-08-23  2:27         ` Eli Zaretskii
  1 sibling, 1 reply; 10+ messages in thread
From: Gerd Möllmann @ 2023-08-22 19:44 UTC (permalink / raw)
  To: João Távora; +Cc: Corwin Brust, emacs-devel

João Távora <joaotavora@gmail.com> writes:

> I think we (meaning you) should lobby Eli for compile_commands.json
> generation first :)

I think that might not even be necessary because users can do that
easily, if they know how.  See https://github.com/rizsotto/Bear, for
example, which is GPLv3.  With it, do an initial full build with "bear
-- gmake" instead of just "gmake".



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: A note about clang-format
  2023-08-22 19:44         ` Gerd Möllmann
@ 2023-08-22 20:13           ` João Távora
  2023-08-23  5:58             ` Gerd Möllmann
  0 siblings, 1 reply; 10+ messages in thread
From: João Távora @ 2023-08-22 20:13 UTC (permalink / raw)
  To: Gerd Möllmann; +Cc: Corwin Brust, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1532 bytes --]

On Tue, Aug 22, 2023, 20:45 Gerd Möllmann <gerd.moellmann@gmail.com> wrote:

> I think we (meaning you) should lobby Eli for compile_commands.json
> > generation first :)
>
> I think that might not even be necessary because users can do that
> easily, if they know how.  See https://github.com/rizsotto/Bear, for
> example, which is GPLv3.  With it, do an initial full build with "bear
> -- gmake" instead of just "gmake".
>

Yes, I've used 'bear' before (in fact I asked you, remember?).

But -- great as it is -- it's still basically a hack which requires
actually compiling the code to learn _how_ it would be compiled. That's not
always practical, perhaps not even always possible depending on the
toolchain to use.

So it's a needless hindrance and, afair, not perfectly accurate (you had
some non-trivial ad-hoc tweak script as I recall).

I don't see a fundamental technical reason not to generate this simple file
from our own configuration script, which is the source of truth for this
information after all.  In all Cmake projects I work with, it's a matter of
setting a simple variable. I wonder if the automake world doesn't have
something similar. If it doesn't, how hard can it be to add one?

We should lower that bar so that every Emacs C hacker (including Eli and
other long timers) can benefit from LSP (with Eglot, of course ;) ). This
will be beneficial to Emacs C code and to Eglot itself of course.

And with that, it seems I have done all the lobbying myself :)

João

>

[-- Attachment #2: Type: text/html, Size: 2556 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: A note about clang-format
  2023-08-22 19:07       ` João Távora
  2023-08-22 19:44         ` Gerd Möllmann
@ 2023-08-23  2:27         ` Eli Zaretskii
  1 sibling, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2023-08-23  2:27 UTC (permalink / raw)
  To: João Távora; +Cc: gerd.moellmann, corwin, emacs-devel

> From: João Távora <joaotavora@gmail.com>
> Date: Tue, 22 Aug 2023 20:07:32 +0100
> Cc: Corwin Brust <corwin@bru.st>, emacs-devel <emacs-devel@gnu.org>
> 
> M-x eglot in Emacs sources still doesn't work oob and there's little reason for that (well, apart from
> some understandable llvm aversion, but there are other servers...).

There's no server based on GCC, AFAIK.  I asked GCC developers to work
on that, and they all agreed it's a good development direction, but
nothing practical came out of it, AFAICT.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: A note about clang-format
  2023-08-22 20:13           ` João Távora
@ 2023-08-23  5:58             ` Gerd Möllmann
  0 siblings, 0 replies; 10+ messages in thread
From: Gerd Möllmann @ 2023-08-23  5:58 UTC (permalink / raw)
  To: João Távora; +Cc: Corwin Brust, emacs-devel

João Távora <joaotavora@gmail.com> writes:

> On Tue, Aug 22, 2023, 20:45 Gerd Möllmann <gerd.moellmann@gmail.com> wrote:
>
>  > I think we (meaning you) should lobby Eli for compile_commands.json
>  > generation first :)
>
>  I think that might not even be necessary because users can do that
>  easily, if they know how.  See https://github.com/rizsotto/Bear, for
>  example, which is GPLv3.  With it, do an initial full build with "bear
>  -- gmake" instead of just "gmake".
>
> Yes, I've used 'bear' before (in fact I asked you, remember?).

Sorry, I didn't remember that that was you :-).

>
> But -- great as it is -- it's still basically a hack which requires
> actually compiling the code to learn _how_ it would be
> compiled. That's not always practical, perhaps not even always
> possible depending on the toolchain to use.

Some alternatives to Bear use a --dry-run.  I haven't tried them though:
https://github.com/nickdiego/compiledb for example.  Would that be
sufficient for the cases you think of?

> So it's a needless hindrance and, afair, not perfectly accurate (you
> had some non-trivial ad-hoc tweak script as I recall).

Yes, the script adds an "-include config.h" for the files in src/.  That
makes things a little bit smoother with clangd.  One can do without,
though.

> I don't see a fundamental technical reason not to generate this simple
> file from our own configuration script, which is the source of truth
> for this information after all.  In all Cmake projects I work with,
> it's a matter of setting a simple variable. I wonder if the automake
> world doesn't have something similar. If it doesn't, how hard can it
> be to add one?

AFAIK, there is nothing like that in autoconf/automake.  At least last
time I checked about a year ago there wasn't.  I also have a vague
memory that someone on their mailing list said it it would be
impoossible to produce a correct compilation database without running
make, because one could alwasys do something like "CFLAGS=... make".
Can't find that article ATM, maybe I'm confusing that with something
else.



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-08-23  5:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-22 14:55 A note about clang-format Gerd Möllmann
2023-08-22 18:29 ` Corwin Brust
2023-08-22 18:34   ` João Távora
2023-08-22 18:59     ` Gerd Möllmann
2023-08-22 19:07       ` João Távora
2023-08-22 19:44         ` Gerd Möllmann
2023-08-22 20:13           ` João Távora
2023-08-23  5:58             ` Gerd Möllmann
2023-08-23  2:27         ` Eli Zaretskii
2023-08-22 19:02   ` Gerd Möllmann

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).