branch: elpa/flx commit a1ac8f97ecb4a0cbb4764210048484fe96074c65 Author: Le Wang <le.w...@agworld.com.au> Commit: Le Wang <le.w...@agworld.com.au>
fix `ido-merge-work-directories` - items are cons cells of (basename . dirname) - match should be performed against basename - caching is skipped for the merge case - flx highlighting is disabled for merged case #10 --- flx-ido.el | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/flx-ido.el b/flx-ido.el index a8bea9df0d..d4940b1c7a 100644 --- a/flx-ido.el +++ b/flx-ido.el @@ -13,7 +13,7 @@ ;; Version: 0.1 ;; Last-Updated: ;; By: -;; Update #: 15 +;; Update #: 17 ;; URL: ;; Keywords: ;; Compatibility: @@ -117,22 +117,25 @@ item, in which case, the ending items are deleted." (defun flx-ido-decorate (things &optional clear) - (let ((decorate-count (min ido-max-prospects - (length things)))) - (nconc - (loop for thing in things - for i from 0 below decorate-count - collect (if clear - (substring-no-properties thing) - ;; copy the string in case it's "pure" - (flx-propertize (copy-sequence (car thing)) (cdr thing)))) - (if clear - (nthcdr decorate-count things) - (mapcar 'car (nthcdr decorate-count things)))))) + (if (consp (caar things)) + (mapcar 'car things) + (let ((decorate-count (min ido-max-prospects + (length things)))) + (nconc + (loop for thing in things + for i from 0 below decorate-count + collect (if clear + (substring-no-properties thing) + ;; copy the string in case it's "pure" + (flx-propertize (copy-sequence (car thing)) (cdr thing)))) + (if clear + (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) + for string = (if (consp item) (car item) item) + for score = (flx-score string query flx-file-cache) if score collect (cons item score) into matches @@ -141,6 +144,11 @@ item, in which case, the ending items are deleted." (sort matches (lambda (x y) (> (cadr x) (cadr y)))))))) +(defun flx-ido-cache (query items) + (if (consp (car items)) + items + (puthash query items flx-ido-narrowed-matches-hash))) + (defun flx-ido-match (query items) "Better sorting for flx ido matching." (if (memq ido-cur-item '(file dir)) @@ -151,13 +159,12 @@ item, in which case, the ending items are deleted." (not (gethash query flx-ido-narrowed-matches-hash))) ;; original function reverses list. (setq items (nreverse (ido-delete-runs items))) - (puthash query items flx-ido-narrowed-matches-hash)) - (destructuring-bind (exact items) + (flx-ido-cache query items)) + (destructuring-bind (exact res-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))))) + res-items + (flx-ido-cache query (flx-ido-match-internal query res-items)))))) (defvar flx-ido-use t "Use flx matching for ido.")