]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/fsm/fsm.el
Make debbugs-newest-bugs more robust
[gnu-emacs-elpa] / packages / fsm / fsm.el
index 17f2291e0f7acd00d76adee0a863b78d387e1380..4ea57c00a138d0ee77a3f543eec140ca4ef46e87 100644 (file)
@@ -4,7 +4,7 @@
 
 ;; Author: Magnus Henoch <magnus.henoch@gmail.com>
 ;; Maintainer: Thomas Fitzsimmons <fitzsim@fitzsim.org>
-;; Version: 0.1ttn4
+;; Version: 0.2.1
 ;; Package-Requires: ((emacs "24.1") (cl-lib "0.5"))
 ;; Keywords: extensions
 
@@ -186,9 +186,10 @@ arguments.
               (put fsm :name ',name)
               (put fsm :state nil)
               (put fsm :state-data nil)
-              (put fsm :sleep ,(or sleep (lambda (secs)
-                                           (accept-process-output
-                                            nil secs))))
+              (put fsm :sleep ,(or sleep '(lambda (secs)
+                                            (accept-process-output
+                                             nil secs))))
+
               (put fsm :deferred nil)
               (fsm-update fsm state state-data timeout)
               fsm)))))))
@@ -324,7 +325,7 @@ event handler explicitly asks to keep the timer."
    ))
 
 (defun fsm-send (fsm event &optional callback)
-  "Send FSM EVENT asynchronously.
+  "Send EVENT to FSM asynchronously.
 If the state machine generates a response, eventually call
 CALLBACK with the response as only argument."
   (run-with-timer 0 nil #'fsm-send-sync fsm event callback))
@@ -332,7 +333,7 @@ CALLBACK with the response as only argument."
 (defun fsm-update (fsm new-state new-state-data timeout)
   "Update FSM with NEW-STATE, NEW-STATE-DATA and TIMEOUT."
   (let ((fsm-name (get fsm :name))
-        (old-state (get fsm :state)))
+       (old-state (get fsm :state)))
     (put fsm :state new-state)
     (put fsm :state-data new-state-data)
     (fsm-maybe-change-timer fsm timeout)
@@ -359,7 +360,7 @@ CALLBACK with the response as only argument."
          (apply 'fsm-send-sync fsm event))))))
 
 (defun fsm-send-sync (fsm event &optional callback)
-  "Send FSM EVENT synchronously.
+  "Send EVENT to FSM synchronously.
 If the state machine generates a response, eventually call
 CALLBACK with the response as only argument."
   (save-match-data
@@ -399,7 +400,7 @@ CALLBACK with the response as only argument."
                            result)))))))
 
 (defun fsm-call (fsm event)
-  "Send FSM EVENT synchronously, and wait for a reply.
+  "Send EVENT to FSM synchronously, and wait for a reply.
 Return the reply.  `with-timeout' might be useful."
   (let (reply)
     (fsm-send-sync fsm event (lambda (r) (setq reply (list r))))
@@ -422,7 +423,7 @@ Events sent are of the form (:sentinel PROCESS STRING)."
       (fsm-send-sync fsm (list :sentinel process string)))))
 
 (defun fsm-sleep (fsm secs)
-  "Let FSM receive events while sleeping up to SECS seconds."
+  "Sleep up to SECS seconds in a way that lets FSM receive events."
   (funcall (get fsm :sleep) secs))
 
 (defun fsm-get-state-data (fsm)