summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2026-01-06 02:27:25 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2026-01-06 02:27:25 +0100
commit5bff3712859276713260acdacd4b16c84a29e41f (patch)
treec8c9b3dd2c8bf5c53cab3cd854cfae0ecaeb4d5b
parentaccea195a3c0d42ea9e6b393bf0ec9bf7eb74803 (diff)
corfu--exhibit: Simplify
Move quitting for single exactly matching candidates to corfu-auto--complete-deferred.
-rw-r--r--corfu.el17
-rw-r--r--extensions/corfu-auto.el23
-rw-r--r--extensions/corfu-echo.el2
-rw-r--r--extensions/corfu-popupinfo.el2
4 files changed, 25 insertions, 19 deletions
diff --git a/corfu.el b/corfu.el
index fefd691..cfe639f 100644
--- a/corfu.el
+++ b/corfu.el
@@ -1150,20 +1150,17 @@ A scroll bar is displayed from LO to LO+BAR."
(corfu--match-symbol-p corfu-continue-commands this-command)))
(corfu--insert 'exact)))
-(cl-defgeneric corfu--exhibit (&optional auto)
- "Exhibit Corfu UI.
-AUTO is non-nil when initializing auto completion."
+(cl-defgeneric corfu--exhibit ()
+ "Exhibit Corfu UI."
(pcase-let ((`(,beg ,end ,table ,pred . ,_) completion-in-region--data)
(`(,str . ,pt) (corfu--update 'interruptible)))
(cond
;; 1) Single exactly matching candidate and no further completion is possible.
- ((and (not (equal str ""))
- (equal (car corfu--candidates) str) (not (cdr corfu--candidates))
+ ((and corfu-on-exact-match
(not (eq corfu-on-exact-match 'show))
- (or auto corfu-on-exact-match)
+ (equal corfu--candidates (list str))
(not (consp (corfu--try-completion str table pred pt))))
- ;; Quit directly when initializing auto completion.
- (if (or auto (eq corfu-on-exact-match 'quit))
+ (if (eq corfu-on-exact-match 'quit)
(corfu-quit)
(corfu--done (car corfu--candidates) 'finished nil)))
;; 2) There exist candidates => Show candidates popup.
@@ -1177,8 +1174,8 @@ AUTO is non-nil when initializing auto completion."
('nil corfu--input)
('separator (seq-contains-p (car corfu--input) corfu-separator)))
(corfu--popup-show (posn-at-point beg) 0 8 '(#("No match" 0 8 (face italic)))))
- ;; 4) No candidates & auto completing or initialized => Quit.
- ((or auto corfu--input) (corfu-quit)))))
+ ;; 4) No candidates & initialized => Quit.
+ (corfu--input (corfu-quit)))))
(cl-defgeneric corfu--teardown (buffer)
"Tear-down Corfu in BUFFER, which might be dead at this point."
diff --git a/extensions/corfu-auto.el b/extensions/corfu-auto.el
index 429b7c4..8a99e1c 100644
--- a/extensions/corfu-auto.el
+++ b/extensions/corfu-auto.el
@@ -79,13 +79,22 @@ The list can contain either command symbols or regular expressions."
'completion-at-point-functions
#'corfu--capf-wrapper corfu-auto-prefix corfu-auto-trigger))
(`(,fun ,beg ,end ,table . ,plist)
- (let ((completion-in-region-mode-predicate
- (lambda ()
- (when-let* ((newbeg (car-safe (funcall fun))))
- (= newbeg beg))))
- (completion-extra-properties plist))
- (corfu--setup beg end table (plist-get plist :predicate))
- (corfu--exhibit 'auto))))))))
+ (pcase-let* ((completion-in-region-mode-predicate
+ (lambda ()
+ (when-let* ((newbeg (car-safe (funcall fun))))
+ (= newbeg beg))))
+ (completion-extra-properties plist)
+ (pred (plist-get plist :predicate))
+ (state (plist-get plist :corfu--state))
+ (`(,str . ,pt) (alist-get 'corfu--input state))
+ (cands (alist-get 'corfu--candidates state)))
+ ;; Bail out immediately for exactly matching candidates
+ ;; if no further completion is possible.
+ (when (or (eq corfu-on-exact-match 'show)
+ (not (equal cands (list str)))
+ (consp (corfu--try-completion str table pred pt)))
+ (corfu--setup beg end table pred)
+ (corfu--exhibit)))))))))
(defun corfu-auto--post-command ()
"Post command hook which initiates auto completion."
diff --git a/extensions/corfu-echo.el b/extensions/corfu-echo.el
index 184b1c0..e07c32a 100644
--- a/extensions/corfu-echo.el
+++ b/extensions/corfu-echo.el
@@ -80,7 +80,7 @@ subsequent delay."
"Show candidate documentation in echo area."
:global t :group 'corfu)
-(cl-defmethod corfu--exhibit :after (&context (corfu-echo-mode (eql t)) &optional _auto)
+(cl-defmethod corfu--exhibit :after (&context (corfu-echo-mode (eql t)))
(if-let* (((not (minibufferp)))
(delay (if (consp corfu-echo-delay)
(funcall (if corfu-echo--message #'cdr #'car)
diff --git a/extensions/corfu-popupinfo.el b/extensions/corfu-popupinfo.el
index c45e24c..4aa038a 100644
--- a/extensions/corfu-popupinfo.el
+++ b/extensions/corfu-popupinfo.el
@@ -493,7 +493,7 @@ not be displayed until this command is called again, even if
"Corfu info popup minor mode."
:global t :group 'corfu)
-(cl-defmethod corfu--exhibit :after (&context (corfu-popupinfo-mode (eql t)) &optional _auto)
+(cl-defmethod corfu--exhibit :after (&context (corfu-popupinfo-mode (eql t)))
(when completion-in-region-mode
(setf (alist-get #'corfu-popupinfo-mode minor-mode-overriding-map-alist)
corfu-popupinfo-map)