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

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

[elpa] externals/corfu cd1e5c396e 1/2: corfu-quit-no-match: Remove suppo


From: ELPA Syncer
Subject: [elpa] externals/corfu cd1e5c396e 1/2: corfu-quit-no-match: Remove support for seconds (#122)
Date: Mon, 7 Feb 2022 12:59:31 -0500 (EST)

branch: externals/corfu
commit cd1e5c396efa5c737f60032dafc65cd2327a9423
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: GitHub <noreply@github.com>

    corfu-quit-no-match: Remove support for seconds (#122)
    
    * corfu-quit-no-match: Remove support for seconds
    
    * corfu-quit-no-match: Support value 'separator
    
    * README updates
---
 README.org | 13 ++++++-------
 corfu.el   | 34 ++++++++++++++--------------------
 2 files changed, 20 insertions(+), 27 deletions(-)

diff --git a/README.org b/README.org
index ceb1e2bb2a..7644ec5f05 100644
--- a/README.org
+++ b/README.org
@@ -78,7 +78,7 @@
       ;; (corfu-auto t)                 ;; Enable auto completion
       ;; (corfu-commit-predicate nil)   ;; Do not commit selected candidates 
on next input
       ;; (corfu-separator ?\s)          ;; Orderless field separator
-      ;; (corfu-quit-no-match t)        ;; Automatically quit if there is no 
match
+      ;; (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-echo-documentation nil) ;; Disable documentation in the echo 
area
@@ -142,9 +142,9 @@
   appeared unexpectedly.
 
   #+begin_src emacs-lisp
-    ;; Enable auto completion and eager quitting
+    ;; Enable auto completion and configure quitting
     (setq corfu-auto t
-          corfu-quit-no-match t)
+          corfu-quit-no-match 'separator) ;; or t
   #+end_src
 
   In general, I recommend to experiment a bit with the various settings and key
@@ -188,14 +188,13 @@ completion UI, the following snippet should yield the 
desired result.
 
 ** Completing with Corfu in the Shell or Eshell
 
-When completing in the Eshell I recommend conservative local settings, no auto
-completion, and quitting if there is no match.
+When completing in the Eshell I recommend conservative local settings without
+auto completion.
 
 #+begin_src emacs-lisp
   (add-hook 'eshell-mode-hook
             (lambda ()
-              (setq-local corfu-quit-no-match t
-                          corfu-auto nil)
+              (setq-local corfu-auto nil)
               (corfu-mode)))
 #+end_src
 
diff --git a/corfu.el b/corfu.el
index 338cb7c075..1f12100805 100644
--- a/corfu.el
+++ b/corfu.el
@@ -97,13 +97,15 @@ can be entered.  If nil, always quit at completion 
boundaries.
 To enter the first separator character, call
 `corfu-insert-separator' (bound to M-SPC by default).
 Useful for multi-component completion styles such as orderless."
-  :type '(choice (const nil) 'character))
+  :type '(choice (const nil) character))
 
-(defcustom corfu-quit-no-match 1.0
+(defcustom corfu-quit-no-match 'separator
   "Automatically quit if no matching candidate is found.
-If a floating point number, quit on no match only if the auto-started
-completion began less than that number of seconds ago."
-  :type '(choice boolean float))
+nil: Stay alive even if there is no match.
+t: Quit if there is no match.
+separator: Only stay alive if there is no match and
+`corfu-separator' has been inserted."
+  :type '(choice boolean (const separator)))
 
 (defcustom corfu-excluded-modes nil
   "List of modes excluded by `corfu-global-mode'."
@@ -268,9 +270,6 @@ The completion backend can override this with
 (defvar-local corfu--change-group nil
   "Undo change group.")
 
-(defvar-local corfu--auto-start nil
-  "Auto completion start time.")
-
 (defvar-local corfu--echo-timer nil
   "Echo area message timer.")
 
@@ -291,7 +290,6 @@ The completion backend can override this with
     corfu--total
     corfu--preview-ov
     corfu--extra
-    corfu--auto-start
     corfu--echo-timer
     corfu--echo-message
     corfu--change-group
@@ -831,12 +829,11 @@ there hasn't been any input, then quit."
       (corfu--echo-documentation)
       (corfu--preview-current beg end str))
      ;; 4) There are no candidates & corfu-quit-no-match => Confirmation popup
-     ((not (or corfu--candidates
-               ;; When `corfu-quit-no-match' is a number of seconds and the 
auto completion wasn't
-               ;; initiated too long ago, quit directly without showing the 
"No match" popup.
-               (if (and corfu--auto-start (numberp corfu-quit-no-match))
-                   (< (- (float-time) corfu--auto-start) corfu-quit-no-match)
-                 (eq t corfu-quit-no-match))))
+     ((and (not corfu--candidates)
+           (pcase-exhaustive corfu-quit-no-match
+             ('t nil)
+             ('nil t)
+             ('separator (seq-contains-p (car corfu--input) corfu-separator))))
       (corfu--popup-show beg 0 8 '(#("No match" 0 8 (face italic)))))
      (t (corfu-quit)))))
 
@@ -884,9 +881,7 @@ there hasn't been any input, then quit."
 
 (defun corfu--goto (index)
   "Go to candidate with INDEX."
-  (setq corfu--index (max corfu--preselect (min index (1- corfu--total)))
-        ;; Reset auto start in order to disable the `corfu-quit-no-match' timer
-        corfu--auto-start nil))
+  (setq corfu--index (max corfu--preselect (min index (1- corfu--total)))))
 
 (defun corfu-next (&optional n)
   "Go forward N candidates."
@@ -1160,8 +1155,7 @@ See `completion-in-region' for the arguments BEG, END, 
TABLE, PRED."
        (let ((completion-in-region-mode-predicate
               (lambda () (eq beg (car-safe (funcall fun)))))
              (completion-extra-properties plist))
-         (setq corfu--auto-start (float-time)
-               completion-in-region--data
+         (setq completion-in-region--data
                (list (copy-marker beg) (copy-marker end t) table
                      (plist-get plist :predicate)))
          (corfu--setup)



reply via email to

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