emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/corfu 676395f 1/2: Generalize corfu-commit-predicate


From: ELPA Syncer
Subject: [elpa] externals/corfu 676395f 1/2: Generalize corfu-commit-predicate
Date: Sun, 17 Oct 2021 09:57:16 -0400 (EDT)

branch: externals/corfu
commit 676395fbb5784a50f54985026d76929daee8ee4c
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Generalize corfu-commit-predicate
    
    Fix #49, Fix #52
---
 corfu.el | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/corfu.el b/corfu.el
index bf930c2..ab7a544 100644
--- a/corfu.el
+++ b/corfu.el
@@ -66,9 +66,9 @@
   "Continue Corfu completion after executing these commands."
   :type '(repeat (choice regexp symbol)))
 
-(defcustom corfu-commit-predicate t
-  "Automatically commit the selected candidate if the predicate returns t."
-  :type '(choice boolean (function :tag "Predicate function")))
+(defcustom corfu-commit-predicate #'corfu-candidate-selected-p
+  "Automatically commit if the predicate returns t."
+  :type 'function)
 
 (defcustom corfu-quit-at-boundary nil
   "Automatically quit at completion field/word boundary.
@@ -695,13 +695,15 @@ completion began less than that number of seconds ago."
 (defun corfu--pre-command ()
   "Insert selected candidate unless command is marked to continue completion."
   (add-hook 'window-configuration-change-hook #'corfu-quit)
-  (unless (or (< corfu--index 0) (corfu--match-symbol-p 
corfu-continue-commands this-command))
-    (if (if (functionp corfu-commit-predicate)
-            (funcall corfu-commit-predicate)
-          corfu-commit-predicate)
+  (unless (corfu--match-symbol-p corfu-continue-commands this-command)
+    (if (funcall corfu-commit-predicate)
         (corfu--insert 'exact)
       (setq corfu--index -1))))
 
+(defun corfu-candidate-selected-p ()
+  "Return t if a candidate is selected."
+  (>= corfu--index 0))
+
 (defun corfu--post-command ()
   "Refresh Corfu after last command."
   (remove-hook 'window-configuration-change-hook #'corfu-quit)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]