From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.help Subject: Re: Sorting Order of Completion Candidates Date: Tue, 01 Mar 2011 13:25:47 -0600 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <87sjv6skw4.fsf@lifelogs.com> References: <4D6BB13E.3040404@miszellen.de> <87aahevm69.fsf@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1299009803 11173 80.91.229.12 (1 Mar 2011 20:03:23 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 1 Mar 2011 20:03:23 +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 21:03:17 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 1PuVmv-0006Bk-Bw for geh-help-gnu-emacs@m.gmane.org; Tue, 01 Mar 2011 21:03:17 +0100 Original-Received: from localhost ([127.0.0.1]:39778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PuVTI-0004r9-T9 for geh-help-gnu-emacs@m.gmane.org; Tue, 01 Mar 2011 14:43:00 -0500 Original-Path: usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!t-online.de!78.46.73.112.MISMATCH!news.schnuerpel.eu!news.albasani.net!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 35 Original-X-Trace: news.albasani.net mKEP3uonxCaxomQx2TO1vJvvJX/CjIGqGlylraTSE0ZKQFW5nYcyYjiL0jY4KF9LgjvDT0dVoLqgbDF1QcIC+g== Original-NNTP-Posting-Date: Tue, 1 Mar 2011 19:25:47 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="TKQ+U7IclMYqOGTVW3qGYIVXlubud4imOyI9GKg+lM/qhOIMT12U7rXElvxzyHXgQW9Zlx7R4UZvE4UT9PsA2LH6KGU/YHzmP1xVvc+DmILxNhCmi2L+47UI209YHmqG"; mail-complaints-to="abuse@albasani.net" User-Agent: Gnus/5.110014 (No Gnus v0.14) Emacs/24.0.50 (gnu/linux) X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" Cancel-Lock: sha1:BUP7Ll52h/3/NiZiIgpklhs1QlA= sha1:UtPRpA1OUxCS44zAigWxPoKw8oo= Original-Xref: usenet.stanford.edu gnu.emacs.help:185502 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:79651 Archived-At: 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