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

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

[elpa] externals/corfu 2f0dcbb 3/3: Improve corfu-reset


From: ELPA Syncer
Subject: [elpa] externals/corfu 2f0dcbb 3/3: Improve corfu-reset
Date: Thu, 18 Nov 2021 16:57:13 -0500 (EST)

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

    Improve corfu-reset
    
    This command can be executed multiple times consecutively by hammering the 
ESC
    key. If a candidate is selected, unselect the candidate. Otherwise reset the
    input. If there hasn't been any input, then quit.
---
 corfu.el | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/corfu.el b/corfu.el
index 8008712..9f42145 100644
--- a/corfu.el
+++ b/corfu.el
@@ -599,14 +599,18 @@ A scroll bar is displayed from LO to LO+BAR."
   (completion-in-region-mode -1))
 
 (defun corfu-reset ()
-  "Reset Corfu completion and quit if reset has been executed twice."
+  "Reset Corfu completion.
+This command can be executed multiple times consecutively by hammering the ESC
+key. If a candidate is selected, unselect the candidate. Otherwise reset the
+input. If there hasn't been any input, then quit."
   (interactive)
-  (setq corfu--index -1)
-  ;; Cancel all changes and start new change group.
-  (cancel-change-group corfu--change-group)
-  (activate-change-group (setq corfu--change-group (prepare-change-group)))
-  (when (eq last-command #'corfu-reset)
-    (corfu-quit)))
+  (if (>= corfu--index 0)
+      (corfu--goto -1)
+    (let ((quit (eq buffer-undo-list (cdar corfu--change-group)))) ;; Change 
group is empty
+      ;; Cancel all changes and start new change group.
+      (cancel-change-group corfu--change-group)
+      (activate-change-group (setq corfu--change-group (prepare-change-group)))
+      (when quit (corfu-quit)))))
 
 (defun corfu--affixate (cands)
   "Annotate CANDS with annotation function."



reply via email to

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