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