I'm a big fan of ido-mode
, so much so that I would like to use it for things like describe-function
or find-tag
and so on, without having to write something like in "Can I get ido-mode-style completion for searching tags in Emacs?" for each one.
Both
(defalias completing-read ido-completing-read)
and
(setf 'completing-read 'ido-completing-read)
don't work, at least partly because ido-completing-read
calls completing-read
in its body, so any simple redefinition would result in infinite recursion.
In theory, it should be possible, since the first line of the docstring for ido-completing-read
is "Ido replacement for the built-in completing-read
." I've looked around a bit and can't seem to find anyone else who has attempted or succeeded at it.
I realize that Icicles probably provides something like this, and I may end up going with that anyway, but it is a bit more of a plunge than I care to take right now.
Thanks for any help.
Edit: This is now an Emacs package available from MELPA. It has been expanded into a full-fledged minor mode. Development happens on GitHub.
Here is my refinement of Jacobo's answer. Credit to him for the original magic. I've added an override variable, which you can use to prevent the use of ido-completing-read
in specific functions. I have also added a check that uses the original completing-read if there are no completions (This happens occasionally, for example in org-remember-apply-template
from org-mode, which breaks with Jacobo's original advice).
(defvar ido-enable-replace-completing-read t
"If t, use ido-completing-read instead of completing-read if possible.
Set it to nil using let in around-advice for functions where the
original completing-read is required. For example, if a function
foo absolutely must use the original completing-read, define some
advice like this:
(defadvice foo (around original-completing-read-only activate)
(let (ido-enable-replace-completing-read) ad-do-it))")
;; Replace completing-read wherever possible, unless directed otherwise
(defadvice completing-read
(around use-ido-when-possible activate)
(if (or (not ido-enable-replace-completing-read) ; Manual override disable ido
(boundp 'ido-cur-list)) ; Avoid infinite loop from ido calling this
ad-do-it
(let ((allcomp (all-completions "" collection predicate)))
(if allcomp
(setq ad-return-value
(ido-completing-read prompt
allcomp
nil require-match initial-input hist def))
ad-do-it))))
Oh, and for using ido in M-x, use amx.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With