help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting Order of Completion Candidates


From: Florian Beck
Subject: Re: Sorting Order of Completion Candidates
Date: Tue, 01 Mar 2011 21:41:11 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7

On 03/01/2011 08:25 PM, Ted Zlatanov wrote:
On Tue, 01 Mar 2011 19:22:47 +0100 Florian Beck<fb@miszellen.de>  wrote:

FB>  On 03/01/2011 05:29 PM, Ted Zlatanov wrote:
Florian: I've proposed a patch to use the string property
:completion-score to attach a numerical score to the completion
candidates.  The discussion so far is in the BBDB mailing list (where we
needed to score completion candidates) but I will propose it on
emacs-devel once Stefan reviews it.

FB>  Nice idea. You mean text properties on the strings?

FB>  So I would use something like

FB>  (defun string-score-higher (a b)
FB>    (if (>  (or (get-text-property 0 :completion-score a) 0)
FB>          (or (get-text-property 0 :completion-score b) 0))
FB>        a
FB>      (string-lessp a b)))

FB>  as a sorting predicate?

FB>  Seems to work (so far),

With my proposal it will be built into
`completion-all-sorted-completions':

- if both candidates have a :completion-score, lowest wins

- if only one has :completion-score, it wins

- else we sort by string length (shortest wins)

Thus you don't have to craft custom sort predicates :)

Ted


Hm, intuitively, I would think higher scored items come first.

Anyway, I tried modifying `completion-all-sorted-completions' but it had no effect, because the candidates are sorted in `minibuffer-completion-help'. I guess, you will override that -- but why sort there in the first place? All sorting should take place is `completion-all-sorted-completions', shouldn't it?

Also, both for reasons of performance and convenience, an option not to sort candidates at all might be desirable.

--
Florian




reply via email to

[Prev in Thread] Current Thread [Next in Thread]