branch: elpa/pacmacs
commit bfb089d1def3eb2fe51d4bd90d05cccb8556ec53
Author: rexim <[email protected]>
Commit: rexim <[email protected]>
Exctract init code to a function (#115)
---
pacmacs.el | 10 +++++++---
tools/it-recorder.el | 15 ++-------------
2 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/pacmacs.el b/pacmacs.el
index 39c5844bda..701ded9857 100644
--- a/pacmacs.el
+++ b/pacmacs.el
@@ -89,19 +89,23 @@
;;;###autoload
(defun pacmacs-start ()
(interactive)
+ (pacmacs--initialize-game 'pacmacs-tick)
+ (pacmacs-mode))
+
+(defun pacmacs--initialize-game (tick-function)
(switch-to-buffer pacmacs-buffer-name)
- (pacmacs-mode)
(setq pacmacs-lives 3)
(setq pacmacs-score 0)
(setq pacmacs-levels (pacmacs--get-list-of-levels))
(setq pacmacs-current-level 0)
-
+
(pacmacs--load-current-level)
(pacmacs--switch-to-play-state)
(unless pacmacs-timer
- (setq pacmacs-timer (run-at-time nil (* pacmacs-tick-duration-ms 0.001)
'pacmacs-tick))))
+ (setq pacmacs-timer (run-at-time nil (* pacmacs-tick-duration-ms 0.001)
+ tick-function))))
(defun pacmacs-destroy ()
(when pacmacs-timer
diff --git a/tools/it-recorder.el b/tools/it-recorder.el
index f65d1aff6c..e31424152d 100644
--- a/tools/it-recorder.el
+++ b/tools/it-recorder.el
@@ -55,17 +55,6 @@
(defun pacmacs--start-it-recorder ()
(interactive)
- (switch-to-buffer pacmacs-buffer-name)
+ (pacmacs--initialize-game 'pacmacs-record-tick)
(pacmacs-it-recorder-mode)
-
- (setq pacmacs-lives 3)
- (setq pacmacs-score 0)
- (setq pacmacs-levels (pacmacs--get-list-of-levels))
- (setq pacmacs-current-level 0)
- (pacmacs--reset-recorder)
-
- (pacmacs--load-current-level)
- (pacmacs--switch-to-play-state)
-
- (unless pacmacs-timer
- (setq pacmacs-timer (run-at-time nil (* pacmacs-tick-duration-ms 0.001)
'pacmacs-record-tick))))
+ (pacmacs--reset-recorder))