[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/corfu cb059a4 1/3: Add corfu-commit-predicate (Fix #40)
From: |
ELPA Syncer |
Subject: |
[elpa] externals/corfu cb059a4 1/3: Add corfu-commit-predicate (Fix #40) |
Date: |
Wed, 21 Jul 2021 08:57:09 -0400 (EDT) |
branch: externals/corfu
commit cb059a4f858c8fb213e944acb33a47917c8f7365
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add corfu-commit-predicate (Fix #40)
---
README.org | 12 +++++++-----
corfu.el | 10 +++++++++-
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/README.org b/README.org
index eea3657..e666e03 100644
--- a/README.org
+++ b/README.org
@@ -39,7 +39,8 @@
- In manual mode, the popup must be summoned explicitly by pressing =TAB=
- The current candidate is inserted with =TAB= and selected with =RET=
- Candidates sorting by prefix, string length and alphabetically
- - Completion is automatically terminated after candidate selection
+ - The selected candidate is automatically committed on the next input by
default.
+ This behavior can be configured by adjusting ~corfu-commit-predicate~.
- Filter string can contain arbitrary characters and spaces, if
~corfu-quit-at-boundary~ is nil. This is needed when filtering with the
[[https://github.com/oantolin/orderless][Orderless]] completion style.
@@ -61,10 +62,11 @@
(use-package corfu
;; Optional customizations
;; :custom
- ;; (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
- ;; (corfu-auto t) ;; Enable auto completion
- ;; (corfu-quit-at-boundary t) ;; Automatically quit at word boundary
- ;; (corfu-quit-no-match t) ;; Automatically quit if there is no match
+ ;; (corfu-cycle t) ;; Enable cycling for
`corfu-next/previous'
+ ;; (corfu-auto t) ;; Enable auto completion
+ ;; (corfu-commit-predicate nil) ;; Do not commit selected candidates on
next input
+ ;; (corfu-quit-at-boundary t) ;; Automatically quit at word boundary
+ ;; (corfu-quit-no-match t) ;; Automatically quit if there is no
match
;; Optionally use TAB for cycling, default is `corfu-complete'.
;; :bind (:map corfu-map
diff --git a/corfu.el b/corfu.el
index 534fd14..a78a738 100644
--- a/corfu.el
+++ b/corfu.el
@@ -59,6 +59,10 @@
"Enable cycling for `corfu-next' and `corfu-previous'."
:type 'boolean)
+(defcustom corfu-commit-predicate t
+ "Automatically commit the selected candidate if the predicate returns t."
+ :type '(choice (const nil) (const t) 'function))
+
(defcustom corfu-quit-at-boundary nil
"Automatically quit at completion field/word boundary.
If automatic quitting is disabled, Orderless filtering is facilitated since a
@@ -606,7 +610,11 @@ filter string with spaces is allowed."
"Insert selected candidate unless command is marked to continue completion."
(add-hook 'window-configuration-change-hook #'corfu--popup-hide)
(unless (or (< corfu--index 0) (corfu--continue-p))
- (corfu--insert 'exact)))
+ (if (if (functionp corfu-commit-predicate)
+ (funcall corfu-commit-predicate)
+ corfu-commit-predicate)
+ (corfu--insert 'exact)
+ (setq corfu--index -1))))
(defun corfu--post-command ()
"Refresh Corfu after last command."