Subject: bug#3274: ido-completing-read doesn't work unless ido-mode is executed

From: Leo <[email-masked]>
Date: Sun, 28 Nov 2010 13:53:26 +0000

On 2010-11-28 13:37 +0000, Leo wrote:
> I also ran into this bug a while back but didn't stop to fix it.
>
> Could you verify the following patch fixes the bug?

Please consider this patch instead. While the previous fix is minimal it
does a bit too much by calling (ido-mode 1).

commit eb3f3a514c7ebd2db402ca8c2f3ce7088dd8736a (HEAD, refs/heads/Ferrari)
Date:   Sun Nov 28 13:32:44 2010 +0000

    Fix initialisation in ido-completing-read (#3274)

	Modified lisp/ido.el
diff --git a/lisp/ido.el b/lisp/ido.el
index 70d2d98..2cc10b2 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -1490,6 +1490,11 @@ Removes badly formatted data and ignored directories."
   ;; ido kill emacs hook
   (ido-save-history))
 
+(defun ido-common-initilization ()
+  (ido-init-completion-maps)
+  (add-hook 'minibuffer-setup-hook 'ido-minibuffer-setup)
+  (add-hook 'choose-completion-string-functions 'ido-choose-completion-string))
+
 (define-minor-mode ido-everywhere
   "Toggle using ido speed-ups everywhere file and directory names are read.
 With ARG, turn ido speed-up on if arg is positive, off otherwise."
@@ -1533,12 +1538,9 @@ This function also adds a hook to the minibuffer."
 	 (t nil)))
 
   (ido-everywhere (if ido-everywhere 1 -1))
-  (when ido-mode
-    (ido-init-completion-maps))
 
   (when ido-mode
-    (add-hook 'minibuffer-setup-hook 'ido-minibuffer-setup)
-    (add-hook 'choose-completion-string-functions 'ido-choose-completion-string)
+    (ido-common-initilization)
     (ido-load-history)
 
     (add-hook 'kill-emacs-hook 'ido-kill-emacs-hook)
@@ -4853,6 +4855,8 @@ DEF, if non-nil, is the default value."
 	(ido-directory-too-big nil)
 	(ido-context-switch-command 'ignore)
 	(ido-choice-list choices))
+    ;; Initialize ido before invoking ido-read-internal
+    (ido-common-initilization)
     (ido-read-internal 'list prompt hist def require-match initial-input)))
 
 (defun ido-unload-function ()