From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Antoine Levitt Newsgroups: gmane.emacs.bbdb.user,gmane.emacs.devel Subject: Re: (patch) sort cycling completion candidates Date: Tue, 08 Mar 2011 16:32:00 +0100 Message-ID: <87y64paarz.fsf@gmail.com> References: <87wrlfv9vs.fsf@gmail.com> <19790.55748.877481.348512@gargle.gargle.HOWL> <87r5bljcf1.fsf@gmail.com> <19797.17272.589272.209237@gargle.gargle.HOWL> <19797.51331.541498.485483@gargle.gargle.HOWL> <19798.51132.460403.212914@gargle.gargle.HOWL> <8739nr3ni1.fsf@lifelogs.com> <19800.2420.143963.914603@gargle.gargle.HOWL> <87bp2aziyf.fsf@lifelogs.com> <87bp22ldxh.fsf@lifelogs.com> <19818.50284.187613.9352@gargle.gargle.HOWL> <87fwr82gpg.fsf@lifelogs.com> <87lj0yvodp.fsf@lifelogs.com> <87mxl5bqcg.fsf@jumptrading.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1299598433 5742 80.91.229.12 (8 Mar 2011 15:33:53 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 8 Mar 2011 15:33:53 +0000 (UTC) Cc: emacs-devel@gnu.org To: bbdb-info@lists.sourceforge.net Original-X-From: bbdb-info-bounces@lists.sourceforge.net Tue Mar 08 16:33:49 2011 Return-path: Envelope-to: bbdb-user@m.gmane.org Original-Received: from lists.sourceforge.net ([216.34.181.88]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Pwyuy-0005V6-Cb for bbdb-user@m.gmane.org; Tue, 08 Mar 2011 16:33:48 +0100 Original-Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.74) (envelope-from ) id 1Pwyu1-00037g-5L; Tue, 08 Mar 2011 15:32:49 +0000 Original-Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.74) (envelope-from ) id 1Pwyu0-00037U-5o for bbdb-info@lists.sourceforge.net; Tue, 08 Mar 2011 15:32:48 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of m.gmane.org designates 80.91.229.12 as permitted sender) client-ip=80.91.229.12; envelope-from=bbdb-user@m.gmane.org; helo=lo.gmane.org; Original-Received: from lo.gmane.org ([80.91.229.12]) by sog-mx-4.v43.ch3.sourceforge.com with esmtp (Exim 4.74) id 1Pwytz-0005X2-4Y for bbdb-info@lists.sourceforge.net; Tue, 08 Mar 2011 15:32:48 +0000 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Pwytn-0004vT-5g for bbdb-info@lists.sourceforge.net; Tue, 08 Mar 2011 16:32:35 +0100 Original-Received: from portable115.ceremade.dauphine.fr ([193.48.71.115]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 08 Mar 2011 16:32:35 +0100 Original-Received: from antoine.levitt by portable115.ceremade.dauphine.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 08 Mar 2011 16:32:35 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 64 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: portable115.ceremade.dauphine.fr User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-Spam-Score: -0.3 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is freemail (antoine.levitt[at]gmail.com) -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is CUSTOM_MED -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record 1.2 NML_ADSP_CUSTOM_MED ADSP custom_med hit, and not from a mailing list 0.0 T_TO_NO_BRKTS_FREEMAIL T_TO_NO_BRKTS_FREEMAIL X-Headers-End: 1Pwytz-0005X2-4Y X-BeenThere: bbdb-info@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: "Bugs, help, discussion about BBDB" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bbdb-info-bounces@lists.sourceforge.net Xref: news.gmane.org gmane.emacs.bbdb.user:2515 gmane.emacs.devel:136888 Archived-At: 08/03/11 16:10, Ted Zlatanov > Attached please find a patch to sort cycling completion candidates by > the text property :completion-cycle-penalty (lower is better). > > Thanks > Ted > > > === modified file 'lisp/minibuffer.el' > --- lisp/minibuffer.el 2011-02-12 18:30:13 +0000 > +++ lisp/minibuffer.el 2011-03-08 14:51:07 +0000 > @@ -704,7 +704,19 @@ > (when last > (setcdr last nil) > ;; Prefer shorter completions. > - (setq all (sort all (lambda (c1 c2) (< (length c1) (length c2))))) > + (setq > + all > + (sort all > + (lambda (c1 c2) > + (let ((s1 (get-text-property > + 0 :completion-cycle-penalty c1)) > + (s2 (get-text-property > + 0 :completion-cycle-penalty c2))) > + (cond ((and s1 s2) (cond ((< s1 s2) t) > + ((> s1 s2) nil) > + (t (< (length c1) (length c2))))) > + (s1 t) > + (s2 nil)))))) > ;; Prefer recently used completions. > (let ((hist (symbol-value minibuffer-history-variable))) > (setq all (sort all (lambda (c1 c2) What about the case when s1 and s2 are nil? Shouldn't there be another (t (< (length c1) (length c2))) at the end of the second cond ? Am I missing something? It seems cleaner to sort two times, instead of once with both predicates, the way it's already done in the code for recently used completions. Also, the comment needs changing. What about this? diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 3c8628c..f4af7f3 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -710,6 +710,13 @@ scroll the window of possible completions." (setq all (sort all (lambda (c1 c2) (> (length (member c1 hist)) (length (member c2 hist))))))) + ;; Use the completion-cycle-penalty property + (setq all (sort all (lambda (c1 c2) + (let ((s1 (get-text-property + 0 :completion-cycle-penalty c1)) + (s2 (get-text-property + 0 :completion-cycle-penalty c2))) + (and s1 (or (not s2) (< s1 s2))))))) ;; Cache the result. This is not just for speed, but also so that ;; repeated calls to minibuffer-force-complete can cycle through ;; all possibilities. ------------------------------------------------------------------------------ What You Don't Know About Data Connectivity CAN Hurt You This paper provides an overview of data connectivity, details its effect on application quality, and explores various alternative solutions. http://p.sf.net/sfu/progress-d2d _______________________________________________ bbdb-info@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bbdb-info BBDB Home Page: http://bbdb.sourceforge.net/