]> git.eshelyaron.com Git - emacs.git/commit
Allow completion styles to adjust completion metadata
authorJoão Távora <joaotavora@gmail.com>
Fri, 25 Oct 2019 22:57:44 +0000 (23:57 +0100)
committerJoão Távora <joaotavora@gmail.com>
Sat, 26 Oct 2019 12:09:52 +0000 (13:09 +0100)
commit7fc0292f5c49d11fc39853f8bc25586d54221e6a
tree807713e2e4c8585553f357a0acd9057a749c1171
parente3cebbb839fc94f314659bf667c6790edebf4297
Allow completion styles to adjust completion metadata

The new facility, realized in the completion-adjust-metadata-for-style
generic, allows completion styles to have a say in metadata properties
such as cycle-sort-function and display-sort-function.  This is
especially useful for completion styles such as 'flex', which
generally produce many matches, including some potentially "obscure"
ones.  The default sorting strategy would often bubble the latter
to the top of the list.

The sorting function for 'flex' considers pre-computed matching scores
and is thus much better than the default for this particular style.

Additionally, it overrides the completion table's cycle-sort-function
or display-sort-function properties if they exist, although it still
uses them to pre-sort the result, so that they are still relevant for
resolving ties.

* lisp/minibuffer.el (completion--nth-completion): Call
completion-adjust-metadata-for-style.
(completion-adjust-metadata-for-style): New generic.
(completion-adjust-metadata-for-style 'flex): New method.
lisp/minibuffer.el