feat(corfu): both
option for RET behavior
Adds a new value of `+corfu-want-ret-to-confirm` to cover the case where the user wants to select the candidate as well as perform the normal behavior of RET. Also, the logic for RET behavior has been refactored for clarity, and the variable's documentation has been clarified a little.
This commit is contained in:
parent
bbadabda51
commit
dd18fa16be
2 changed files with 18 additions and 11 deletions
|
@ -4,9 +4,9 @@
|
||||||
"Configure how the user expects RET to behave.
|
"Configure how the user expects RET to behave.
|
||||||
Possible values are:
|
Possible values are:
|
||||||
- t (default): Insert candidate if one is selected, pass-through otherwise;
|
- t (default): Insert candidate if one is selected, pass-through otherwise;
|
||||||
- `minibuffer': Insert candidate if one is selected, pass-through otherwise,
|
- nil: Pass-through without inserting;
|
||||||
and immediatelly exit if in the minibuffer;
|
- `both': Insert candidate if one is selected, then pass-through;
|
||||||
- nil: Pass-through without inserting.")
|
- `minibuffer': Behaves like `both` in the minibuffer and `t` otherwise.")
|
||||||
|
|
||||||
(defvar +corfu-buffer-scanning-size-limit (* 1 1024 1024) ; 1 MB
|
(defvar +corfu-buffer-scanning-size-limit (* 1 1024 1024) ; 1 MB
|
||||||
"Size limit for a buffer to be scanned by `cape-dabbrev'.")
|
"Size limit for a buffer to be scanned by `cape-dabbrev'.")
|
||||||
|
|
|
@ -482,16 +482,23 @@ Continues comments if executed from a commented line. Consults
|
||||||
(cond ((null +corfu-want-ret-to-confirm)
|
(cond ((null +corfu-want-ret-to-confirm)
|
||||||
(corfu-quit)
|
(corfu-quit)
|
||||||
nil)
|
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)
|
(funcall-interactively cmd)
|
||||||
nil)
|
nil)
|
||||||
((and (or (not (minibufferp nil t))
|
((eq +corfu-want-ret-to-confirm 'minibuffer)
|
||||||
(eq +corfu-want-ret-to-confirm t))
|
(if (minibufferp nil t)
|
||||||
(>= corfu--index 0))
|
;; 'both' behavior
|
||||||
cmd)
|
(progn
|
||||||
((or (not (minibufferp nil t))
|
(funcall-interactively cmd)
|
||||||
(eq +corfu-want-ret-to-confirm t))
|
nil)
|
||||||
nil)
|
;; 't' behavior
|
||||||
|
(if (>= corfu--index 0)
|
||||||
|
cmd
|
||||||
|
nil)))
|
||||||
(t cmd))))))
|
(t cmd))))))
|
||||||
(map! :when (modulep! :completion corfu)
|
(map! :when (modulep! :completion corfu)
|
||||||
:map corfu-map
|
:map corfu-map
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue