summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2022-02-12 20:31:42 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2022-02-12 20:31:42 +0100
commit8dd1cb7d17353f01158843155a0df87e1b204a4c (patch)
treed4dd37783a59242da2125b1d7ee54f593ef56eee
parent82379e8bd9f3ce5a87ce7b97be1558b690fad5e2 (diff)
Rename corfu-insert-single to corfu-on-exact-match (See #109)
-rw-r--r--README.org2
-rw-r--r--corfu.el16
2 files changed, 10 insertions, 8 deletions
diff --git a/README.org b/README.org
index 45c8552..e41b781 100644
--- a/README.org
+++ b/README.org
@@ -87,7 +87,7 @@
;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match
;; (corfu-preview-current nil) ;; Disable current candidate preview
;; (corfu-preselect-first nil) ;; Disable candidate preselection
- ;; (corfu-insert-single nil) ;; Do not insert single matches automatically
+ ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches
;; (corfu-echo-documentation nil) ;; Disable documentation in the echo area
;; (corfu-scroll-margin 5) ;; Use scroll margin
diff --git a/corfu.el b/corfu.el
index 5fb0cdc..02d1430 100644
--- a/corfu.el
+++ b/corfu.el
@@ -64,9 +64,9 @@ The value should lie between 0 and corfu-count/2."
"Enable cycling for `corfu-next' and `corfu-previous'."
:type 'boolean)
-(defcustom corfu-insert-single t
- "Automatically insert single matching candidate."
- :type 'boolean)
+(defcustom corfu-on-exact-match 'insert
+ "Configure how a single exact match should be handled."
+ :type '(choice (const insert) (const quit) (const nil)))
(defcustom corfu-continue-commands
;; nil is undefined command
@@ -818,13 +818,15 @@ there hasn't been any input, then quit."
;; 1) Initializing, no candidates => Quit. Happens during auto completion.
((and initializing (not corfu--candidates))
(corfu-quit))
- ;; 2) Single matching candidate and no further completion is possible.
+ ;; 2) Single exactly matching candidate and no further completion is possible.
((and (not (equal str ""))
(equal (car corfu--candidates) str) (not (cdr corfu--candidates))
(not (consp (completion-try-completion str table pred pt corfu--metadata)))
- (or initializing corfu-insert-single))
- ;; Quit directly, happens during auto completion.
- (if initializing (corfu-quit) (corfu--done str 'finished)))
+ (or initializing corfu-on-exact-match))
+ ;; Quit directly when initializing. This happens during auto completion.
+ (if (or initializing (eq corfu-on-exact-match 'quit))
+ (corfu-quit)
+ (corfu--done str 'finished)))
;; 3) There exist candidates => Show candidates popup.
(corfu--candidates
(corfu--candidates-popup beg)