diff --git a/modules/completion/corfu/config.el b/modules/completion/corfu/config.el index 7cd7b5173..34368030a 100644 --- a/modules/completion/corfu/config.el +++ b/modules/completion/corfu/config.el @@ -4,9 +4,9 @@ "Configure how the user expects RET to behave. Possible values are: - t (default): Insert candidate if one is selected, pass-through otherwise; -- `minibuffer': Insert candidate if one is selected, pass-through otherwise, - and immediatelly exit if in the minibuffer; -- nil: Pass-through without inserting.") +- nil: Pass-through without inserting; +- `both': Insert candidate if one is selected, then pass-through; +- `minibuffer': Behaves like `both` in the minibuffer and `t` otherwise.") (defvar +corfu-buffer-scanning-size-limit (* 1 1024 1024) ; 1 MB "Size limit for a buffer to be scanned by `cape-dabbrev'.") diff --git a/modules/config/default/config.el b/modules/config/default/config.el index 21aa7268d..4ebb63f20 100644 --- a/modules/config/default/config.el +++ b/modules/config/default/config.el @@ -482,16 +482,23 @@ Continues comments if executed from a commented line. Consults (cond ((null +corfu-want-ret-to-confirm) (corfu-quit) nil) - ((eq +corfu-want-ret-to-confirm 'minibuffer) + ((eq +corfu-want-ret-to-confirm t) + (if (>= corfu--index 0) + cmd + nil)) + ((eq +corfu-want-ret-to-confirm 'both) (funcall-interactively cmd) nil) - ((and (or (not (minibufferp nil t)) - (eq +corfu-want-ret-to-confirm t)) - (>= corfu--index 0)) - cmd) - ((or (not (minibufferp nil t)) - (eq +corfu-want-ret-to-confirm t)) - nil) + ((eq +corfu-want-ret-to-confirm 'minibuffer) + (if (minibufferp nil t) + ;; 'both' behavior + (progn + (funcall-interactively cmd) + nil) + ;; 't' behavior + (if (>= corfu--index 0) + cmd + nil))) (t cmd)))))) (map! :when (modulep! :completion corfu) :map corfu-map