[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/fsm 384864d 03/16: fsm: Fix formatting
From: |
Stefan Monnier |
Subject: |
[elpa] externals/fsm 384864d 03/16: fsm: Fix formatting |
Date: |
Sun, 29 Nov 2020 12:00:23 -0500 (EST) |
branch: externals/fsm
commit 384864d3beb85028168e5742f8ab18c4747683e7
Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Commit: Thomas Fitzsimmons <fitzsim@fitzsim.org>
fsm: Fix formatting
---
fsm.el | 69 ++++++++++++++++++++++++++++++++++--------------------------------
1 file changed, 36 insertions(+), 33 deletions(-)
diff --git a/fsm.el b/fsm.el
index db2a17a..2535e05 100644
--- a/fsm.el
+++ b/fsm.el
@@ -90,6 +90,7 @@
;; Version 0.2:
;; -- Delete trailing whitespace.
+;; -- Fix formatting.
;; NOTE: This is version 0.1ttn4 of fsm.el, with the following
;; mods (an exercise in meta-meta-programming ;-) by ttn:
@@ -126,9 +127,9 @@ FORMAT and ARGS are passed to `format'."
(save-excursion
(goto-char (point-max))
(insert (if fsm-debug-timestamp-format
- (format-time-string fsm-debug-timestamp-format)
- (concat (current-time-string) ": "))
- (apply 'format format args) "\n")))))
+ (format-time-string fsm-debug-timestamp-format)
+ (concat (current-time-string) ": "))
+ (apply 'format format args) "\n")))))
(defmacro* define-state-machine (name &key start sleep)
"Define a state machine class called NAME.
@@ -156,26 +157,26 @@ arguments.
stringp def-body)]
[":sleep" function-form])))
(let ((start-name (intern (format "start-%s" name)))
- interactive-spec)
+ interactive-spec)
(destructuring-bind (arglist docstring &body body) start
(when (and (consp (car body)) (eq 'interactive (caar body)))
- (setq interactive-spec (list (pop body))))
+ (setq interactive-spec (list (pop body))))
(unless (stringp docstring)
(error "Docstring is not a string"))
`(progn
- (put ',name :fsm-enter (make-hash-table :size 11 :test 'eq))
- (put ',name :fsm-event (make-hash-table :size 11 :test 'eq))
+ (put ',name :fsm-enter (make-hash-table :size 11 :test 'eq))
+ (put ',name :fsm-event (make-hash-table :size 11 :test 'eq))
(defun ,start-name ,arglist
,docstring
- ,@interactive-spec
+ ,@interactive-spec
(fsm-debug-output "Starting %s" ',name)
(let ((fsm (list :fsm ',name)))
(destructuring-bind (state state-data &optional timeout)
(progn ,@body)
(nconc fsm (list :state nil :state-data nil
:sleep ,(or sleep (lambda (secs)
- (accept-process-output
- nil secs)))
+ (accept-process-output
+ nil secs)))
:deferred nil))
(fsm-update fsm state state-data timeout)
fsm)))))))
@@ -209,7 +210,7 @@ which case the event will be resent when the state machine
enters
another state."
(declare (debug (&define name name :name handler lambda-list def-body)))
`(setf (gethash ',state-name (get ',fsm-name :fsm-event))
- (lambda ,arglist ,@body)))
+ (lambda ,arglist ,@body)))
(defmacro* define-enter-state (fsm-name state-name arglist &body body)
"Define a function to call when FSM-NAME enters the state STATE-NAME.
@@ -228,14 +229,14 @@ TIMEOUT A number: send timeout event after this
many seconds
:keep: let existing timer continue"
(declare (debug (&define name name :name enter lambda-list def-body)))
`(setf (gethash ',state-name (get ',fsm-name :fsm-enter))
- (lambda ,arglist ,@body)))
+ (lambda ,arglist ,@body)))
(defmacro* define-fsm (name &key
- start sleep states
- (fsm-name 'fsm)
- (state-data-name 'state-data)
- (callback-name 'callback)
- (event-name 'event))
+ start sleep states
+ (fsm-name 'fsm)
+ (state-data-name 'state-data)
+ (callback-name 'callback)
+ (event-name 'event))
"Define a state machine class called NAME, along with its STATES.
This macro is (further) syntatic sugar for `define-state-machine',
`define-state' and `define-enter-state' macros, q.v.
@@ -254,18 +255,18 @@ used to construct the state functions' arglists."
`(progn
(define-state-machine ,name :start ,start :sleep ,sleep)
,@(loop for (state-name . spec) in states
- if (assq :enter spec) collect
- `(define-enter-state ,name ,state-name
- (,fsm-name ,state-data-name)
- ,@(cdr it))
- end
- if (assq :event spec) collect
- `(define-state ,name ,state-name
- (,fsm-name ,state-data-name
- ,event-name
- ,callback-name)
- ,@(cdr it))
- end)))
+ if (assq :enter spec) collect
+ `(define-enter-state ,name ,state-name
+ (,fsm-name ,state-data-name)
+ ,@(cdr it))
+ end
+ if (assq :event spec) collect
+ `(define-state ,name ,state-name
+ (,fsm-name ,state-data-name
+ ,event-name
+ ,callback-name)
+ ,@(cdr it))
+ end)))
(defun fsm-goodbye-cruel-world (name)
"Unbind functions related to fsm NAME (a symbol).
@@ -321,7 +322,7 @@ CALLBACK with the response as only argument."
(defun fsm-update (fsm new-state new-state-data timeout)
(let ((fsm-name (cadr fsm))
- (old-state (plist-get (cddr fsm) :state)))
+ (old-state (plist-get (cddr fsm) :state)))
(plist-put (cddr fsm) :state new-state)
(plist-put (cddr fsm) :state-data new-state-data)
(fsm-maybe-change-timer fsm timeout)
@@ -370,9 +371,10 @@ CALLBACK with the response as only argument."
((eq result :defer)
(let ((deferred (plist-get (cddr fsm) :deferred)))
(plist-put (cddr fsm) :deferred
- (cons (list event callback) deferred))))
+ (cons (list event callback) deferred))))
((null result)
- (fsm-debug-output "Warning: event %S ignored in state %s/%s" event
fsm-name state))
+ (fsm-debug-output "Warning: event %S ignored in state %s/%s"
+ event fsm-name state))
((eq (car-safe result) :error-signaled)
(fsm-debug-output "Error in %s/%s: %s"
fsm-name state
@@ -380,7 +382,8 @@ CALLBACK with the response as only argument."
((and (listp result)
(<= 2 (length result))
(<= (length result) 3))
- (destructuring-bind (new-state new-state-data &optional timeout)
result
+ (destructuring-bind (new-state new-state-data &optional timeout)
+ result
(fsm-update fsm new-state new-state-data timeout)))
(t
(fsm-debug-output "Incorrect return value in %s/%s: %S"
- [elpa] branch externals/fsm created (now b7d74b3), Stefan Monnier, 2020/11/29
- [elpa] externals/fsm cfbe515 06/16: fsm: Add FSM name to some fsm-debug-output messages, Stefan Monnier, 2020/11/29
- [elpa] externals/fsm 3acbc4d 14/16: packages/fsm: Bump version to 0.2.1, Stefan Monnier, 2020/11/29
- [elpa] externals/fsm aaea24a 01/16: fsm: Import fsm.el from emacs-jabber, Stefan Monnier, 2020/11/29
- [elpa] externals/fsm 384864d 03/16: fsm: Fix formatting,
Stefan Monnier <=
- [elpa] externals/fsm e3c4c03 04/16: fsm: Use lexical binding, Stefan Monnier, 2020/11/29
- [elpa] externals/fsm 74d3364 11/16: fsm: Bump version to 0.2, Stefan Monnier, 2020/11/29
- [elpa] externals/fsm 3548ca5 12/16: fsm: Revert some changes suggested by checkdoc, Stefan Monnier, 2020/11/29
- [elpa] externals/fsm 1e86cbc 09/16: fsm: Fix copyright, Stefan Monnier, 2020/11/29
- [elpa] externals/fsm b7d74b3 16/16: * .gitignore: New file, Stefan Monnier, 2020/11/29
- [elpa] externals/fsm 1044ede 10/16: fsm: Change FSMs from plists to uninterned symbols, Stefan Monnier, 2020/11/29
- [elpa] externals/fsm 3b66086 13/16: packages/fsm: Fix compilation error, Stefan Monnier, 2020/11/29
- [elpa] externals/fsm 5e69613 07/16: fsm: Fix checkdoc errors, Stefan Monnier, 2020/11/29
- [elpa] externals/fsm 5ecf3cb 05/16: fsm: Port to cl-lib, Stefan Monnier, 2020/11/29
- [elpa] externals/fsm ccc2f3f 08/16: fsm: Add packaging fields, Stefan Monnier, 2020/11/29