 (defun smex-convert-for-ido (command-items)
   (mapcar (lambda (command-item)
             (let* ((command (car command-item))
-                   (keybinding (smex-find-keybinding command))
-                   (command-name (symbol-name command)))
+                   (command-name (symbol-name command))
+                   (keybinding
+                    (gethash command smex-command-keybindings)))
               (if keybinding
                   (format "%s (%s)" command-name keybinding)
                 command-name)))

  (smex-detect-new-commands)
  (smex-rebuild-cache)
  (add-hook 'kill-emacs-hook 'smex-save-to-file)
  (setq smex-initialized-p t))

(defun smex-initialize-ido ()

(defun smex-extract-command-name (pretty-name)
  "Given a string \"foo (C-c f)\", return \"foo\"."
  (car (split-string pretty-name " ")))

(defvar smex-command-keybindings
  (make-hash-table)
  "A keybinding (a string) for each command symbol.")

(defun smex-update-command-keybindings ()
  "Ensure `smex-command-keybindings' contains the latest keybindings.
This can take ~5 seconds, so we only run when Emacs
is idle."
  (interactive)
  (clrhash smex-command-keybindings)
  (mapc (lambda (symbol-with-index)
          (let* ((symbol (car symbol-with-index))
                 (keybinding (smex-find-keybinding symbol)))
            (if keybinding
                (puthash symbol keybinding smex-command-keybindings))))
        smex-cache))

(defun smex-find-keybinding (command)
  "Find the first keybinding for COMMAND, if one exists.
