summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar AntolĂ­n Camarena <omar.antolin@gmail.com>2022-09-17 19:35:36 -0500
committerGitHub <noreply@github.com>2022-09-17 19:35:36 -0500
commite0b2b74d71d96c2da74a79bfef6aec197887ce86 (patch)
treee0d30445ae4d489879c436888d4966ece7ff6853
parent2e46849f5eac049b04eb9d1655b78203d1d31f09 (diff)
parentc06e66d96468b97ac1c4dcf48a8c0d90bc3a518e (diff)
Merge pull request #120 from minad/fix-118
Improve orderless-try-completion (Fix #118)
-rw-r--r--orderless.el26
1 files changed, 14 insertions, 12 deletions
diff --git a/orderless.el b/orderless.el
index d1b47e9..0d99e35 100644
--- a/orderless.el
+++ b/orderless.el
@@ -423,18 +423,20 @@ This function is part of the `orderless' completion style."
(catch 'orderless--many
(let (one)
;; Abuse all-completions/orderless-filter as a fast search loop.
- ;; Should be more or less allocation-free since our "predicate"
- ;; always returns nil.
- (orderless-filter string table
- ;; key/value for hash tables
- (lambda (&rest args)
- (when (or (not pred) (apply pred args))
- (when one
- (throw 'orderless--many (cons string point)))
- (setq one (car args) ;; first argument is key
- one (if (consp one) (car one) one) ;; alist
- one (if (symbolp one) (symbol-name one) one)))
- nil))
+ ;; Should be almost allocation-free since our "predicate" is not
+ ;; called more than two times.
+ (orderless-filter
+ string table
+ ;; key/value for hash tables
+ (lambda (&rest args)
+ (when (or (not pred) (apply pred args))
+ (setq args (car args) ;; first argument is key
+ args (if (consp args) (car args) args) ;; alist
+ args (if (symbolp args) (symbol-name args) args))
+ (when (and one (not (equal one args)))
+ (throw 'orderless--many (cons string point)))
+ (setq one args)
+ t)))
(when one
(if (equal string one)
t ;; unique exact match