[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/corfu 5b0fdd9ec9 2/3: Add corfu-insert-single configura
From: |
ELPA Syncer |
Subject: |
[elpa] externals/corfu 5b0fdd9ec9 2/3: Add corfu-insert-single configuration option (Fix #109) |
Date: |
Sat, 12 Feb 2022 10:57:22 -0500 (EST) |
branch: externals/corfu
commit 5b0fdd9ec99f8490902a3c2edf46958301fb6db1
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add corfu-insert-single configuration option (Fix #109)
---
corfu.el | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/corfu.el b/corfu.el
index e428fc4dc7..5fb0cdc53f 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)