From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Florian Beck Newsgroups: gmane.emacs.help Subject: Re: Sorting Order of Completion Candidates Date: Tue, 01 Mar 2011 21:41:11 +0100 Message-ID: References: <4D6BB13E.3040404@miszellen.de> <87aahevm69.fsf@lifelogs.com> <87sjv6skw4.fsf@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1299013727 1418 80.91.229.12 (1 Mar 2011 21:08:47 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 1 Mar 2011 21:08:47 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Mar 01 22:08:43 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PuWoF-0001BZ-6v for geh-help-gnu-emacs@m.gmane.org; Tue, 01 Mar 2011 22:08:43 +0100 Original-Received: from localhost ([127.0.0.1]:43079 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PuWT6-00076o-81 for geh-help-gnu-emacs@m.gmane.org; Tue, 01 Mar 2011 15:46:52 -0500 Original-Received: from [140.186.70.92] (port=35508 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PuWRq-0006JK-CI for help-gnu-emacs@gnu.org; Tue, 01 Mar 2011 15:45:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PuWRQ-0005b6-3t for help-gnu-emacs@gnu.org; Tue, 01 Mar 2011 15:45:09 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:53158) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PuWRP-0005am-QV for help-gnu-emacs@gnu.org; Tue, 01 Mar 2011 15:45:08 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PuWRM-00044d-Q9 for help-gnu-emacs@gnu.org; Tue, 01 Mar 2011 21:45:04 +0100 Original-Received: from p54996440.dip.t-dialin.net ([84.153.100.64]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 01 Mar 2011 21:45:04 +0100 Original-Received: from fb by p54996440.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 01 Mar 2011 21:45:04 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 51 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: p54996440.dip.t-dialin.net User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 In-Reply-To: <87sjv6skw4.fsf@lifelogs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:79654 Archived-At: On 03/01/2011 08:25 PM, Ted Zlatanov wrote: > On Tue, 01 Mar 2011 19:22:47 +0100 Florian Beck 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