Subject: bug#62043: closed (Re: bug#62043: [PATCH] Fix enums appearing as structs in c-ts-base-mode's imenu)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 10 Mar 2023 18:18:02 +0000

Your bug report

#62043: [PATCH] Fix enums appearing as structs in c-ts-base-mode's imenu

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
62043: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=62043
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#62043: [PATCH] Fix enums appearing as structs in c-ts-base-mode's imenu
From: Randy Taylor <[email-masked]>
To: Yuan Fu <[email-masked]>
Cc: "[email-masked]" <[email-masked]>
Date: Fri, 10 Mar 2023 18:16:48 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

On Friday, March 10th, 2023 at 00:59, Yuan Fu <[email-masked]> wrote:
> 
> > On Mar 8, 2023, at 6:04 PM, Randy Taylor [email-masked] wrote:
> > 
> > On Wednesday, March 8th, 2023 at 18:27, Yuan Fu [email-masked] wrote:
> > 
> > > > On Mar 7, 2023, at 5:49 PM, Randy Taylor [email-masked] wrote:
> > > > 
> > > > X-Debbugs-CC: [email-masked]
> > > > 
> > > > With {c, c++}-ts-mode, enums appear as structs in imenu. The attached patch fixes this.
> > > > 
> > > > Example:
> > > > enum Thing { A, B, C };
> > > > 
> > > > Should appear as Enum Thing
> > > > <0001-Fix-enums-appearing-as-structs-in-c-ts-base-mode-s-i.patch>
> > > 
> > > Thanks! I wonder what determines which categories to merge together and which to not? If we separate Enums, should we also separate Unions?
> > > 
> > > Yuan
> > 
> > I think they should all be separate actually. Attached a patch that does so.<0001-Fix-enums-and-unions-appearing-as-structs-in-c-ts-ba.patch>
> 
> 
> That’s probably the right thing to do. I applied the patch, thanks!
> 
> Yuan

Thanks, closing.

Subject: [PATCH] Fix enums appearing as structs in c-ts-base-mode's imenu
From: Randy Taylor <[email-masked]>
To: "[email-masked]" <[email-masked]>
Date: Wed, 08 Mar 2023 01:49:49 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

X-Debbugs-CC: [email-masked]

With {c, c++}-ts-mode, enums appear as structs in imenu. The attached patch fixes this.

Example:
enum Thing { A, B, C };

Should appear as Enum Thing

From 0ca6e15bcd3e76bc14b667d88d60f44c4ea6d56a Mon Sep 17 00:00:00 2001
From: Randy Taylor <[email-masked]>
Date: Tue, 7 Mar 2023 20:38:18 -0500
Subject: [PATCH] Fix enums appearing as structs in c-ts-base-mode's imenu

* lisp/progmodes/c-ts-mode.el (c-ts-base-mode): Separate enums out
from structs.
---
 lisp/progmodes/c-ts-mode.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index fdd962ff020..9bb4950da8c 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -930,7 +930,8 @@ c-ts-base-mode
   ;; Imenu.
   (setq-local treesit-simple-imenu-settings
               (let ((pred #'c-ts-mode--defun-valid-p))
-                `(("Struct" ,(rx bos (or "struct" "enum" "union")
+                `(("Enum" "\\`enum_specifier\\'" ,pred nil)
+                  ("Struct" ,(rx bos (or "struct" "union")
                                  "_specifier" eos)
                    ,pred nil)
                   ("Variable" ,(rx bos "declaration" eos) ,pred nil)
-- 
2.39.2