-
I recently started using consult after years of using ivy. I am mostly happy with the swap, but there's a bit of functionality I haven't been able to replace from my previous configuration. It's a little function that implements this idea with ivy-read:
There are two features here I can't seem to reenact with consult--read/completing-read:
Is there any way to implement this with consult/completing-read? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 11 replies
-
I suggest to implement this on the level of the completion UI. For example in Vertico you could add an after advice to |
Beta Was this translation helpful? Give feedback.
-
Not the user facing option I was looking for but thank you for your input. |
Beta Was this translation helpful? Give feedback.
-
Passing a |
Beta Was this translation helpful? Give feedback.
-
You can headlongify any minibuffer completion session for any "Emacs-compliant" completion UI as follows: (defun headlong ()
"Make the current minibuffer completion exit when there is 1 candidate."
(add-hook 'after-change-functions
(lambda (&rest _)
(let* ((all (completion-all-completions
(minibuffer-contents)
minibuffer-completion-table
minibuffer-completion-predicate
(max 0 (- (point) (minibuffer-prompt-end)))))
(last (last all)))
(when last (setcdr last nil))
(when (and all (null (cdr all)))
(delete-minibuffer-contents)
(insert (car all))
(exit-minibuffer))))
nil t)) This should work with default completion, Vertico and Icomplete (but I did not test extensively). Just call (minibuffer-with-setup-hook #'headlong (call-interactively #'find-file)) |
Beta Was this translation helpful? Give feedback.
-
(If you are concerned about eficiency, @minad's suggestion of doing the headlongifying at the completion UI level is much better since you can avoid recomputing all completions.) |
Beta Was this translation helpful? Give feedback.
-
Thanks Daniel & Omar, but this is not really helping to fix my issue :( I went back to the original
Provided |
Beta Was this translation helpful? Give feedback.
@oantolin sweet! It works :)
For the sake of completness:
@minad & @oantolin: many thanks to both of you for your feedback & congrats on the superb work :)