[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (patch) sort cycling completion candidates
From: |
Stefan Monnier |
Subject: |
Re: (patch) sort cycling completion candidates |
Date: |
Mon, 14 Mar 2011 22:59:15 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
> I am in favor of Antoine's patch: it fixes a bug and is cleaner, but I'm
> citing both for completeness.
Taking a closer look at those patches, I now wonder: should it take
precedence over the "recently used" preference, as Antoine's does,
or not? I'd tend to think it should not, as in the patch below.
Stefan
=== modified file 'lisp/minibuffer.el'
--- lisp/minibuffer.el 2011-02-12 18:30:13 +0000
+++ lisp/minibuffer.el 2011-03-15 02:58:25 +0000
@@ -704,7 +704,15 @@
(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)))
+ (if (eq s1 s2)
+ (< (length c1) (length c2))
+ (< (or s1 (length c1))
+ (or s2 (length c2))))))))
;; Prefer recently used completions.
(let ((hist (symbol-value minibuffer-history-variable)))
(setq all (sort all (lambda (c1 c2)