Close: #7750
This commit is contained in:
Henrik Lissner 2024-08-31 21:31:11 -04:00
commit 10484dea87
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
3 changed files with 23 additions and 26 deletions

View file

@ -193,9 +193,13 @@ A few variables may be set to change behavior of this module:
- [[var:corfu-preview-current]] :: - [[var:corfu-preview-current]] ::
Configures current candidate preview. Configures current candidate preview.
- [[var:+corfu-want-ret-to-confirm]] :: - [[var:+corfu-want-ret-to-confirm]] ::
Enables commiting with [[RET]] when the popup is visible. Default is ~t~, may be set to Controls the behavior of [[kbd:][RET]] when the popup is visible - whether it confirms
~'minibuffer~ if you want to commit both the completion and the minibuffer when the selected candidate, and whether [[kbd:][RET]] is passed through (ie. the normal
active. When ~nil~, it is always passed-through. behavior of [[kbd:][RET]] is performed). The default value of ~t~ enables confirmation
and disables pass-through. Other variations are ~nil~ for pass-through and no
confirmation and ~both~ for confirmation followed by pass-through. Finally,
the value of ~minibuffer~ will both confirm and pass-through (like ~both~)
when in the minibuffer, and only confirm (like ~t~) otherwise.
- [[var:+corfu-buffer-scanning-size-limit]] :: - [[var:+corfu-buffer-scanning-size-limit]] ::
Sets the maximum buffer size to be scanned by ~cape-dabbrev~. Defaults to 1 MB. Sets the maximum buffer size to be scanned by ~cape-dabbrev~. Defaults to 1 MB.
Set this if you are having performance problems using the CAPF. Set this if you are having performance problems using the CAPF.

View file

@ -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'.")

View file

@ -466,28 +466,21 @@ Continues comments if executed from a commented line."
(let ((cmds-del (let ((cmds-del
`(menu-item "Reset completion" corfu-reset `(menu-item "Reset completion" corfu-reset
:filter ,(lambda (cmd) :filter ,(lambda (cmd)
(cond (when (and (>= corfu--index 0)
((and (>= corfu--index 0)
(eq corfu-preview-current 'insert)) (eq corfu-preview-current 'insert))
cmd))))) cmd))))
(cmds-ret (cmds-ret
`(menu-item "Insert completion DWIM" corfu-insert `(menu-item "Insert completion DWIM" corfu-insert
:filter ,(lambda (cmd) :filter ,(lambda (cmd)
(cond (pcase +corfu-want-ret-to-confirm
((null +corfu-want-ret-to-confirm) ('nil (corfu-quit) nil)
(corfu-quit) ('t (if (>= corfu--index 0) cmd))
nil) ('both (funcall-interactively cmd) nil)
((eq +corfu-want-ret-to-confirm 'minibuffer) ('minibuffer
(funcall-interactively cmd) (if (minibufferp nil t)
nil) (ignore (funcall-interactively cmd)) ; 'both' behavior
((and (or (not (minibufferp nil t)) (if (>= corfu--index 0) cmd))) ; 't' behavior
(eq +corfu-want-ret-to-confirm t)) (_ cmd)))))
(>= corfu--index 0))
cmd)
((or (not (minibufferp nil t))
(eq +corfu-want-ret-to-confirm t))
nil)
(t cmd)))))
(cmds-tab (cmds-tab
`(menu-item "Select next candidate or expand/traverse snippet" corfu-next `(menu-item "Select next candidate or expand/traverse snippet" corfu-next
:filter (lambda (cmd) :filter (lambda (cmd)