Permalink
Browse files

Add auto-initialization

  • Loading branch information...
1 parent 0170613 commit 132fde80e3234f2d6213d5971605c191e99f45ae @nonsequitur committed Aug 17, 2012
Showing with 8 additions and 2 deletions.
  1. +2 −1 README.markdown
  2. +6 −1 smex.el
View
3 README.markdown
@@ -17,7 +17,8 @@ commands. And to all the other commands, too.
* To auto-start Smex every time you open Emacs add these lines to your .emacs file:
(require 'smex) ; Not needed if you use package.el
- (smex-initialize)
+ (smex-initialize) ; Can be omitted. This might cause a (minimal) delay
+ ; when Smex is auto-initialized on its first run.
* Bind some keys:
View
7 smex.el
@@ -71,6 +71,7 @@ Set this to nil to disable fuzzy matching."
:type 'boolean
:group 'smex)
+(defvar smex-initialized-p nil)
(defvar smex-cache)
(defvar smex-ido-cache)
(defvar smex-data)
@@ -81,8 +82,11 @@ Set this to nil to disable fuzzy matching."
;;--------------------------------------------------------------------------------
;; Smex Interface
+;;;###autoload
(defun smex ()
(interactive)
+ (unless smex-initialized-p
+ (smex-initialize))
(if (smex-already-running)
(smex-update-and-rerun)
(and smex-auto-update
@@ -241,7 +245,8 @@ This function provides temporary means to aid the transition."
(setq smex-history nil smex-data nil))
(smex-detect-new-commands)
(smex-rebuild-cache)
- (add-hook 'kill-emacs-hook 'smex-save-to-file)))
+ (add-hook 'kill-emacs-hook 'smex-save-to-file))
+ (setq smex-initialized-p t))
(defun smex-initialize-ido ()
"Sets up a minimal Ido environment for `ido-completing-read'."

0 comments on commit 132fde8

Please sign in to comment.