* bug#62043: [PATCH] Fix enums appearing as structs in c-ts-base-mode's imenu
@ 2023-03-08 1:49 Randy Taylor
2023-03-08 23:27 ` Yuan Fu
0 siblings, 1 reply; 5+ messages in thread
From: Randy Taylor @ 2023-03-08 1:49 UTC (permalink / raw)
To: 62043; +Cc: casouri
[-- Attachment #1.1: Type: text/plain, Size: 183 bytes --]
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
[-- Attachment #1.2: Type: text/html, Size: 1111 bytes --]
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-enums-appearing-as-structs-in-c-ts-base-mode-s-i.patch --]
[-- Type: text/x-patch; name=0001-Fix-enums-appearing-as-structs-in-c-ts-base-mode-s-i.patch, Size: 1066 bytes --]
From 0ca6e15bcd3e76bc14b667d88d60f44c4ea6d56a 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 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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#62043: [PATCH] Fix enums appearing as structs in c-ts-base-mode's imenu
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
0 siblings, 1 reply; 5+ messages in thread
From: Yuan Fu @ 2023-03-08 23:27 UTC (permalink / raw)
To: Randy Taylor; +Cc: 62043
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#62043: [PATCH] Fix enums appearing as structs in c-ts-base-mode's imenu
2023-03-08 23:27 ` Yuan Fu
@ 2023-03-09 2:04 ` Randy Taylor
2023-03-10 5:59 ` Yuan Fu
0 siblings, 1 reply; 5+ messages in thread
From: Randy Taylor @ 2023-03-09 2:04 UTC (permalink / raw)
To: Yuan Fu; +Cc: 62043
[-- 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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#62043: [PATCH] Fix enums appearing as structs in c-ts-base-mode's imenu
2023-03-09 2:04 ` Randy Taylor
@ 2023-03-10 5:59 ` Yuan Fu
2023-03-10 18:16 ` Randy Taylor
0 siblings, 1 reply; 5+ messages in thread
From: Yuan Fu @ 2023-03-10 5:59 UTC (permalink / raw)
To: Randy Taylor; +Cc: 62043
> On Mar 8, 2023, at 6:04 PM, Randy Taylor <dev@rjt.dev> wrote:
>
> 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.<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
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#62043: [PATCH] Fix enums appearing as structs in c-ts-base-mode's imenu
2023-03-10 5:59 ` Yuan Fu
@ 2023-03-10 18:16 ` Randy Taylor
0 siblings, 0 replies; 5+ messages in thread
From: Randy Taylor @ 2023-03-10 18:16 UTC (permalink / raw)
To: Yuan Fu; +Cc: 62043-done@debbugs.gnu.org
On Friday, March 10th, 2023 at 00:59, Yuan Fu <casouri@gmail.com> wrote:
>
> > On Mar 8, 2023, at 6:04 PM, Randy Taylor dev@rjt.dev wrote:
> >
> > 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.<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.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-03-10 18:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2023-03-10 5:59 ` Yuan Fu
2023-03-10 18:16 ` Randy Taylor
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.