Permalink
Browse files

[Refactor] The main function should be clear and readable

  • Loading branch information...
1 parent 90ed2aa commit 3481b7222921374dc8ebc36583dee10b9b01c7cc @nonsequitur committed Dec 19, 2011
Showing with 7 additions and 3 deletions.
  1. +7 −3 smex.el
View
10 smex.el
@@ -78,14 +78,18 @@ Must be set before initializing Smex."
(defun smex ()
(interactive)
(if (smex-already-running)
- (smex-do-with-selected-item
- (lambda (ignore) (smex-update) (smex-read-and-run smex-ido-cache ido-text)))
- (and smex-auto-update (smex-detect-new-commands) (smex-update))
+ (smex-update-and-rerun)
+ (and smex-auto-update (smex-detect-new-commands)
+ (smex-update))
(smex-read-and-run smex-ido-cache)))
(defsubst smex-already-running ()
(and (boundp 'ido-choice-list) (eql ido-choice-list smex-ido-cache)))
+(defsubst smex-update-and-rerun ()
+ (smex-do-with-selected-item
+ (lambda (ignore) (smex-update) (smex-read-and-run smex-ido-cache ido-text))))
+
(defun smex-read-and-run (commands &optional initial-input)
(let ((chosen-item (intern (smex-completing-read commands initial-input))))
(if smex-custom-action

0 comments on commit 3481b72

Please sign in to comment.