 
 (defun smex-initialize-ido ()
   "Sets up a minimal Ido environment for `ido-completing-read'."
-  (ido-init-completion-maps)
+  (with-no-warnings ; `ido-init-completion-maps' is deprecated in Emacs 25
+    (ido-init-completion-maps))
   (add-hook 'minibuffer-setup-hook 'ido-minibuffer-setup))
+
+(defsubst smex-save-file-not-empty-p ()
+  (string-match-p "\[^[:space:]\]" (buffer-string)))
 
 (defun smex-load-save-file ()
   "Loads `smex-history' and `smex-data' from `smex-save-file'"

            (error (if (smex-save-file-not-empty-p)
                       (error "Invalid data in smex-save-file (%s). Can't restore history."
                              smex-save-file)
                     (if (not (boundp 'smex-history)) (setq smex-history))
                     (if (not (boundp 'smex-data))    (setq smex-data))))))
      (setq smex-history nil smex-data nil))))

(defsubst smex-save-file-not-empty-p ()
  (string-match-p "\[^[:space:]\]" (buffer-string)))

(defun smex-save-history ()
  "Updates `smex-history'"
  (setq smex-history nil)
  (let ((cell smex-cache))
    (dotimes (i smex-history-length)
      (setq smex-history (cons (caar cell) smex-history))
      (setq cell (cdr cell))))
  (setq smex-history (nreverse smex-history)))

(defun smex-save-to-file ()
  (interactive)
  (smex-save-history)
  (with-temp-file (expand-file-name smex-save-file)
    (ido-pp 'smex-history)
    (ido-pp 'smex-data)))

;;--------------------------------------------------------------------------------
;; Ranking

    (setq buffer-read-only t)
    (let ((inhibit-read-only t))
      (erase-buffer)
      (smex-pp unbound-commands))
    (set-buffer-modified-p nil)
    (goto-char (point-min))))

;; A copy of `ido-pp' that's compatible with lexical bindings
(defun smex-pp* (list list-name)
  (let ((print-level nil) (eval-expression-print-level nil)
        (print-length nil) (eval-expression-print-length nil))
    (insert "\n;; ----- " list-name " -----\n(\n ")
    (while list
      (let* ((elt (car list))
             (s (if (consp elt) (car elt) elt)))
        (if (and (stringp s) (= (length s) 0))
            (setq s nil))
        (if s
            (prin1 elt (current-buffer)))
        (if (and (setq list (cdr list)) s)
            (insert "\n "))))
    (insert "\n)\n")))

(provide 'smex)
;;; smex.el ends here
