From: Magnus H. <leg...@us...> - 2015-10-25 23:31:56
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "emacs-jabber". The branch, master has been updated via d5bfa1c62e6474a997e73a836524fdd322c0af44 (commit) via 92106a961fc54be33f82d7c09b65b43b79ed3fb9 (commit) from f2aaf7919d2a179e8a541761cad0adbba2f31331 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit d5bfa1c62e6474a997e73a836524fdd322c0af44 Author: Magnus Henoch <mag...@gm...> Date: Sun Oct 25 23:04:12 2015 +0000 Prefer fsm.el from ELPA fsm.el is now in GNU ELPA, so let's use it if it's installed. Also, let the jabber package depend on it. Keep a copy in jabber-fallback-lib directory, and use it if necessary. Notably, this one is still compatible with Emacs 23. diff --git a/Makefile.am b/Makefile.am index 9b43844..5eed578 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,7 +3,7 @@ ACLOCAL_AMFLAGS = -I m4 # for options in configure.ac. AUTOMAKE_OPTIONS = 1.11 -my_lisp_sources=fsm.el jabber-activity.el jabber-ahc-presence.el \ +my_lisp_sources=jabber-activity.el jabber-ahc-presence.el \ jabber-ahc.el jabber-alert.el jabber-autoaway.el jabber-avatar.el \ jabber-awesome.el jabber-ping.el jabber-libnotify.el jabber-console.el \ jabber-notifications.el \ @@ -25,7 +25,7 @@ jabber-watch.el jabber-widget.el jabber-wmii.el jabber-xmessage.el \ jabber-muc-nick-coloring.el \ jabber-xml.el jabber.el srv.el jabber-tmux.el jabber-ourversion.el -compat_lisp_sources = jabber-fallback-lib/hexrgb.el +compat_lisp_sources = jabber-fallback-lib/hexrgb.el jabber-fallback-lib/fsm.el dist_lisp_LISP=$(my_lisp_sources) $(compat_lisp_sources) jabber-autoloads.el MAINTAINERCLEANFILES=jabber-autoloads.el diff --git a/jabber-core.el b/jabber-core.el index 0306293..de05a34 100644 --- a/jabber-core.el +++ b/jabber-core.el @@ -27,7 +27,16 @@ (require 'jabber-util) (require 'jabber-logon) (require 'jabber-conn) -(require 'fsm) +(eval-and-compile + (or (ignore-errors (require 'fsm)) + (ignore-errors + (let ((load-path (cons (expand-file-name + "jabber-fallback-lib" + (file-name-directory (locate-library "jabber"))) + load-path))) + (require 'fsm))) + (error + "fsm not found in `load-path' or jabber-fallback-lib/ directory."))) (require 'jabber-sasl) (require 'jabber-console) diff --git a/fsm.el b/jabber-fallback-lib/fsm.el similarity index 100% rename from fsm.el rename to jabber-fallback-lib/fsm.el diff --git a/jabber-pkg.el.in b/jabber-pkg.el.in index f255fc4..bcd7f48 100644 --- a/jabber-pkg.el.in +++ b/jabber-pkg.el.in @@ -1,4 +1,5 @@ ;; For ELPA: http://tromey.com/elpa/ -(define-package "jabber" "@PACKAGE_VERSION@" "A Jabber client for Emacs.") +(define-package "jabber" "@PACKAGE_VERSION@" "A Jabber client for Emacs." + '((fsm "0.2"))) ;; arch-tag: fa652136-12f7-11dd-b4c4-000a95c2fcd0 diff --git a/jabber-socks5.el b/jabber-socks5.el index fa8ac0c..97f6d8a 100644 --- a/jabber-socks5.el +++ b/jabber-socks5.el @@ -24,7 +24,8 @@ (require 'jabber-si-server) (require 'jabber-si-client) -(require 'fsm) +;; jabber-core will require fsm for us +(require 'jabber-core) (eval-when-compile (require 'cl)) (defvar jabber-socks5-pending-sessions nil commit 92106a961fc54be33f82d7c09b65b43b79ed3fb9 Author: Magnus Henoch <mag...@gm...> Date: Sun Oct 25 22:47:02 2015 +0000 FSMs are symbols, not proplists Instead of FSMs being proplists, make them uninterned symbols, storing their properties in the proplist slot. This makes debugging much more pleasant, as backtraces no longer display the entire state data multiple times. diff --git a/fsm.el b/fsm.el index 4bc4ebf..e97dc09 100644 --- a/fsm.el +++ b/fsm.el @@ -167,14 +167,16 @@ arguments. ,docstring ,@interactive-spec (fsm-debug-output "Starting %s" ',name) - (let ((fsm (list :fsm ',name))) + (let ((fsm (gensym (concat "fsm-" ,(symbol-name 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))) - :deferred nil)) + (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 :deferred nil) (fsm-update fsm state state-data timeout) fsm))))))) @@ -286,20 +288,17 @@ any state machines using them. Return nil." 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) - :timeout (run-with-timer secs - nil - #'fsm-send-sync fsm - :timeout)))) + (put fsm + :timeout (run-with-timer + secs nil + #'fsm-send-sync fsm :timeout))) (defun fsm-stop-timer (fsm) "Stop the timeout timer of FSM." - (let ((timer (plist-get (cddr fsm) :timeout))) + (let ((timer (get fsm :timeout))) (when (timerp timer) (cancel-timer timer) - (setf (cddr fsm) (plist-put (cddr fsm) :timeout nil))))) + (put fsm :timeout nil)))) (defun fsm-maybe-change-timer (fsm timeout) "Change the timer of FSM according to TIMEOUT." @@ -318,10 +317,10 @@ CALLBACK with the response as only argument." (run-with-timer 0 nil #'fsm-send-sync fsm event callback)) (defun fsm-update (fsm new-state new-state-data timeout) - (let ((fsm-name (cadr fsm)) - (old-state (plist-get (cddr fsm) :state))) - (plist-put (cddr fsm) :state new-state) - (plist-put (cddr fsm) :state-data new-state-data) + (let ((fsm-name (get fsm :name)) + (old-state (get fsm :state))) + (put fsm :state new-state) + (put fsm :state-data new-state-data) (fsm-maybe-change-timer fsm timeout) ;; On state change, call enter function and send deferred events @@ -335,14 +334,13 @@ CALLBACK with the response as only argument." (destructuring-bind (newer-state-data newer-timeout) (funcall enter-fn fsm new-state-data) (fsm-debug-output "Using data from enter function") - (plist-put (cddr fsm) :state-data newer-state-data) + (put fsm :state-data newer-state-data) (fsm-maybe-change-timer fsm newer-timeout)) ((debug error) (fsm-debug-output "Didn't work: %S" e))))) - (let ((deferred (nreverse (plist-get (cddr fsm) :deferred)))) - (setf (cddr fsm) - (plist-put (cddr fsm) :deferred nil)) + (let ((deferred (nreverse (get fsm :deferred)))) + (put fsm :deferred nil) (dolist (event deferred) (apply 'fsm-send-sync fsm event)))))) @@ -351,9 +349,9 @@ CALLBACK with the response as only argument." If the state machine generates a response, eventually call CALLBACK with the response as only argument." (save-match-data - (let* ((fsm-name (second fsm)) - (state (plist-get (cddr fsm) :state)) - (state-data (plist-get (cddr fsm) :state-data)) + (let* ((fsm-name (get fsm :name)) + (state (get fsm :state)) + (state-data (get fsm :state-data)) (state-fn (gethash state (get fsm-name :fsm-event)))) ;; If the event is a list, output only the car, to avoid an ;; overflowing debug buffer. @@ -366,9 +364,8 @@ CALLBACK with the response as only argument." ;; Special case for deferring an event until next state change. (cond ((eq result :defer) - (let ((deferred (plist-get (cddr fsm) :deferred))) - (plist-put (cddr fsm) :deferred - (cons (list event callback) deferred)))) + (let ((deferred (get fsm :deferred))) + (put fsm :deferred (cons (list event callback) deferred)))) ((null result) (fsm-debug-output "Warning: event %S ignored in state %s/%s" event fsm-name state)) ((eq (car-safe result) :error-signaled) @@ -411,13 +408,13 @@ Events sent are of the form (:sentinel PROCESS STRING)." (defun fsm-sleep (fsm secs) "Sleep up to SECS seconds in a way that lets FSM receive events." - (funcall (plist-get (cddr fsm) :sleep) secs)) + (funcall (get fsm :sleep) secs)) (defun fsm-get-state-data (fsm) "Return the state data of FSM. Note the absence of a set function. The fsm should manage its state data itself; other code should just send messages to it." - (plist-get (cddr fsm) :state-data)) + (get fsm :state-data)) (provide 'fsm) ----------------------------------------------------------------------- Summary of changes: Makefile.am | 4 +- jabber-core.el | 11 ++++++- fsm.el => jabber-fallback-lib/fsm.el | 59 ++++++++++++++++------------------ jabber-pkg.el.in | 3 +- jabber-socks5.el | 3 +- 5 files changed, 44 insertions(+), 36 deletions(-) rename fsm.el => jabber-fallback-lib/fsm.el (92%) hooks/post-receive -- emacs-jabber |