Subject: bug#69657: Missing imenu entries with eglot

From: João Távora <[email-masked]>
Date: Sun, 10 Mar 2024 01:05:34 +0000

On Sat, Mar 9, 2024 at 4:20 PM Felician Nemeth
<[email-masked]> wrote:
>
> CC-ing João, the maintainer of breadcrumb-mode.

I've made a file with

class Foo {
  void bar() {}
};

And the imenu--index-alist calculated by Eglot has what I think is the most
sensible way to represent this within the ancient rigid limitations of that
variable's format.

((#("Foo" 0 3 (breadcrumb-region (1 . 31) breadcrumb-kind "Class"))
  (#("bar" 0 3 (breadcrumb-region (15 . 28) breadcrumb-kind "Method"))
   . 15)))

I understand Sebastian wants to see an extra top-evel ("Foo" . 1) there
or something, but that leads to two entries with duplicate names and imenu
just doesn't like that (if I apply the patch I just can't go to 'bar' with M
-x imenu), neither do some of its clients.

This is way Eglot emits "breadcrumb"-friendly cookies to overcome imenu's
limitations.   Using breadcrumb i can jump to Foo and Foo > bar just
fine (using
`M-x breadcrumb-jump`).

These cookies are innocuous to anyone else.  But I guess if someone took the
time to consecrate them as imenu things instead of breadcrumb things. Then
others UIs could use them. Or someone could invent something much better
than imenu and have Eglot write to that idk.  Imenu is pretty cursed, but it's
what was already there so I picked it.

Anyway, if users don't like Eglot's imenu function, they can use something
else.  Eglot's imenu is different from c++-ts-mode, and afaik c++-ts-mode's is
already different from c++-mode's.  I wouldn't install this patch though,
teach other UIs about those optional cookies seems like a better deal that
doesn't break stuff.