feat(corfu): general move-to-minibuffer impl
We previously implemented only consult/vertico as a target for export, now we have all of them. It was necessary to use case-by-case conditions, unfortunately, because other UIs have subtle quirks that prevent a single generalized approach to work. Ivy is almost compliant, but it needs beg and end to not be markers. Helm doesn't replace `completion-in-region-function`, it expects to go around the default `completion--in-region`. It's supposed to add the advice by itself, but it's very unreliable, so we do the wrapping manually. Ido doesn't implement `completion-in-region` and its `completing-read` is retricted to a list of strings as table, so we use default `completion--in-region` with no bells or whistles.
This commit is contained in:
parent
0588b42b46
commit
763464afdb
2 changed files with 27 additions and 11 deletions
|
@ -160,12 +160,11 @@ you accidentaly press more than needed.
|
||||||
| [[kbd:][SPC]] | (when completing) Quit autocompletion |
|
| [[kbd:][SPC]] | (when completing) Quit autocompletion |
|
||||||
| [[kbd:][SPC]] | (when completing with separators) Self-insert |
|
| [[kbd:][SPC]] | (when completing with separators) Self-insert |
|
||||||
|
|
||||||
** Exporting to the minibuffer (requires [[doom-module::completion vertico]])
|
** Exporting to the minibuffer
|
||||||
When using the [[doom-module::completion vertico]] module, which pulls in the
|
The entries shown in the completion popup can be exported to a ~completing-read~
|
||||||
[[doom-package:consult]] package, the entries shown in the completion popup can be
|
minibuffer, giving access to all the manipulations that suite allows. Using
|
||||||
exported to a consult minibuffer, giving access to all the manipulations the
|
Vertico for instance, one could use this to export with [[doom-package:embark]] via
|
||||||
Vertico suite allows. For instance, one could use this to export with
|
[[kbd:][C-c C-l]] and get a buffer with all candidates.
|
||||||
[[doom-package:embark]] via [[kbd:][C-c C-l]] and get a buffer with all candidates.
|
|
||||||
|
|
||||||
* Configuration
|
* Configuration
|
||||||
A few variables may be set to change behavior of this module:
|
A few variables may be set to change behavior of this module:
|
||||||
|
|
|
@ -2,12 +2,29 @@
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +corfu-move-to-minibuffer ()
|
(defun +corfu-move-to-minibuffer ()
|
||||||
;; Taken from corfu's README.
|
"Move the current list of candidates to your choice of minibuffer completion UI."
|
||||||
;; TODO: extend this to other completion front-ends.
|
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((completion-extra-properties corfu--extra)
|
(pcase completion-in-region--data
|
||||||
(completion-cycle-threshold completion-cycling))
|
(`(,beg ,end ,table ,pred ,extras)
|
||||||
(apply #'consult-completion-in-region completion-in-region--data)))
|
(let ((completion-extra-properties extras)
|
||||||
|
completion-cycle-threshold completion-cycling)
|
||||||
|
(cond ((and (modulep! :completion vertico)
|
||||||
|
(fboundp #'consult-completion-in-region))
|
||||||
|
(consult-completion-in-region beg end table pred))
|
||||||
|
((and (modulep! :completion ivy)
|
||||||
|
(fboundp #'ivy-completion-in-region))
|
||||||
|
(ivy-completion-in-region (marker-position beg) (marker-position end) table pred))
|
||||||
|
;; Important: `completion-in-region-function' is set to corfu at
|
||||||
|
;; this moment, so `completion-in-region' (single -) doesn't work
|
||||||
|
;; below.
|
||||||
|
((modulep! :completion helm)
|
||||||
|
;; Helm is special and wants to _wrap_ `completion--in-region'
|
||||||
|
;; instead of replacing it in `completion-in-region-function'.
|
||||||
|
;; But because the advice is too unreliable we "fake" the wrapping.
|
||||||
|
(helm--completion-in-region #'completion--in-region beg end table pred))
|
||||||
|
((modulep! :completion ido)
|
||||||
|
(completion--in-region beg end table pred))
|
||||||
|
(t (error "No minibuffer completion UI available for moving to!")))))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +corfu-smart-sep-toggle-escape ()
|
(defun +corfu-smart-sep-toggle-escape ()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue