GNU bug report logs - #69657
Missing imenu entries with eglot

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Sebastian Poeplau <sebastian.poeplau@HIDDEN>; dated Fri, 8 Mar 2024 20:33:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 69657 <at> debbugs.gnu.org:


Received: (at 69657) by debbugs.gnu.org; 10 Mar 2024 01:07:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 09 20:07:28 2024
Received: from localhost ([127.0.0.1]:35016 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rj7ey-000842-Jb
	for submit <at> debbugs.gnu.org; Sat, 09 Mar 2024 20:07:28 -0500
Received: from mail-lf1-f50.google.com ([209.85.167.50]:54703)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <joaotavora@HIDDEN>) id 1rj7ev-00083n-Bh
 for 69657 <at> debbugs.gnu.org; Sat, 09 Mar 2024 20:07:28 -0500
Received: by mail-lf1-f50.google.com with SMTP id
 2adb3069b0e04-5131c0691feso4407639e87.1
 for <69657 <at> debbugs.gnu.org>; Sat, 09 Mar 2024 17:06:52 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1710032746; x=1710637546; darn=debbugs.gnu.org;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:from:to:cc:subject:date
 :message-id:reply-to;
 bh=l03ABOgB1iBmt17n2yy5yh/dpTsws/uS/09bkJ44sS4=;
 b=GTW8hkNI3XuV5GRvHvy14/qtQ5YnPbJkh8YJb5Jhvp7T5a46A4UHwc6yOrs4GtgAFT
 k2CcRVSJ6Ttpu36BT2LuBTtrsPY3owiMrPmTn1IdR40VtrmxRkLCNE4nVFuig0F4tNjh
 0J0RsKuqy3pB6PPwmgp6tX62b72MR7RVqzJFRiE/3m2mDdlQ5uKzcCsfcgCkVDXVB/96
 lKRCSk5YE65Ajynui2d9scg6RUOQcaSWSYRdzNgV/IszoSIIaq013iRILE+vL3hCKrUV
 BXQoiK9f2c9QzbmrAmosKsDIplzieDnWH40n9GKp4HxJ3ubKPL/cktpxZTAwSv5mQAiS
 h8Bw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1710032746; x=1710637546;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=l03ABOgB1iBmt17n2yy5yh/dpTsws/uS/09bkJ44sS4=;
 b=pRcWOIXdZrV02b4+gExDNdOav0RC5NyddgVZer0Ne+JbW/jdET2OLx11hB4kRvN8dC
 2BiBesFELJQitVmtL9z695Tc4DGitQ2ttcQa0Vqv/6B92IBC1BwXfEUKAfKyJ2BIKe5S
 /O9nyl8aoLteCtsXSU6S53KzMEZdTMLD3prsNyTYgKtzgJdvOBrvG5dd07Sdw/K1Tb4h
 0UJmPZO61uNozHjRRXbWEuvLjLREQz98IA0alvcLuM29RCgMpoHJbPTbSJNqhiYgld+9
 afLKhoqCUsbX+wkJuBoqs6SRePhB8VEg6V/Azmxq3/SGsfCb3Bx/N7AUJJWs4Pjv9Rxj
 5pYw==
X-Forwarded-Encrypted: i=1;
 AJvYcCUSVYEboLx21J2zbpciggeRewDGE7LF9z/MRdzUBs3UGqpndgkS/7WzD4nHQN6raGy9mZpBAYMKNq6dTak1/dLQiZdEWKM=
X-Gm-Message-State: AOJu0YzfwiFBXjIamHyWbuw+AiPRSP1hsnnozTWk2G4gzL9MgzLaHCrX
 sEUVSkGkCi4Ez5hbUXAEvgKKUeiCern+8QAglX1zL09Pr4C7OIgV6X9lNQH0ND/T2Nx7G3K016G
 pVwP3leWH7G7p604j+hS8X3bTtvo=
X-Google-Smtp-Source: AGHT+IFAXqLuyEu2bjLxVAdiKFZAz481tx2glDPqPNGsy3T3jdYgleZuu4BaKpcG0kPGLuS/DsKu3hnre7hHB9gzsNo=
X-Received: by 2002:a05:6512:2353:b0:512:fded:e674 with SMTP id
 p19-20020a056512235300b00512fdede674mr2185920lfu.61.1710032746085; Sat, 09
 Mar 2024 17:05:46 -0800 (PST)
MIME-Version: 1.0
References: <87frx0ze5n.fsf@HIDDEN> <87a5n8s8jw.fsf@HIDDEN>
 <87bk7oz6vc.fsf@HIDDEN> <87v85v1io3.fsf@HIDDEN>
In-Reply-To: <87v85v1io3.fsf@HIDDEN>
From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Date: Sun, 10 Mar 2024 01:05:34 +0000
Message-ID: <CALDnm53uLT7Hq_1NEyyXiBQTgrf=F81Jp9Ebd=xvhNOqUCkAqA@HIDDEN>
Subject: Re: bug#69657: Missing imenu entries with eglot
To: Felician Nemeth <felician.nemeth@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 69657
Cc: 69657 <at> debbugs.gnu.org, Sebastian Poeplau <sebastian.poeplau@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Sat, Mar 9, 2024 at 4:20=E2=80=AFPM Felician Nemeth
<felician.nemeth@HIDDEN> wrote:
>
> CC-ing Jo=C3=A3o, 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 th=
e
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 i=
t'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.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#69657; Package emacs. Full text available.

Message received at 69657 <at> debbugs.gnu.org:


Received: (at 69657) by debbugs.gnu.org; 9 Mar 2024 16:21:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 09 11:21:55 2024
Received: from localhost ([127.0.0.1]:34687 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rizSN-0002wf-IZ
	for submit <at> debbugs.gnu.org; Sat, 09 Mar 2024 11:21:55 -0500
Received: from mail-ej1-f44.google.com ([209.85.218.44]:46191)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <felician.nemeth@HIDDEN>) id 1rizSK-0002wS-V9
 for 69657 <at> debbugs.gnu.org; Sat, 09 Mar 2024 11:21:53 -0500
Received: by mail-ej1-f44.google.com with SMTP id
 a640c23a62f3a-a45bdf6e9c2so363736066b.0
 for <69657 <at> debbugs.gnu.org>; Sat, 09 Mar 2024 08:21:20 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1710001214; x=1710606014; darn=debbugs.gnu.org;
 h=content-transfer-encoding:mime-version:face:user-agent:message-id
 :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject
 :date:message-id:reply-to;
 bh=Kgzsvs8jhrLTiQFKFIHZoTw+5YxMWjSF4qDtsfUOBq8=;
 b=CxPWI6ASpx/ST1ZMqZ0T21x2Zbh25wY8sdng9SUQWewcNeZ8wDbxWeaVQCsYpQmrRX
 PSkpi6H+YR7u0oQ1HMeCfpLD2Uq3PNnOt61peAdxwJ/B23kPFDdEwEraOe7rM1W0YN5T
 mJn0UwoQPwWI1r3VIGSqclsZ2XT9i51m2vvxTZNPoG9qCbUWgs8un0Lw1eqa8WY9mKYf
 ySN63NG73xxcTsggFyJQ20tdwZY6D2w4rLU7Wm5aP0fZC+z2usglKAbZGM/djGg8VxxF
 Of/3Yi9jK/+H0CSQfFylMAqrc6agOinHMmX+2d3X2zmJ/HZtwcOe+cg9pUFKi2FjxwoB
 j++Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1710001214; x=1710606014;
 h=content-transfer-encoding:mime-version:face:user-agent:message-id
 :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=Kgzsvs8jhrLTiQFKFIHZoTw+5YxMWjSF4qDtsfUOBq8=;
 b=FTgtPppl7XLWmc6bPaBmW0z1xeyrUUYHyH7GMutwHaWMz+NWmcT2dJNED7l9tSWH+3
 DicUonbBypNvsmAckzozDyOStoDfhQ/tgz8HIJHs35K88/DnpQ7tltWVbsnvfWcYwRSJ
 BMUGAcTrjIN88DL4p9MQKR7tpslmKmjxQvFM/SkbYv1a30uZejEttxUumjSJZE73ZnYx
 0ji2R0TgdNhucsx5j4yH7ravSgbCH6jLHp/3IYiPxb3q2Pip9dwzQgVt1QX9+MJnCfkF
 cpEar7+wiCV44LMY4IrtfNXgnLnp7wtsFFBC/PJpb4IgX3aUvZEZCkJ4FuHP4kni6YfY
 0HhQ==
X-Gm-Message-State: AOJu0YxJA4DrGWwiUIV60RB5nJzYxJwb0nI3RlDWCzY/M+wPHSkYSnRi
 cMP3L/2o+GJDs9GeeDNAfYd9uawua1hGlDm6c3vhitrYs45e2CrY
X-Google-Smtp-Source: AGHT+IHfGzEwPvDzBou3WzTGXeQVbvL1QFVtqprlcL51pDaNVBXrNb0PgZroaF6oC4S7EeLsPkIoZQ==
X-Received: by 2002:a17:906:f215:b0:a45:b1cf:42f6 with SMTP id
 gt21-20020a170906f21500b00a45b1cf42f6mr1230587ejb.9.1710001214041; 
 Sat, 09 Mar 2024 08:20:14 -0800 (PST)
Received: from betli.gmail.com (catv-213-222-160-137.catv.fixed.vodafone.hu.
 [213.222.160.137]) by smtp.gmail.com with ESMTPSA id
 j20-20020a170906411400b00a45c18345e0sm1028451ejk.163.2024.03.09.08.20.12
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 09 Mar 2024 08:20:13 -0800 (PST)
From: Felician Nemeth <felician.nemeth@HIDDEN>
To: Sebastian Poeplau <sebastian.poeplau@HIDDEN>
Subject: Re: bug#69657: Missing imenu entries with eglot
References: <87frx0ze5n.fsf@HIDDEN> <87a5n8s8jw.fsf@HIDDEN>
 <87bk7oz6vc.fsf@HIDDEN>
Date: Sat, 09 Mar 2024 17:20:12 +0100
In-Reply-To: <87bk7oz6vc.fsf@HIDDEN> (Sebastian Poeplau's message of
 "Fri, 08 Mar 2024 23:28:26 +0100")
Message-ID: <87v85v1io3.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEUMBwgHAgMFAAGPjY7/
 //80MDHq6eqJt3pKAAABr0lEQVQ4jX2UzZKDIAzHqR177q7TPbtx2HMr6guQcrbY9txZ0fd/hA0f
 onXazcEJ/CD8E4Js8/HS9mwjXtqeMRxHXJkakTEm4b4GPVQW8PU8ov4fQCqeThlF60MBWdo1IXzd
 2nEEZE7CEAZLwI0N/gJAhTj7ESQAX4gPgO8lyI+cvgViSVPlNomAj2M9gW40eg7VWY3cATjUcyiO
 Z+i03cFruGLYoUR7VyU3HihdmCEVhoDN65FXkpbSxkomOzsTQN/gySaodGb9Gdi1oSRXP46gdBWh
 LcUKJNdeGCWac74GKakmne0aHCFvyqJPYLsCFAVlhRTvGdzMdLHqtgRyUulyXIAH7CYQ3AB0Nody
 JQhAkq/qtOnbjhxdzYDkXPxlH5y4WdUAeUcX1NVJ6GR7UQEYPGWoAnA36OQNn5lRRp38vHTAp9Br
 LoTmvlPPDoRCKzpjG1SXT89AaT5l456BamJuMcs+NIOMzJ/s5dI6yUVcrARlruwOebfdv6gunTn4
 ww3+QjGBEn5suVyLHoSGvAqREuDLN+iqZ+VcFg+HBbsJUU9+FZthbez9T+bdb+kPv2Ls6ct3hTkA
 AAAASUVORK5CYII=
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 69657
Cc: 69657 <at> debbugs.gnu.org,
 =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

CC-ing Jo=C3=A3o, the maintainer of breadcrumb-mode.

> I did M-x imenu, although I should add that I normally use
> consult-imenu, which presents a flattened menu. That's also what I wrote
> the patch for.

Without the patch, I can jump to "bar" (M-x imenu RET Foo RET bar RET)
and cannot jump to "Foo".  With the patch, I can jump to "Foo" (M-x
imenu RET Foo RET) and cannot jump to "bar".

So the default / basic behavior has changed, but I don't think it is a
definit improvement.

>> On the other hand, the patch seems to ruin breadcrumb-mode: putting
>> the point after "{}", the breadcrumb header line shows: "dir/test.cpp:
>> Class > Foo" instead of the original "dir/test.cpp: Class > Foo >
>> bar".
>
> If you move point _after_ "{}", you're outside of method "bar", aren't
> you? Doesn't that mean the breadcrumb header is correct now and was
> wrong before?

This is the first time I use breadcrumb, so I don't really know what is
the exact correct behaviour.  But without the patch there are locations
for with "bar" is present it the breadcrumb header, and with the patch
there isn't any.

Maybe this is a bug in breadcrumb, but applying the current version of
the patch is going to ruin an existing feature.

Additionally, with the patch, the *Completions* buffer shows: "3
possible completions: *Rescan* Foo".  So maybe there is a bug in imenu
as well, since it seems it cannot handle items having the same name.

> for the record, this is the textDocument/documentSymbol response I'm
> getting for the example in my original message:  [...]

This is what I get as well, so luckily the different clangd versions
don't cause problems.

----

By the way, I haven't used consult before, but after a quick look at it,
I think consult-imenu could use the breadcrumb-kind text properties to
show additional information in its live preview mode.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#69657; Package emacs. Full text available.

Message received at 69657 <at> debbugs.gnu.org:


Received: (at 69657) by debbugs.gnu.org; 9 Mar 2024 03:13:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 08 22:13:55 2024
Received: from localhost ([127.0.0.1]:60014 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rin9h-0002bH-Mv
	for submit <at> debbugs.gnu.org; Fri, 08 Mar 2024 22:13:55 -0500
Received: from mout-p-202.mailbox.org ([80.241.56.172]:52400)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sebastian.poeplau@HIDDEN>) id 1riisg-00045r-67
 for 69657 <at> debbugs.gnu.org; Fri, 08 Mar 2024 17:40:01 -0500
Received: from smtp102.mailbox.org (smtp102.mailbox.org
 [IPv6:2001:67c:2050:b231:465::102])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
 (No client certificate requested)
 by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4Ts1L01DLJz9spM;
 Fri,  8 Mar 2024 23:38:48 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org;
 s=mail20150812; t=1709937528;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 in-reply-to:in-reply-to:references:references;
 bh=YPz9PBEVXINbfhsQFhkZu7IS48haGKKwyAmNGJmlRmo=;
 b=O9QeUoV/viO9yXXQ4bRkPxsWheHsfdL/OCNI/Ka6TZSXEUCDRUDS1WL+ThOblqDliZsTbC
 GEZxl41djV1Gk5QP8b1mNk/luJA2zNsgNMUQzBQCq7Bc4a6QbhRRf3FLKYSrDKtjp0y/9x
 J6JsavUcquKC7f8h3vU8JIZcOAHk1M9NaWtOGGpJV/XkrTrpt4egw0bfgtBF86obMU3kIv
 win6M4INWEr3Q1OZf4Dx/4WFquGWyp4+GoCTZYy/nPvn9Rp4qmUmbzB47JUUuUPnBDTwyq
 cSW0DXsnSizmt7sg0shCn3FeG7VsqAtnU08cEfAJoFkJjQANMOP+twkHuEadVw==
References: <87frx0ze5n.fsf@HIDDEN> <87a5n8s8jw.fsf@HIDDEN>
From: Sebastian Poeplau <sebastian.poeplau@HIDDEN>
To: Felician Nemeth <felician.nemeth@HIDDEN>
Subject: Re: bug#69657: Missing imenu entries with eglot
Date: Fri, 08 Mar 2024 23:28:26 +0100
In-reply-to: <87a5n8s8jw.fsf@HIDDEN>
Message-ID: <87bk7oz6vc.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-MBO-RS-META: qocwwqgu3tqafzjb3kg6erx8737fm6n3
X-MBO-RS-ID: df0f2ab9927de61c4a3
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 69657
X-Mailman-Approved-At: Fri, 08 Mar 2024 22:13:44 -0500
Cc: 69657 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)


> How do you invoke imenu?

I did M-x imenu, although I should add that I normally use
consult-imenu, which presents a flattened menu. That's also what I wrote
the patch for.

> If I type M-x imenu-add-menubar-index RET, then I cannot select "Foo"
> as you wrote above. However, if I apply the patch, the menu looks
> exactly the same.

Indeed, it seems that for regular imenu the patch doesn't make a
difference (presumably because both the category and the symbol have the
same name). I had tested that the entry for "Foo" is absent, but I guess
i should have verified that it shows up with the patch. In any case, for
users of consult-imenu (and possibly others) there's a benefit, also in
terms of consistency with language servers that use SymbolInformation.

> On the other hand, the patch seems to ruin breadcrumb-mode: putting
> the point after "{}", the breadcrumb header line shows: "dir/test.cpp:
> Class > Foo" instead of the original "dir/test.cpp: Class > Foo >
> bar".

If you move point _after_ "{}", you're outside of method "bar", aren't
you? Doesn't that mean the breadcrumb header is correct now and was
wrong before?

> $ clangd --version
> Debian clangd version 14.0.6
> Features: linux+grpc

I tested with clangd 15 from the Ubuntu repositories and clangd 17 from
the repositories maintained by the LLVM project (for Ubuntu and Debian).
But I don't think this is a matter of clangd versions; for the record,
this is the textDocument/documentSymbol response I'm getting for the
example in my original message:

{
  "id": 5,
  "jsonrpc": "2.0",
  "result": [
    {
      "children": [
        {
          "detail": "void ()",
          "kind": 6,
          "name": "bar",
          "range": {
            "end": {
              "character": 15,
              "line": 1
            },
            "start": {
              "character": 2,
              "line": 1
            }
          },
          "selectionRange": {
            "end": {
              "character": 10,
              "line": 1
            },
            "start": {
              "character": 7,
              "line": 1
            }
          }
        }
      ],
      "detail": "class",
      "kind": 5,
      "name": "Foo",
      "range": {
        "end": {
          "character": 1,
          "line": 2
        },
        "start": {
          "character": 0,
          "line": 0
        }
      },
      "selectionRange": {
        "end": {
          "character": 9,
          "line": 0
        },
        "start": {
          "character": 6,
          "line": 0
        }
      }
    }
  ]
}




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#69657; Package emacs. Full text available.

Message received at 69657 <at> debbugs.gnu.org:


Received: (at 69657) by debbugs.gnu.org; 8 Mar 2024 21:46:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 08 16:46:03 2024
Received: from localhost ([127.0.0.1]:59808 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rii2V-0002c5-2K
	for submit <at> debbugs.gnu.org; Fri, 08 Mar 2024 16:46:03 -0500
Received: from mail-lj1-f179.google.com ([209.85.208.179]:56713)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <felician.nemeth@HIDDEN>) id 1rii2S-0002ba-MC
 for 69657 <at> debbugs.gnu.org; Fri, 08 Mar 2024 16:46:01 -0500
Received: by mail-lj1-f179.google.com with SMTP id
 38308e7fff4ca-2d27184197cso31457841fa.1
 for <69657 <at> debbugs.gnu.org>; Fri, 08 Mar 2024 13:45:28 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1709934262; x=1710539062; darn=debbugs.gnu.org;
 h=mime-version:face:user-agent:message-id:in-reply-to:date:references
 :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to;
 bh=YJ5xQn4LUGH8+WDU1Qu37CehJJ6XW/CQmyQdxu1xjk8=;
 b=cvmZs5zzYpONdDA09BR5r6ohJ1s4clNNpmT/fJLLfKboqPL31jRFYl4RXqcKFvwJtD
 Vx30L2iu4wJa0qxpuaSqw1FSZGxOAiCbUGRI6/UARBae1LIS4lMvFot/d+n+BwwNnSCE
 RXZ3IjGXVBq8UPATgBO5JYyk+xPcFA6nUSN9MhbKWKjVjDfM3xRd63P+NrDDLBMZf9u4
 lD3J+/08+A21F926ookUBouaiksO2pIox7OIP0Xr1q71pen7Z380UaSrp2Xi31LAXKzl
 R7s3vGSnWXGSc3ul1ptgXpU17/BwiSUn2jDLs72OGqA0dvQbDjZK5+Vx7a6wluux+yhT
 ZsJw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1709934262; x=1710539062;
 h=mime-version:face:user-agent:message-id:in-reply-to:date:references
 :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date
 :message-id:reply-to;
 bh=YJ5xQn4LUGH8+WDU1Qu37CehJJ6XW/CQmyQdxu1xjk8=;
 b=Jf0jz9BHcGuaGTkVmnZxMpN5AKvjPvabu15/JEHGxxTOAkShkdKU2TIo0H5jJkZeeu
 VtF05j6GNkgzK+1pe3oe+FXhKfaVobdL5FYjeHWWwLY/oVo1Ge58+woyqKdclVbdUINm
 xjc30dTfUFQB+/lBwq/hwTQN79eAafL9D+Xq9BcKckzXRZTDdSHhAKt8SAPRziJM+fCS
 oBq//GtiCtVbtLDrKl2we1fzfyWDdKTc2YsxSPsXG+Ugn1vO6f2eqZxOQ0RiQopZbVDw
 I963u2erWjp9n13Xy3FTcuI0KDV3tBDv2VJVavA/DTbVUN0gaaSvTzYc5jHVEEM+Rq8b
 tpNA==
X-Gm-Message-State: AOJu0YyKcQT57WKHSmOtMQGV/HEmajKHwO5NkBFEZofdkZJpTVlXn7XA
 bwCdFNIa94G1q5HyG6AodgiXUTFVapZTIgeFaImXsJL8V786y5VpShCqveRO
X-Google-Smtp-Source: AGHT+IEoJeAnl8uFEbLAIFemnlzwCvb5ngxKQ0wW9mPE1vPbaH5WSjJtC4AzvkTzr4PstyFeuhiF3w==
X-Received: by 2002:a2e:9357:0:b0:2d2:a2f5:5970 with SMTP id
 m23-20020a2e9357000000b002d2a2f55970mr318871ljh.27.1709934261272; 
 Fri, 08 Mar 2024 13:44:21 -0800 (PST)
Received: from betli.gmail.com (catv-213-222-160-137.catv.fixed.vodafone.hu.
 [213.222.160.137]) by smtp.gmail.com with ESMTPSA id
 x1-20020a056402414100b005683b6d8809sm66832eda.19.2024.03.08.13.44.20
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 08 Mar 2024 13:44:20 -0800 (PST)
From: Felician Nemeth <felician.nemeth@HIDDEN>
To: Sebastian Poeplau <sebastian.poeplau@HIDDEN>
Subject: Re: bug#69657: Missing imenu entries with eglot
References: <87frx0ze5n.fsf@HIDDEN>
Date: Fri, 08 Mar 2024 22:44:19 +0100
In-Reply-To: <87frx0ze5n.fsf@HIDDEN> (Sebastian Poeplau via's message of
 "Fri, 08 Mar 2024 21:01:24 +0100")
Message-ID: <87a5n8s8jw.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAElBMVEWOdXElERN7LDLZs6/l
 0dDQq6TepMcqAAACW0lEQVQ4jWWSzY7bMAyEaSm6mypylxjkroTRvUW8d9lavf+r7NDOZotWQHzg
 lyGHP0Sn5ed9qKrLWWIWos9/QJWIeCSywPNTd/AE0LtwFj7A+3WT5PwfeBrQKcsBnkfwVcNySWQr
 3i34XN6gRNgis/v4uwSKHCD9lPitB0Aq9BHfHX4cgsI7cJJfLdZg/4bbCzoRmkD9MsagQSBDedZi
 CgNxkVSJmSOStTBUBKkywEnEoZzbwWj+ACiVJkF6pOpak2PMCqkMYDpaw+gatLR8atMOrB3JGzmm
 3rSQo+tkxU+UAbhQSgtslULhsXKk6+IyQ1QTzeQB0MzjlpkCEUCeUdviWrwBcxVqpZjP+v0MYPA0
 aq2rvIEZe4GRM0v+9QIB03rsABVSk5y+Mz3LSzExtJLlCCO6dV1uzDQFTBad+gO0TqqL9XE8x4ek
 +orvYiMJgzC8e+r6TqaPaK6QyqVNvoHtsRrooQ6tTi4vgaSkd8wIikodB3B0iIk58avsDdYNajpS
 bSKJ+mQnipGszB6zW4lGgsOkKHE2RWVcBpwhaIv3BYIAu3WsnC7YYKLRchp6w8fRGZIWiZuFsVai
 7gbcUcJEhiDZ3K1+uzZvBlfaEO8oH4MLu6/hrKVM7QpQcIXJFuC1XjfbfKRxNslk94l9cYcEihV2
 HWyNDQAXaLsvnrSyp7HaQhrAn13V6/XW11nh0XINBOEAV+tHK4EvAGNGvEwc0eZw8Vyr56imYEsV
 sOW9jxm/yb9AH1ufqGMviIK7A0Tc/723oM3tJ4HTOu9gDr3ftbdkxfdjsUv5AqWKwyfCYo5WAAAA
 AElFTkSuQmCC
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 69657
Cc: 69657 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> 1. Put this code in a C++ source file, e.g., test.cpp:
>
>    class Foo {
>      void bar() {}
>    };
>
> 2. Start eglot with clangd.
> 3. Invoke imenu; there will be a single entry "bar", nested under "Foo".
>    In particular, there is no entry that lets you jump to Foo.

How do you invoke imenu?  If I type M-x imenu-add-menubar-index RET,
then I cannot select "Foo" as you wrote above.  However, if I apply the
patch, the menu looks exactly the same.  On the other hand, the patch
seems to ruin breadcrumb-mode: putting the point after "{}", the
breadcrumb header line shows: "dir/test.cpp: Class > Foo" instead of the
original "dir/test.cpp: Class > Foo > bar".

$ clangd --version
Debian clangd version 14.0.6
Features: linux+grpc




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#69657; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 8 Mar 2024 20:32:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 08 15:32:12 2024
Received: from localhost ([127.0.0.1]:59709 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rigt0-00037K-TH
	for submit <at> debbugs.gnu.org; Fri, 08 Mar 2024 15:32:12 -0500
Received: from lists.gnu.org ([209.51.188.17]:45926)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sebastian.poeplau@HIDDEN>) id 1rigQ2-0002B6-FM
 for submit <at> debbugs.gnu.org; Fri, 08 Mar 2024 15:02:17 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <sebastian.poeplau@HIDDEN>)
 id 1rigPU-000800-Vo
 for bug-gnu-emacs@HIDDEN; Fri, 08 Mar 2024 15:01:41 -0500
Received: from mout-p-202.mailbox.org ([2001:67c:2050:0:465::202])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256)
 (Exim 4.90_1) (envelope-from <sebastian.poeplau@HIDDEN>)
 id 1rigPS-0007a9-K8
 for bug-gnu-emacs@HIDDEN; Fri, 08 Mar 2024 15:01:40 -0500
Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
 (No client certificate requested)
 by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4TrxrV24M3z9sSV
 for <bug-gnu-emacs@HIDDEN>; Fri,  8 Mar 2024 21:01:30 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org;
 s=mail20150812; t=1709928090;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type;
 bh=G5Ic7Q6x1tFTmh7lQXcqraxdmh1b0VW3AyIAWYm/Zpo=;
 b=Kj8KyB0zMd7kbBr9tgcxT2MjKr4mFXUgHmR5d26xoB+/Q0s2Te6g5cwl8PCzrwdx4bYbj8
 aFwRs6ski0rlPykCZuXJEP9dfGqD5tPKlE3zWSd6qWraYpYZuEHTPxjpec10KChOaAme0H
 thyB2zk6e1JUcjztF4WsAOMDWhgr2uE5Ijbc3xeyYa7O3mP/8hhkImoRGSw3QUhgkKpBmE
 bqbSt0DVkO4AWUxLHxOAq5xOyi93BZnUQo6WXXKs29YL03b1ixm3/A2pOX18MF989YlaTu
 J55SszqPdYTPxYt6kTnus/nRGa6UjTmqHag3IRYeEp8StkI0Tm8Cgw/zdcUdtg==
From: Sebastian Poeplau <sebastian.poeplau@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: Missing imenu entries with eglot
Date: Fri, 08 Mar 2024 21:01:24 +0100
Message-ID: <87frx0ze5n.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-MBO-RS-ID: 9ead0157ce2e62f9060
X-MBO-RS-META: 9t4zy4g5oipa4h6bffr9uz3ax71b5hsu
Received-SPF: pass client-ip=2001:67c:2050:0:465::202;
 envelope-from=sebastian.poeplau@HIDDEN; helo=mout-p-202.mailbox.org
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Fri, 08 Mar 2024 15:32:09 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--=-=-=
Content-Type: text/plain

For language servers that reply to the textDocument/documentSymbol
request with instances of DocumentSymbol rather than SymbolInformation,
eglot's imenu builder omits symbols containing other symbols. This
applies to eglot 1.17 from ELPA as well as the version in Emacs master
as of today.

You can use clangd to reproduce the problem:

1. Put this code in a C++ source file, e.g., test.cpp:

   class Foo {
     void bar() {}
   };

2. Start eglot with clangd.
3. Invoke imenu; there will be a single entry "bar", nested under "Foo".
   In particular, there is no entry that lets you jump to Foo.

This is inconsistent with how eglot handles language servers that return
SymbolInformation (e.g., pylsp), and I would argue that it's not what
users expect. The attached patch fixes the behavior by inserting a
dedicated entry for each symbol in addition to entries for its children.


--=-=-=
Content-Type: text/x-diff
Content-Disposition: attachment;
 filename=0001-Eglot-include-containers-in-imenu.patch

From 953372f4cb1eea435a21a66e72226c7b2a6be51b Mon Sep 17 00:00:00 2001
From: Sebastian Poeplau <sebastian.poeplau@HIDDEN>
Date: Fri, 8 Mar 2024 16:29:25 +0100
Subject: [PATCH] Eglot: include containers in imenu

When the language server provides symbols as instances of
DocumentSymbol, eglot now includes containers (i.e., symbols with
children) in the imenu listing. This is consistent with eglot's behavior
when symbols are given as SymbolInformation objects.

* lisp/progmodes/eglot.el (eglot--imenu-DocumentSymbol): Include an
entry for symbols with children.
---
 lisp/progmodes/eglot.el | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index f341428cac3..87366811efd 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -3454,10 +3454,13 @@ for which LSP on-type-formatting should be requested."
                                          'breadcrumb-region reg
                                          'breadcrumb-kind kind)))
                   (if (seq-empty-p children)
-                      (cons name (car reg))
-                    (cons name
-                            (mapcar (lambda (c) (apply #'dfs c)) children))))))
-    (mapcar (lambda (s) (apply #'dfs s)) res)))
+                      (list (cons name (car reg)))
+                    (list (cons name (car reg))
+                          (cons name
+                                (mapcan (lambda (c)
+                                          (apply #'dfs c))
+                                        children)))))))
+    (mapcan (lambda (s) (apply #'dfs s)) res)))
 
 (cl-defun eglot-imenu ()
   "Eglot's `imenu-create-index-function'.
-- 
2.43.2


--=-=-=--




Acknowledgement sent to Sebastian Poeplau <sebastian.poeplau@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#69657; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 10 Mar 2024 01:15:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.