GNU bug report logs -
#48545
28.0.50; `icomplete-vertical-mode` does not support the `group-function`
Previous Next
Reported by: Daniel Mendler <mail <at> daniel-mendler.de>
Date: Thu, 20 May 2021 18:57:02 UTC
Severity: normal
Found in version 28.0.50
Done: João Távora <joaotavora <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Thu, 19 Aug 2021 12:18:55 +0100
with message-id <871r6pr8bk.fsf <at> gmail.com>
and subject line Re: bug#48545: 28.0.50; `icomplete-vertical-mode` does not support the `group-function`
has caused the debbugs.gnu.org bug report #48545,
regarding 28.0.50; `icomplete-vertical-mode` does not support the `group-function`
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
48545: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=48545
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
The recently introduced `icomplete-vertical-mode` should support the
`group-function`, which can be specified by the completion metadata. The
group function allows grouping the completion candidates by group titles.
Additional to the default completion UI, support for group functions is
already present in the following vertical minibuffer UIs, which are
similar to `icomplete-vertical-mode`: Vertico (GNU ELPA), Selectrum
(MELPA) and Icomplete-vertical (MELPA).
[Message part 3 (message/rfc822, inline)]
[Dmitry, I've tagged you since you're generally interested in this
stuff.]
João Távora <joaotavora <at> gmail.com> writes:
> Kévin Le Gouguec <kevin.legouguec <at> gmail.com> writes:
>> I think Daniel is referring to what happens if you set completions-group
>> to t and type e.g. C-x 8 RET ROMAN TAB TAB (without icomplete): you will
>> see two "sections" titled 'symbol' and 'ancient-symbol'.
> Thanks you, easy to reproduce and see clearly what you mean now
I've pushed this feature. This is how I tested:
src/emacs -Q --eval '(setq completions-group t)' \
--eval '(setq xref-show-definitions-function (quote xref-show-definitions-completing-read))'
-f fido-vertical-mode
C-U M-. xref-location-marker RET
This should produce 5 locations. It shows, with section headers, how 4
of these belong to xref.el and 1 belongs to elisp-mode.el. When typing
a pattern which leads to filtering (e.g. with flex) sections are
preserved. Sane scrolling should also be maintained, though this was
complicated to get right and may still have some bugs (I haven't
noticed any yet.)
I noticed a quirk, though. If I add '-l etags' to the 'emacs -Q' line,
one gets 6 matches instead of 5 (due to etags having another
xref-location-marker). That's fine, but due to the default
alphanumeric/length sorting, it gets shoved into the group of xref.el
matches and thus we get two xref.el groups. I.e. it looks like
xref.el
(cl-defgeneric xref-location-marker)
(cl-defmethod xref-location-marker ((l xref-file-location)))
(cl-defmethod xref-location-marker ((l xref-bogus-location)))
etags.el
(cl-defmethod xref-location-marker ((l xref-etags-location)))
xref.el
(cl-defmethod xref-location-marker ((l xref-buffer-location)))
elisp-mode.el
(cl-defmethod xref-location-marker ((l xref-elisp-location)))
I don't use completions-group so I don't care strongly for this, but I
believe that this is generally undesired, for non-filtering scenarios.
All the entries from the xref.el group should probably be clumped
together. If a user were flex-matching and thus expecting certain sort
score-based order, it _would_ make sense to me, but here no flexy things
were happening at all.
To fix this, perhaps the default sorting methods should be turned off in
completion-all-sorted-completions in minibuffer.el if a table supplies
`group-function`. A patch for this is after my sig.
Alternatively, tables that do support `group-function` could also start
specifying:
(display-sort-function . identity)
I've tested both alternatives and they seem to do the right thing. But
this may be the subject for some other bug, if someone cares.
Anyway, I'm marking this closed this bug since its main work is done.
Feedback welcome, of course.
João
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index ffcd5d88ab..20fbc326a2 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1506,17 +1506,18 @@ completion-all-sorted-completions
(setq all (delete-dups all))
(setq last (last all))
- (if sort-fun
- (setq all (funcall sort-fun all))
- ;; Sort first by length and alphabetically.
- (setq all (minibuffer--sort-by-length-alpha all))
- ;; Sort by history position, put the default, if it
- ;; exists, on top.
- (when (minibufferp)
- (setq all (minibuffer--sort-by-position
- (minibuffer--sort-preprocess-history
- (substring string 0 base-size))
- all))))
+ (cond (sort-fun
+ (setq all (funcall sort-fun all)))
+ ((not (completion-metadata-get all-md 'group-function))
+ ;; Sort first by length and alphabetically.
+ (setq all (minibuffer--sort-by-length-alpha all))
+ ;; Sort by history position, put the default, if it
+ ;; exists, on top.
+ (when (minibufferp)
+ (setq all (minibuffer--sort-by-position
+ (minibuffer--sort-preprocess-history
+ (substring string 0 base-size))
+ all)))))
This bug report was last modified 3 years and 326 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.