From: Randy Taylor <dev@rjt.dev>
To: Yuan Fu <casouri@gmail.com>
Cc: 62043@debbugs.gnu.org
Subject: bug#62043: [PATCH] Fix enums appearing as structs in c-ts-base-mode's imenu
Date: Thu, 09 Mar 2023 02:04:21 +0000 [thread overview]
Message-ID: <UnskLUv6MSBcs1-A0AIgBSosn3r3LKBlPajlJt4UNjmR7Y1KDwp3kcC3wyWzv2XLNZeiTmc18jt-m0wFNdPGj2VEA4BDLvyxiBw46Srvah8=@rjt.dev> (raw)
In-Reply-To: <FE2C5130-471D-487B-AF57-1B8507CDB082@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 687 bytes --]
On Wednesday, March 8th, 2023 at 18:27, Yuan Fu <casouri@gmail.com> wrote:
>
> > On Mar 7, 2023, at 5:49 PM, Randy Taylor dev@rjt.dev wrote:
> >
> > X-Debbugs-CC: casouri@gmail.com
> >
> > 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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-enums-and-unions-appearing-as-structs-in-c-ts-ba.patch --]
[-- Type: text/x-patch; name=0001-Fix-enums-and-unions-appearing-as-structs-in-c-ts-ba.patch, Size: 1290 bytes --]
From c9b3104a4cca2e921fd6340a991c5601c1ae6a33 Mon Sep 17 00:00:00 2001
From: Randy Taylor <dev@rjt.dev>
Date: Tue, 7 Mar 2023 20:38:18 -0500
Subject: [PATCH] Fix enums and unions appearing as structs in c-ts-base-mode's
imenu
* lisp/progmodes/c-ts-mode.el (c-ts-base-mode): Separate enums and unions out
from structs.
---
lisp/progmodes/c-ts-mode.el | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index fdd962ff020..ff86b9e0544 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -930,9 +930,9 @@ 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")
- "_specifier" eos)
- ,pred nil)
+ `(("Enum" "\\`enum_specifier\\'" ,pred nil)
+ ("Struct" "\\`struct_specifier\\'" ,pred nil)
+ ("Union" "\\`union_specifier\\'" ,pred nil)
("Variable" ,(rx bos "declaration" eos) ,pred nil)
("Function" "\\`function_definition\\'" ,pred nil)
("Class" ,(rx bos (or "class_specifier"
--
2.39.2
next prev parent reply other threads:[~2023-03-09 2:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-08 1:49 bug#62043: [PATCH] Fix enums appearing as structs in c-ts-base-mode's imenu Randy Taylor
2023-03-08 23:27 ` Yuan Fu
2023-03-09 2:04 ` Randy Taylor [this message]
2023-03-10 5:59 ` Yuan Fu
2023-03-10 18:16 ` Randy Taylor
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='UnskLUv6MSBcs1-A0AIgBSosn3r3LKBlPajlJt4UNjmR7Y1KDwp3kcC3wyWzv2XLNZeiTmc18jt-m0wFNdPGj2VEA4BDLvyxiBw46Srvah8=@rjt.dev' \
--to=dev@rjt.dev \
--cc=62043@debbugs.gnu.org \
--cc=casouri@gmail.com \
/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 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).