GNU bug report logs - #78117
Improve c-ts-mode--c-or-c++-regexp

Previous Next

Package: emacs;

Reported by: Sergey Abdulov <tidesmain <at> gmail.com>

Date: Mon, 28 Apr 2025 14:17:07 UTC

Severity: normal

Full log


Message #8 received at 78117 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Sergey Abdulov <tidesmain <at> gmail.com>
Cc: 78117 <at> debbugs.gnu.org
Subject: Re: bug#78117: Improve c-ts-mode--c-or-c++-regexp
Date: Mon, 28 Apr 2025 18:52:40 +0300
> From: Sergey Abdulov <tidesmain <at> gmail.com>
> Date: Mon, 28 Apr 2025 11:13:31 +0500
> 
> Hello!
> 
> I ran into a header that uses C++ features but still opens in c-ts-mode.
> Link: https://raw.githubusercontent.com/HandmadeMath/HandmadeMath/refs/heads/master/HandmadeMath.h
> Therefore I suggest either:
> 1) Treat any mention of `__cplusplus` macro as a C++ file

That's not a good idea, because many header files are basically C
code, but use __cplusplus condition to allow C++ code include the
header file.

> 2) Or add an `operatorX` pattern where X is one of the C++ operators
> (don't forget <=> etc)

That could be unreliable, I'm afraid.

> For now I'm enabling c++-ts-mode manually whenever I edit said header

The usual technique is to have

  // -*- c++ -*-

on the first line of the file.

> but it's still bad since some of the broken highlighting from
> c-ts-mode persists into c++-ts-mode after toggling and gets fixed
> after moving the cursor through affected areas. That's another bug
> though.

Please submit a separate bug about that, with the details: where in
that file do you see the incorrect highlighting after switching the
mode.

Thanks.




This bug report was last modified 110 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.