[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/flx cc3258bb10 038/182: cache key should be based on whole
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/flx cc3258bb10 038/182: cache key should be based on whole input |
Date: |
Tue, 13 Dec 2022 03:59:23 -0500 (EST) |
branch: elpa/flx
commit cc3258bb10ab220166b1c2409597999a34a0b79a
Author: Le Wang <le.wang@agworld.com.au>
Commit: Le Wang <le.wang@agworld.com.au>
cache key should be based on whole input
- files, dirs also cached
---
flx-ido.el | 49 +++++++++++++++++++++++++++----------------------
1 file changed, 27 insertions(+), 22 deletions(-)
diff --git a/flx-ido.el b/flx-ido.el
index 354e0bc405..bca362aca4 100644
--- a/flx-ido.el
+++ b/flx-ido.el
@@ -13,7 +13,7 @@
;; Version: 0.1
;; Last-Updated:
;; By:
-;; Update #: 18
+;; Update #: 23
;; URL:
;; Keywords:
;; Compatibility:
@@ -85,23 +85,24 @@ item, in which case, the ending items are deleted."
(defvar flx-ido-narrowed-matches-hash (make-hash-table :test 'equal))
-(defun flx-ido-narrowed (query items)
+(defun flx-ido-narrowed (items)
"Get the value from `flx-ido-narrowed-matches-hash' with the
longest prefix match."
- (let (best-match
+ (let ((query-key (flx-ido-key-for-query))
+ best-match
exact
res)
(loop for key being the hash-key of flx-ido-narrowed-matches-hash
- do (when (and (>= (length query) (length key))
+ do (when (and (>= (length query-key) (length key))
(eq t
- (compare-strings query 0 (min (length query)
+ (compare-strings query-key 0 (min (length
query-key)
(length key))
key 0 nil))
(or (null best-match)
(> (length key) (length best-match))))
(setq best-match key)
(when (= (length key)
- (length query))
+ (length query-key))
(setq exact t)
(return))))
(setq res (cond (exact
@@ -144,27 +145,31 @@ item, in which case, the ending items are deleted."
(sort matches
(lambda (x y) (> (cadr x) (cadr y))))))))
-(defun flx-ido-cache (query items)
+(defun flx-ido-key-for-query ()
+ (if (boundp 'prompt)
+ (buffer-substring-no-properties (+ (point-min)
+ (length prompt))
+ (point))
+ ido-text))
+
+(defun flx-ido-cache (items)
(if (consp (car items))
items
- (puthash query items flx-ido-narrowed-matches-hash)))
+ (puthash (flx-ido-key-for-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))
- (if (equal "" query)
- (nreverse (ido-delete-runs 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 (ido-delete-runs 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
- res-items
- (flx-ido-cache query (flx-ido-match-internal query res-items))))))
+ (when (and (equal "" query)
+ (not (gethash (flx-ido-key-for-query)
+ flx-ido-narrowed-matches-hash)))
+ ;; original function reverses list.
+ (setq items (nreverse (ido-delete-runs items)))
+ (flx-ido-cache items))
+ (destructuring-bind (exact res-items)
+ (flx-ido-narrowed items)
+ (if exact ; `ido-rotate' case is covered by exact
match
+ res-items
+ (flx-ido-cache (flx-ido-match-internal query res-items)))))
(defvar flx-ido-use t
"Use flx matching for ido.")
- [nongnu] elpa/flx 7424f54816 079/182: flx-ido: don't require cl; flx requires it anyway, (continued)
- [nongnu] elpa/flx 7424f54816 079/182: flx-ido: don't require cl; flx requires it anyway, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 3bcaf03434 002/182: add readme, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx bdfd9d98aa 014/182: add travis status image, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 6189f05c7e 004/182: add flx, ido implementation and helm experiment, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 4c67675437 032/182: add GC tuning information to README, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 114cf369cb 020/182: add ido installation instructions, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 7452ab1c79 021/182: README update, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx f566207c82 015/182: travis config update, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 01eef11b96 033/182: small efficiency fix, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 44951ac311 042/182: simplify caching, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx cc3258bb10 038/182: cache key should be based on whole input,
ELPA Syncer <=
- [nongnu] elpa/flx 771f61f3fd 016/182: update test list, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx a792c2c5f1 053/182: change advice to before, fix comments, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 61dcc4f563 089/182: Reset caches on file reload., ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 24f5d2cfc5 099/182: Fix typo threshhold -> threshold, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx c45daa261c 124/182: refactor: pull out flx-get-matches-worker function, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx b9399afd48 136/182: Simplify math operations in score calculation, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 8419b1b28f 107/182: Bump version to v0.4 ., ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 46dd7d7edb 144/182: Improve readability, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx 807d694555 154/182: remove reference to `flx-ido-big-demo`, ELPA Syncer, 2022/12/13
- [nongnu] elpa/flx e05105872f 169/182: Begin sentences with capital letters and end them with a periods, ELPA Syncer, 2022/12/13