help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using ido-completions in other packages


From: Tassilo Horn
Subject: Re: Using ido-completions in other packages
Date: Fri, 04 Jun 2010 12:57:18 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Andrea Crotti <andrea.crotti.0@gmail.com> writes:

Hi Andrea,

> I've looked in the code but I don't see what I could substitute, maybe
> substituting some functions or advising something else would do the
> trick?

Basically, if you want to use ido-completion in some code, you would use
`ido-comleting-read' instead of `completing-read'.  For example, in some
home-brewn mode I have something like that:

--8<---------------cut here---------------start------------->8---
(if (and (featurep 'ido) ido-mode)
    ;; ido is available and enabled, so use it.
    (ido-completing-read "Command: " commands)
  ;; fallback to normal completion with the
  ;; most frequently used command as default.
  (completing-read
   (concat "Command (defaults to `"
           (car commands) "'): ")
   commands
   nil t nil nil (car commands)))
--8<---------------cut here---------------end--------------->8---

You could try to make `completing-read' point to `ido-completing-read':

  (fset 'completing-read 'ido-completing-read)

But that might error in some cases, cause `completing-read' has one
optional parameter more than `ido-completing-read'.  You might want to
create a function `andrea-completing-read' with the exact signature of
`completing-read' which just delegates to `ido-completing-read' and
throws away the additional parameter, and then do

  (fset 'completing-read 'andrea-completing-read)

In any case: This method is a hammer, so be warned. ;-)

Bye,
Tassilo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]