;; possibly returning a value.
;; The essential macros/functions are:
-;;
+;;
;; define-state-machine - create start-FOO function
;; define-state - event handler for each state (required)
;; define-enter-state - called when entering a state (optional)
;; (:event (zow :ping (if (= 0 count)
;; (fsm-goodbye-cruel-world 'pingpong)
;; 3))))))))
-;;
;; (fsm-send (start-pingpong -16) t)
;;
;; Copy into a buffer, uncomment, and type M-x eval-buffer RET.
;; form with `nil', eval just the `labels' form and then type
;; M-x start-pingpong RET -16 RET.
+;; Version 0.2:
+;; -- Delete trailing whitespace.
+
;; NOTE: This is version 0.1ttn4 of fsm.el, with the following
;; mods (an exercise in meta-meta-programming ;-) by ttn:
;; -- Refill for easy (traditional 80-column) perusal.
\(fn NAME :start ((ARG ...) DOCSTRING BODY) [:sleep SLEEP-FUNCTION])"
(declare (debug (&define name :name start
&rest
- &or [":start"
+ &or [":start"
(lambda-list
[&optional ("interactive" interactive)]
stringp def-body)]
The timer is canceled if another event occurs before, unless the
event handler explicitly asks to keep the timer."
(fsm-stop-timer fsm)
- (setf (cddr fsm)
- (plist-put
- (cddr fsm)
+ (setf (cddr fsm)
+ (plist-put
+ (cddr fsm)
:timeout (run-with-timer secs
nil
- #'fsm-send-sync fsm
+ #'fsm-send-sync fsm
:timeout))))
(defun fsm-stop-timer (fsm)
(fsm-debug-output "Sent %S to %s in state %s"
(or (car-safe event) event) fsm-name state)
(let ((result (condition-case e
- (funcall state-fn fsm state-data event
+ (funcall state-fn fsm state-data event
(or callback 'ignore))
((debug error) (cons :error-signaled e)))))
;; Special case for deferring an event until next state change.