Subject: Re: bug#73117: 30.0.90; Imenu missing entries when flattening by group

From: Troy Brown <[email-masked]>
Date: Sun, 5 Jan 2025 19:15:47 -0500

On Sat, Sep 28, 2024 at 5:20 AM Eli Zaretskii <[email-masked]> wrote:
>
> > Cc: [email-masked], Daniel Mendler <[email-masked]>
> > From: Juri Linkov <[email-masked]>
> > Date: Fri, 20 Sep 2024 09:58:24 +0300
> >
> > > The following example configures `imenu-flatten" to "group" and then
> > > shows the menu, first with `completions-format` set to "horizontal"
> > > and then "vertical".
> > >
> > > ```elisp
> > > (progn
> > >   (setopt completions-group t)
> > >   (setopt imenu-eager-completion-buffer nil)
> > >   (setopt minibuffer-visible-completions t)
> > >   (setopt imenu-flatten 'group)
> > >
> > >   (require 'imenu)
> > >
> > >   (dolist (format '(horizontal vertical))
> > >     (setopt completions-format format)
> >
> > Any fixes for completion--insert-horizontal should be pushed
> > only to master, not to the release branch.
> >
> > But for the release branch we should push the documentation fixes
> > that will mention all prerequisites for this feature to work
> > correctly:
>
> Feel free to install on the release branch, and thanks.

While discussing a similar issue for Vertico here
(https://github.com/minad/vertico/discussions/553), Daniel discovered
that icomplete-mode also won't display all of the grouped candidates.
The following is a reproducer which can be used to demonstrate this
issue.  In the reproducer, the first time through the loop,
icomplete-mode is not enabled and the completion buffer shows all four
possible candidates along with their corresponding groups, however the
next time through the loop, icomplete-vertical-mode is enabled and
only 3 of the 4 candidates are displayed.  See his comments in the
provided link for his take on the issue as well as his discovery of
yet more places that groups don't seem to work correctly (e.g.,
completion--insert-column).

```elisp
(progn
  (setopt completions-group t)
  (setopt completions-format 'vertical)
  (setopt imenu-flatten 'group)
  (setopt icomplete-show-matches-on-no-input t)

  (require 'imenu)

  (dolist (arg '(-1 +1))
    (icomplete-mode arg)
    (icomplete-vertical-mode arg)
    (setopt imenu-eager-completion-buffer icomplete-vertical-mode)
    (imenu-choose-buffer-index (format "(icomplete-vertical-mode = %s)
Index item: " icomplete-vertical-mode)
                               `(("XYZ" . (("123" . ,(point-min-marker))))
                                 ("ABC" . (("124" . ,(point-min-marker))))
                                 ("Bar" . (("Foo" . ,(point-min-marker))))
                                 ("Baz" . (("Foo" . ,(point-max-marker))))))))
```