From: "João Távora" <joaotavora@gmail.com>
To: "Kévin Le Gouguec" <kevin.legouguec@gmail.com>
Cc: Daniel Mendler <mail@daniel-mendler.de>,
Gregory Heytings <gregory@heytings.org>,
48545-done@debbugs.gnu.org, dgutov@yandex.ru
Subject: bug#48545: 28.0.50; `icomplete-vertical-mode` does not support the `group-function`
Date: Thu, 19 Aug 2021 12:18:55 +0100 [thread overview]
Message-ID: <871r6pr8bk.fsf@gmail.com> (raw)
In-Reply-To: <87eearulft.fsf@gmail.com> ("João Távora"'s message of "Wed, 18 Aug 2021 10:55:02 +0100")
[Dmitry, I've tagged you since you're generally interested in this
stuff.]
João Távora <joaotavora@gmail.com> writes:
> Kévin Le Gouguec <kevin.legouguec@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)))))
next prev parent reply other threads:[~2021-08-19 11:18 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-20 18:56 bug#48545: 28.0.50; `icomplete-vertical-mode` does not support the `group-function` Daniel Mendler
2021-08-17 12:17 ` João Távora
2021-08-18 9:38 ` Kévin Le Gouguec
2021-08-18 9:55 ` João Távora
2021-08-19 11:18 ` João Távora [this message]
2021-08-19 12:38 ` Kévin Le Gouguec
2021-08-19 13:29 ` João Távora
2021-08-19 19:36 ` Kévin Le Gouguec
2021-08-19 15:02 ` Dmitry Gutov
2021-08-19 19:41 ` João Távora
2021-08-19 22:37 ` Dmitry Gutov
2021-08-19 23:39 ` João Távora
2021-08-19 23:51 ` Dmitry Gutov
2021-08-20 10:35 ` João Távora
2021-08-21 2:09 ` Dmitry Gutov
2021-08-21 9:40 ` João Távora
2021-08-21 12:01 ` Dmitry Gutov
2021-08-21 12:42 ` João Távora
2021-08-22 13:52 ` Dmitry Gutov
2021-08-22 15:44 ` João Távora
2021-08-21 0:24 ` João Távora
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871r6pr8bk.fsf@gmail.com \
--to=joaotavora@gmail.com \
--cc=48545-done@debbugs.gnu.org \
--cc=dgutov@yandex.ru \
--cc=gregory@heytings.org \
--cc=kevin.legouguec@gmail.com \
--cc=mail@daniel-mendler.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.