summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2022-02-12 16:42:19 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2022-02-12 16:42:19 +0100
commit5b0fdd9ec99f8490902a3c2edf46958301fb6db1 (patch)
tree36f186a89ed6a572401d4c50bfc824ed17482a6f
parentd12ecbc719b0045ec0ea1be85650b56661ad37af (diff)
Add corfu-insert-single configuration option (Fix #109)
-rw-r--r--corfu.el19
1 files changed, 12 insertions, 7 deletions
diff --git a/corfu.el b/corfu.el
index e428fc4..5fb0cdc 100644
--- a/corfu.el
+++ b/corfu.el
@@ -64,6 +64,10 @@ 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-continue-commands
;; nil is undefined command
'(nil ignore universal-argument universal-argument-more digit-argument
@@ -811,21 +815,22 @@ there hasn't been any input, then quit."
nil)
(error (corfu-quit)
(message "Corfu completion error: %s" (error-message-string err)))))
- ;; 1) Initializing, no candidates => Quit (happens during auto completion!)
+ ;; 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 matching candidate and no further completion is possible.
((and (not (equal str ""))
- (equal corfu--candidates (list str))
- (not (consp (completion-try-completion str table pred pt corfu--metadata))))
- ;; Quit directly, happens during auto completion!
+ (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)))
- ;; 3) There exist candidates => Show candidates popup
+ ;; 3) There exist candidates => Show candidates popup.
(corfu--candidates
(corfu--candidates-popup beg)
(corfu--echo-documentation)
(corfu--preview-current beg end str))
- ;; 4) There are no candidates & corfu-quit-no-match => Confirmation popup
+ ;; 4) There are no candidates & corfu-quit-no-match => Confirmation popup.
((and (not corfu--candidates)
(pcase-exhaustive corfu-quit-no-match
('t nil)