From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>
Received: from mp2.migadu.com ([2001:41d0:700:3204::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by ms8.migadu.com with LMTPS
	id +LO6NJRFd2XkIQAAkFu2QA
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Mon, 11 Dec 2023 18:23:32 +0100
Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by mp2.migadu.com with LMTPS
	id yKavLJRFd2U7fwAAe85BDQ
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Mon, 11 Dec 2023 18:23:32 +0100
X-Envelope-To: larch@yhetil.org
Authentication-Results: aspmx1.migadu.com;
	dkim=none;
	spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org";
	dmarc=none
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org;
	s=key1; t=1702315412;
	h=from:from:sender:sender: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:list-id:list-help:list-unsubscribe:
	 list-subscribe:list-post; bh=epRfujYZ/vlXJnJXVVVh4u+E3qbcEksQ3iUYR6mMjto=;
	b=qyahRwOTaY9ldmU0vlNRRdJZtGtYys8q3hbyP0PpHqww3hrq/2pd297LUaslKPSSd64m6E
	aB1LGfRwcSzflvWNoXCGSdkKbffHfQpNvnWcA5v9IZxeZsBcOSnAb/4P2uY9MKNsqWY1kd
	LSj44W7NAnUvCcIPgj18Q38i5tyAU23aaId4Q7vZfbDvbD6vBGKYRLQ24EQJdrDC766IMM
	zGfdWbdw7YixrCozWgN3+4NtVqBno7ISO2vGCfePD6hIP3mCG3krJIRI6pDSvqSpJ2LFmt
	f1EAuHQy+IKCqzYBXdKWrhqpI9C6OPU/MpBJa3g2ExZRIEBBXB7lUeBmMHwWzw==
ARC-Seal: i=1; s=key1; d=yhetil.org; t=1702315412; a=rsa-sha256; cv=none;
	b=WR0jUyrpJ0xdQ/5U+TfQ1X+tl0qIVnCggQ8jXCRb7m/m1GSVgHQMssw9379wY2LoCO27ei
	t4s8N9Yn9zfP342LkTK87Z7HCzieMg0cHiENMhN52R2vngA0Km995qd+IzzoQWY6Y3TdvC
	Xz2oN2qMTX98cRRapvHtdBG5oNLpAYj+DEkqK0qJR2mnsf+KN5iR13irIM/AxJuGLBFmVC
	c2lEg8LhFu3I/VX/ara+qvnq+C9wdCeD0cClI7BrDjEhN7pTrgqTPOHSKeGgK+MGHSi3Kx
	InixxW7XyRIj3uXtJjuJmuinjB6yKqewl9uZvMOQe9FXpdeE15+qh3n5ViA0KQ==
ARC-Authentication-Results: i=1;
	aspmx1.migadu.com;
	dkim=none;
	spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org";
	dmarc=none
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by aspmx1.migadu.com (Postfix) with ESMTPS id 757123BA8A
	for <larch@yhetil.org>; Mon, 11 Dec 2023 18:23:32 +0100 (CET)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <emacs-orgmode-bounces@gnu.org>)
	id 1rCjya-0005Hy-Bn; Mon, 11 Dec 2023 12:21:52 -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 <juri@linkov.net>)
 id 1rCjyX-0005HI-I8; Mon, 11 Dec 2023 12:21:49 -0500
Received: from relay6-d.mail.gandi.net ([2001:4b98:dc4:8::226])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <juri@linkov.net>)
 id 1rCjyU-0002j5-9b; Mon, 11 Dec 2023 12:21:49 -0500
Received: by mail.gandi.net (Postfix) with ESMTPSA id AE18EC0006;
 Mon, 11 Dec 2023 17:21:41 +0000 (UTC)
From: Juri Linkov <juri@linkov.net>
To: =?iso-8859-1?Q?Jo=E3o_T=E1vora?= <joaotavora@gmail.com>
Cc: Ihor Radchenko <yantar92@posteo.net>,  Eli Zaretskii <eliz@gnu.org>,
 Morgan.J.Smith@outlook.com,  emacs-orgmode@gnu.org,
 58131@debbugs.gnu.org,  emacs-devel@gnu.org
Subject: Re: [FR] Allow flattened imenu index
In-Reply-To: <CALDnm51j9X6h2ipYamWUUnHW=fQ9oMRhzVBR1pxxRcUGmZuobQ@mail.gmail.com>
 (=?iso-8859-1?Q?=22Jo=E3o_T=E1vora=22's?= message of "Mon, 11 Dec 2023
 11:51:03 +0000")
Organization: LINKOV.NET
References: <CH3PR84MB34240DD3259A46D28C406019C58BA@CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM>
 <87plzgbalt.fsf@localhost>
 <CH3PR84MB3424C475913C9D2A3F9EDD73C589A@CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM>
 <87msujskxg.fsf@localhost> <835y17y5qu.fsf@gnu.org>
 <874jgrsiyy.fsf@localhost> <86r0jv8efr.fsf@mail.linkov.net>
 <CALDnm51j9X6h2ipYamWUUnHW=fQ9oMRhzVBR1pxxRcUGmZuobQ@mail.gmail.com>
Date: Mon, 11 Dec 2023 19:20:51 +0200
Message-ID: <86zfyg3jgs.fsf@mail.linkov.net>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain
X-GND-Sasl: juri@linkov.net
Received-SPF: pass client-ip=2001:4b98:dc4:8::226;
 envelope-from=juri@linkov.net; helo=relay6-d.mail.gandi.net
X-Spam_score_int: -25
X-Spam_score: -2.6
X-Spam_bar: --
X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7,
 SPF_HELO_PASS=-0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-BeenThere: emacs-orgmode@gnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "General discussions about Org-mode." <emacs-orgmode.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=subscribe>
Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org
Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org
X-Migadu-Flow: FLOW_IN
X-Migadu-Country: US
X-Migadu-Spam-Score: -1.51
X-Spam-Score: -1.51
X-Migadu-Queue-Id: 757123BA8A
X-Migadu-Scanner: mx11.migadu.com
X-TUID: WE9/MvgMafxW

>>   menu1
>>     sub-item1
>>     sub-item2
>>
>> could be flattened to
>>
>>   menu1 -> sub-item1
>>   menu1 -> sub-item2
>
> By the way, this seems to be exactly what the breadcrumb-jump command
> in my breadcrumb.el package does.  Goes reasonably well with a flex/fuzzy
> completion style.

It would be great to have some form of breadcrumb-jump in imenu.el
since it's useful on its own even for someone who doesn't use breadcrumbs.

> You can look at it for an implementation idea.  Just be sure to do this
> flattening at the presentation level (i.e. M-x imenu), not at the
> internal representation level.

Here are some observations while testing on
emacs/test/manual/etags/ruby-src/test.rb.

Both ruby-mode and ruby-ts-mode provide a list that is already flat:

ruby-mode:
  ModuleExample
  ModuleExample#ModuleExample.module_class_method
  ModuleExample#module_instance_method
  ModuleExample::ClassExample
  ModuleExample::ClassExample#+
  ModuleExample::ClassExample#ClassExample.class_method
  ModuleExample::ClassExample#instance_method

ruby-ts-mode:
  ModuleExample
  ModuleExample#module_instance_method
  ModuleExample.module_class_method
  ModuleExample::ClassExample
  ModuleExample::ClassExample#+
  ModuleExample::ClassExample#instance_method
  ModuleExample::ClassExample.class_method

When eglot is enabled then imenu-create-index-function returns a tree.

What is interesting is that breadcrumb-jump already correctly handles both
a flat list and a tree:

a flat list in breadcrumb-jump completions is exactly the same as in 'imenu':
  ModuleExample
  ModuleExample#module_instance_method
  ModuleExample.module_class_method
  ModuleExample::ClassExample
  ModuleExample::ClassExample#+
  ModuleExample::ClassExample#instance_method
  ModuleExample::ClassExample.class_method

a tree from eglot in breadcrumb-jump completions:
  Class > ModuleExample > ClassExample
  Method > ClassExample > class_method
  Method > ModuleExample > module_class_method
  Method > ModuleExample > module_instance_method
  Method > ModuleExample::ClassExample > +
  Method > ModuleExample::ClassExample > instance_method
  Module >  > ModuleExample

is still usable even without special characters like "#".

> It shouldn't be needed here at all, but in case anyone's thinking
> about it, please avoid messing with imenu's internal representation of
> hierarchies as that structure is relied upon by many extensions (not just
> mine, but several others).  Even certain things supported by certain
> imenu-presenting frontends (like "special elements") are not supported by
> other frontends.  It's a bit of a mess.  The symbols holding/describing
> this representation (imenu--index-alist, maybe others) are incorrectly
> named '--' but they are most definitely externally visible and used
> customization points.

Indeed, it's unfortunate that imenu--make-index-alist and imenu--index-alist
are named as internal.