summaryrefslogtreecommitdiff
path: root/corfu.el
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2021-10-16 12:03:59 +0200
committerDaniel Mendler <mail@daniel-mendler.de>2021-10-16 12:03:59 +0200
commit815e7d4c2e5223de75954d7d64adf993f655c6c0 (patch)
treea38cfc3b0ee7d643806f756b814125845e00c496 /corfu.el
parent437b19c42e7d0112041e561607fd10ef03ab90ec (diff)
Generalize corfu-quit-predicategeneralize-predicates
Diffstat (limited to 'corfu.el')
-rw-r--r--corfu.el17
1 files changed, 7 insertions, 10 deletions
diff --git a/corfu.el b/corfu.el
index 14f9f4d..5e5e07c 100644
--- a/corfu.el
+++ b/corfu.el
@@ -76,7 +76,7 @@ If automatic quitting is disabled, Orderless filtering is facilitated since a
filter string with spaces is allowed."
:type 'boolean)
-(defcustom corfu-quit-no-match 1.0
+(defcustom corfu-quit-predicate (list #'corfu-quit-no-match-p 1.0)
"Automatically quit if no matching candidate is found.
If a floating point number, quit on no match only if the auto-started
completion began less than that number of seconds ago."
@@ -668,12 +668,14 @@ completion began less than that number of seconds ago."
((and initializing (not corfu--candidates)) ;; 1) Initializing, no candidates
(funcall msg "No match") ;; => Show error message
nil)
- ((and corfu--candidates ;; 2) There exist candidates
+ ((funcall corfu-quit-predicate) ;; 2) Quit predicate returns non-nil.
+ nil)
+ ((and corfu--candidates ;; 3) There exist candidates
(not (equal corfu--candidates (list str))) ;; & Not a sole exactly matching candidate
continue) ;; & Input is non-empty or continue command
(corfu--show-candidates beg end str metadata) ;; => Show candidates popup
t)
- ;; 3) When after `completion-at-point/corfu-complete', no further completion is possible and the
+ ;; 4) When after `completion-at-point/corfu-complete', no further completion is possible and the
;; current string is a valid match, exit with status 'finished.
((and (memq this-command '(corfu-complete completion-at-point))
(not (stringp (try-completion str table pred)))
@@ -683,13 +685,8 @@ completion began less than that number of seconds ago."
(test-completion str table pred))
(corfu--done str 'finished)
nil)
- ((not (or corfu--candidates ;; 4) There are no candidates
- ;; When `corfu-quit-no-match' is a number of seconds and the auto completion wasn't
- ;; initiated too long ago, quit directly without showing the "No match" popup.
- (if (and corfu--auto-start (numberp corfu-quit-no-match))
- (< (- (float-time) corfu--auto-start) corfu-quit-no-match)
- (eq t corfu-quit-no-match))))
- (corfu--popup-show beg '(#("No match" 0 8 (face italic)))) ;; => Show confirmation popup
+ ((not corfu--candidates) ;; 5) There are no candidates => confirmation popup
+ (corfu--popup-show beg '(#("No match" 0 8 (face italic))))
t))))
(defun corfu--pre-command ()