branch: elpa/flx commit 8605b4b4212194e5e46805a36dd9ed2219cc2c2b Author: Le Wang <le.w...@agworld.com.au> Commit: Le Wang <le.w...@agworld.com.au>
don't do caching when reading file names #3 --- flx-ido.el | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/flx-ido.el b/flx-ido.el index 2fd0193050..e25d25acb6 100644 --- a/flx-ido.el +++ b/flx-ido.el @@ -13,7 +13,7 @@ ;; Version: 0.1 ;; Last-Updated: ;; By: -;; Update #: 9 +;; Update #: 12 ;; URL: ;; Keywords: ;; Compatibility: @@ -111,27 +111,33 @@ (nthcdr decorate-count things) (mapcar 'car (nthcdr decorate-count things)))))) +(defun flx-ido-match-internal (query items) + (let* ((matches (loop for item in items + for score = (flx-score item query flx-file-cache) + if score + collect (cons item score) + into matches + finally return matches))) + (flx-ido-decorate (sort matches + (lambda (x y) (> (cadr x) (cadr y))))))) + (defun flx-ido-match (query items) "Better sorting for flx ido matching." - (when (and (equal "" query) - (not (gethash query flx-ido-narrowed-matches-hash))) - ;; original function reverses list. - (setq items (nreverse items)) - (puthash query items flx-ido-narrowed-matches-hash)) - (destructuring-bind (exact items) - (flx-ido-narrowed query items) - (if exact ; `ido-rotate' case is covered by exact match - items - (let* ((matches (loop for item in items - for score = (flx-score item query flx-file-cache) - if score - collect (cons item score) - into matches - finally return matches)) - res) - (setq res (flx-ido-decorate (sort matches - (lambda (x y) (> (cadr x) (cadr y)))))) - (puthash query res flx-ido-narrowed-matches-hash))))) + (if (memq ido-cur-item '(file dir)) + (if (equal "" query) + (nreverse items) + (flx-ido-match-internal query items)) + (when (and (equal "" query) + (not (gethash query flx-ido-narrowed-matches-hash))) + ;; original function reverses list. + (setq items (nreverse items)) + (puthash query items flx-ido-narrowed-matches-hash)) + (destructuring-bind (exact items) + (flx-ido-narrowed query items) + (if exact ; `ido-rotate' case is covered by exact match + items + (puthash query (flx-ido-match-internal query items) + flx-ido-narrowed-matches-hash))))) (defvar flx-ido-use t "Use flx matching for ido.")