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/