=== 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)