branch: externals/rudel commit 9983f585883e9092c7d0befe603c0c794f0b8f76 Author: Stefan Monnier <monn...@iro.umontreal.ca> Commit: Stefan Monnier <monn...@iro.umontreal.ca>
Use lexical-binding instead of lexical-let --- rudel-debug.el | 60 +++++++---------- rudel-infinote-client.el | 26 ++++--- rudel-interactive.el | 9 ++- rudel-loaddefs.el | 51 +++++++++----- rudel-mode.el | 25 ++++--- rudel-obby-client.el | 69 +++++++++---------- rudel-obby-server.el | 56 +++++++--------- rudel-socket.el | 84 +++++++++++------------ rudel-transport-util.el | 168 +++++++++++++++++++++------------------------- rudel-util.el | 7 +- rudel-xmpp-sasl.el | 17 ++--- rudel-xmpp.el | 28 ++++---- 12 files changed, 290 insertions(+), 310 deletions(-) diff --git a/rudel-debug.el b/rudel-debug.el index 7aca207..e87a6b9 100644 --- a/rudel-debug.el +++ b/rudel-debug.el @@ -1,6 +1,6 @@ -;;; rudel-debug.el --- Debugging functions for Rudel +;;; rudel-debug.el --- Debugging functions for Rudel -*- lexical-binding:t -*- ;; -;; Copyright (C) 2009, 2010, 2014 Free Software Foundation, Inc. +;; Copyright (C) 2009, 2010, 2014, 2016 Free Software Foundation, Inc. ;; ;; Author: Jan Moringen <scym...@users.sourceforge.net> ;; Keywords: rudel, debugging @@ -86,6 +86,8 @@ ;;; Data debug functions ;; +(defvar rudel-current-session) +(defvar rudel-buffer-document) (defun rudel-adebug-discover () "Analyze list of discoverable sessions in data debug buffer." @@ -203,8 +205,7 @@ (object-print data)) (t (prin1-to-string data))))) - (save-excursion - (set-buffer buffer) + (with-current-buffer buffer (goto-char 0) (insert prefix (if label @@ -239,7 +240,7 @@ TAG and LABEL determine the logging style." "Saves state of state machines across one function call.") (defmethod rudel-switch :before - ((this rudel-state-machine) state &rest arguments) + ((this rudel-state-machine) _state &rest _) "Store name of STATE for later printing." (with-slots (state) this (setq rudel-debug-old-state @@ -247,7 +248,7 @@ TAG and LABEL determine the logging style." ) (defmethod rudel-switch :after - ((this rudel-state-machine) state &rest arguments) + ((this rudel-state-machine) _state &rest arguments) "Log STATE and ARGUMENTS to debug stream." (with-slots (state) this (let ((old-state rudel-debug-old-state) @@ -292,16 +293,13 @@ TAG and LABEL determine the logging style." filter1) "Log DATA as it goes through THIS." (with-slots (filter) this - (lexical-let ((this1 this) - (filter2 filter1)) - (setq filter (lambda (data) - (rudel-debug-write - this1 - :received - "ASSEMBLE" - data) - (funcall filter2 data))))) - ) + (setq filter (lambda (data) + (rudel-debug-write + this + :received + "ASSEMBLE" + data) + (funcall filter1 data))))) (defmethod rudel-send :before ((this rudel-assembling-transport-filter) data) @@ -342,16 +340,13 @@ TAG and LABEL determine the logging style." filter1) "Log DATA as it goes through THIS." (with-slots (filter) this - (lexical-let ((this1 this) - (filter2 filter1)) - (setq filter (lambda (data) - (rudel-debug-write - this1 - :received - "PARSE" - (format "%s" data) data) - (funcall filter2 data))))) - ) + (setq filter (lambda (data) + (rudel-debug-write + this + :received + "PARSE" + (format "%s" data) data) + (funcall filter1 data))))) (defmethod rudel-send :before ((this rudel-parsing-transport-filter) string-or-data) @@ -380,14 +375,11 @@ TAG and LABEL determine the logging style." (defmethod rudel-set-filter ((this rudel-socket-transport) filter) "Log DATA as it goes through THIS." - (lexical-let ((this1 this) - (filter1 filter)) - (oset - this :filter - (lambda (data) - (rudel-debug-write this1 :received "SOCKET" data) - (funcall filter1 data)))) - ) + (oset + this :filter + (lambda (data) + (rudel-debug-write this :received "SOCKET" data) + (funcall filter data)))) (defmethod rudel-send :before ((this rudel-socket-transport) data) diff --git a/rudel-infinote-client.el b/rudel-infinote-client.el index 6057940..eb011cf 100644 --- a/rudel-infinote-client.el +++ b/rudel-infinote-client.el @@ -1,6 +1,6 @@ -;;; rudel-infinote-client.el --- Client part of the infinote backend for Rudel +;;; rudel-infinote-client.el --- Client part of the infinote backend for Rudel -*- lexical-binding:t -*- ;; -;; Copyright (C) 2009, 2010, 2014 Free Software Foundation, Inc. +;; Copyright (C) 2009, 2010, 2014, 2016 Free Software Foundation, Inc. ;; ;; Author: Jan Moringen <scym...@users.sourceforge.net> ;; Keywords: rudel, infinote, client @@ -36,8 +36,7 @@ ;;; Code: ;; -(eval-when-compile - (require 'cl)) +(require 'cl) (require 'warnings) @@ -97,7 +96,7 @@ side.")) "TODO") (defmethod initialize-instance ((this rudel-infinote-client-connection) - slots) + _slots) "" ;; Initialize slots of THIS. (when (next-method-p) @@ -109,10 +108,9 @@ side.")) ;; Install handler. (with-slots (transport) this - (lexical-let ((this1 this)) - (rudel-set-filter transport - (lambda (xml) - (rudel-receive this1 xml))))) + (rudel-set-filter transport + (lambda (xml) + (rudel-receive this xml)))) ;; (with-slots (session) this @@ -175,8 +173,8 @@ which case it is the name of a group." group-or-name)))) (remhash name groups)))) -(defmethod rudel-make-and-add-group ((this rudel-infinote-client-connection) - type name method &optional node) +(defmethod rudel-make-and-add-group ((_this rudel-infinote-client-connection) + _type name method &optional node) "Create a group object and add it to THIS." ;; TODO the backend creates these (let ((group (rudel-infinote-group-text-document @@ -346,7 +344,7 @@ WHICH is compared to the result of KEY using TEST." ;; list of subscribed users of DOCUMENT. ) -(defmethod rudel-unsubscribe-from ((this rudel-infinote-client-connection) +(defmethod rudel-unsubscribe-from ((_this rudel-infinote-client-connection) document) "" ;; Delete the jupiter context for DOCUMENT. @@ -424,9 +422,9 @@ WHICH is compared to the result of KEY using TEST." ;; (jupiter-local-operation context operation)) ) -(defmethod rudel-remote-operation ((this rudel-infinote-client-connection) +(defmethod rudel-remote-operation ((_this rudel-infinote-client-connection) document user - remote-revision local-revision + _remote-revision _local-revision operation) "Handle OPERATION received through THIS connection performed by USER on DOCUMENT." (let* (;; Find jupiter context for DOCUMENT. diff --git a/rudel-interactive.el b/rudel-interactive.el index a95a4d3..782e9c1 100644 --- a/rudel-interactive.el +++ b/rudel-interactive.el @@ -1,4 +1,4 @@ -;;; rudel-interactive.el --- User interaction functions for Rudel. +;;; rudel-interactive.el --- User interaction functions for Rudel. -*- lexical-binding:t -*- ;; ;; Copyright (C) 2008-2010, 2014, 2016 Free Software Foundation, Inc. ;; @@ -251,19 +251,18 @@ sources for a matching password entry." "Return a progress reporter that displays LABEL along with states. This function's primary purpose is constructing callbacks suitable for `rudel-state-wait'" - (lexical-let ((label1 label) - (reporter (make-progress-reporter label))) + (let ((reporter (make-progress-reporter label))) (lambda (state) (cond ;; For all states, just spin. ((consp state) (progress-reporter-force-update - reporter nil (format "%s(%s)" label1 (car state)))) + reporter nil (format "%s(%s)" label (car state)))) ;; Done (t (progress-reporter-force-update - reporter nil label1) + reporter nil label) (progress-reporter-done reporter))))) ) diff --git a/rudel-loaddefs.el b/rudel-loaddefs.el index db4d8c5..685ecc5 100644 --- a/rudel-loaddefs.el +++ b/rudel-loaddefs.el @@ -140,26 +140,43 @@ service type TYPE. ;;;*** -;;;### (autoloads nil nil ("adopted-compound.el" "adopted-delete.el" -;;;;;; "adopted-insert.el" "adopted-nop.el" "adopted-operation.el" -;;;;;; "adopted.el" "jupiter-compound.el" "jupiter-delete.el" "jupiter-insert.el" -;;;;;; "jupiter-nop.el" "jupiter-operation.el" "jupiter.el" "rudel-autoloads.el" -;;;;;; "rudel-chat.el" "rudel-color.el" "rudel-debug.el" "rudel-display.el" -;;;;;; "rudel-errors.el" "rudel-hooks.el" "rudel-icons.el" "rudel-infinote-client.el" -;;;;;; "rudel-infinote-display.el" "rudel-infinote-document.el" -;;;;;; "rudel-infinote-errors.el" "rudel-infinote-group-directory.el" +;;;### (autoloads nil nil ("adopted-compound.el" "adopted-compound.el" +;;;;;; "adopted-delete.el" "adopted-delete.el" "adopted-insert.el" +;;;;;; "adopted-insert.el" "adopted-nop.el" "adopted-nop.el" "adopted-operation.el" +;;;;;; "adopted-operation.el" "adopted.el" "adopted.el" "jupiter-compound.el" +;;;;;; "jupiter-compound.el" "jupiter-delete.el" "jupiter-delete.el" +;;;;;; "jupiter-insert.el" "jupiter-insert.el" "jupiter-nop.el" +;;;;;; "jupiter-nop.el" "jupiter-operation.el" "jupiter-operation.el" +;;;;;; "jupiter.el" "jupiter.el" "rudel-autoloads.el" "rudel-chat.el" +;;;;;; "rudel-chat.el" "rudel-color.el" "rudel-color.el" "rudel-debug.el" +;;;;;; "rudel-display.el" "rudel-display.el" "rudel-errors.el" "rudel-errors.el" +;;;;;; "rudel-hooks.el" "rudel-hooks.el" "rudel-icons.el" "rudel-icons.el" +;;;;;; "rudel-infinote-client.el" "rudel-infinote-display.el" "rudel-infinote-display.el" +;;;;;; "rudel-infinote-document.el" "rudel-infinote-document.el" +;;;;;; "rudel-infinote-errors.el" "rudel-infinote-errors.el" "rudel-infinote-group-directory.el" +;;;;;; "rudel-infinote-group-directory.el" "rudel-infinote-group-document.el" ;;;;;; "rudel-infinote-group-document.el" "rudel-infinote-group-text-document.el" +;;;;;; "rudel-infinote-group-text-document.el" "rudel-infinote-group.el" ;;;;;; "rudel-infinote-group.el" "rudel-infinote-node-directory.el" -;;;;;; "rudel-infinote-node.el" "rudel-infinote-state.el" "rudel-infinote-text-document.el" -;;;;;; "rudel-infinote-user.el" "rudel-infinote-util.el" "rudel-interactive.el" -;;;;;; "rudel-mode.el" "rudel-obby-client.el" "rudel-obby-debug.el" -;;;;;; "rudel-obby-display.el" "rudel-obby-errors.el" "rudel-obby-server.el" +;;;;;; "rudel-infinote-node-directory.el" "rudel-infinote-node.el" +;;;;;; "rudel-infinote-node.el" "rudel-infinote-state.el" "rudel-infinote-state.el" +;;;;;; "rudel-infinote-text-document.el" "rudel-infinote-text-document.el" +;;;;;; "rudel-infinote-user.el" "rudel-infinote-user.el" "rudel-infinote-util.el" +;;;;;; "rudel-infinote-util.el" "rudel-interactive.el" "rudel-mode.el" +;;;;;; "rudel-obby-client.el" "rudel-obby-debug.el" "rudel-obby-debug.el" +;;;;;; "rudel-obby-display.el" "rudel-obby-display.el" "rudel-obby-errors.el" +;;;;;; "rudel-obby-errors.el" "rudel-obby-server.el" "rudel-obby-state.el" ;;;;;; "rudel-obby-state.el" "rudel-obby-util.el" "rudel-operations.el" -;;;;;; "rudel-operators.el" "rudel-overlay.el" "rudel-pkg.el" "rudel-protocol.el" -;;;;;; "rudel-speedbar.el" "rudel-state-machine.el" "rudel-transport-util.el" -;;;;;; "rudel-transport.el" "rudel-util.el" "rudel-xml.el" "rudel-xmpp-debug.el" -;;;;;; "rudel-xmpp-sasl.el" "rudel-xmpp-state.el" "rudel-xmpp-tls.el" -;;;;;; "rudel-xmpp-util.el" "rudel.el") (0 0 0 0)) +;;;;;; "rudel-operations.el" "rudel-operators.el" "rudel-operators.el" +;;;;;; "rudel-overlay.el" "rudel-overlay.el" "rudel-pkg.el" "rudel-protocol.el" +;;;;;; "rudel-protocol.el" "rudel-speedbar.el" "rudel-speedbar.el" +;;;;;; "rudel-state-machine.el" "rudel-state-machine.el" "rudel-transport-util.el" +;;;;;; "rudel-transport-util.el" "rudel-transport.el" "rudel-transport.el" +;;;;;; "rudel-util.el" "rudel-xml.el" "rudel-xml.el" "rudel-xmpp-debug.el" +;;;;;; "rudel-xmpp-debug.el" "rudel-xmpp-sasl.el" "rudel-xmpp-state.el" +;;;;;; "rudel-xmpp-state.el" "rudel-xmpp-tls.el" "rudel-xmpp-tls.el" +;;;;;; "rudel-xmpp-util.el" "rudel-xmpp-util.el" "rudel.el" "rudel.el") +;;;;;; (0 0 0 0)) ;;;*** diff --git a/rudel-mode.el b/rudel-mode.el index 89c5fbf..c54c7f5 100644 --- a/rudel-mode.el +++ b/rudel-mode.el @@ -1,6 +1,6 @@ -;;; rudel-mode.el --- Global and buffer-local Rudel minor modes +;;; rudel-mode.el --- Global and buffer-local Rudel minor modes -*- lexical-binding:t -*- ;; -;; Copyright (C) 2008-2010, 2014 Free Software Foundation, Inc. +;; Copyright (C) 2008-2010, 2014, 2016 Free Software Foundation, Inc. ;; ;; Author: Jan Moringen <scym...@users.sourceforge.net> ;; Keywords: rudel, mode @@ -146,7 +146,7 @@ ;;; Header line indication of users' status and activities ;; -(defun rudel-header-subscriptions--user-change (document user) +(defun rudel-header-subscriptions--user-change (document _user) "Update header line after USER changed." ;; Update the header line to reflect the changes to USER. (rudel-header-subscriptions--update-from-document document)) @@ -154,17 +154,16 @@ (defun rudel-header-subscriptions--add-user (document user) "Start monitoring USER and update header line." ;; Monitor USER. - (lexical-let ((document1 document)) - (object-add-hook user 'change-hook - (lambda (user) - (rudel-header-subscriptions--user-change - document1 user)))) + (object-add-hook user 'change-hook + (lambda (user) + (rudel-header-subscriptions--user-change + document user))) ;; Update the header line once to get the user added. (rudel-header-subscriptions--update-from-document document) ) -(defun rudel-header-subscriptions--remove-user (document user) +(defun rudel-header-subscriptions--remove-user (document _user) "Stop monitoring USER and update header line." ;; TODO Stop monitoring USER. ;; (object-remove-hook user 'change-hook @@ -248,17 +247,17 @@ subscriptions mode; otherwise, turn it off." ;; Tracking stuff for the global mode -(defun rudel-header-subscriptions--attach (document buffer) +(defun rudel-header-subscriptions--attach (_document buffer) "Activate header subscriptions mode for BUFFER." (with-current-buffer buffer (rudel-header-subscriptions-minor-mode 1))) -(defun rudel-header-subscriptions--detach (document buffer) +(defun rudel-header-subscriptions--detach (_document buffer) "Deactivate header subscriptions mode for BUFFER." (with-current-buffer buffer (rudel-header-subscriptions-minor-mode 0))) -(defun rudel-header-subscriptions--add-document (session document) +(defun rudel-header-subscriptions--add-document (_session document) "Watch DOCUMENT for attach/detach events." ;; When document is attached to a buffer, turn the mode on. (with-slots (buffer) document @@ -271,7 +270,7 @@ subscriptions mode; otherwise, turn it off." (object-add-hook document 'detach-hook #'rudel-header-subscriptions--detach)) -(defun rudel-header-subscriptions--remove-document (session document) +(defun rudel-header-subscriptions--remove-document (_session document) "Stop watching DOCUMENT for attach/detach events." ;; When document is attached to a buffer, turn the mode off. (with-slots (buffer) document diff --git a/rudel-obby-client.el b/rudel-obby-client.el index 700863e..7903557 100644 --- a/rudel-obby-client.el +++ b/rudel-obby-client.el @@ -1,6 +1,6 @@ -;;; rudel-obby-client.el --- Client functions of the Rudel obby backend +;;; rudel-obby-client.el --- Client functions of the Rudel obby backend -*- lexical-binding:t -*- ;; -;; Copyright (C) 2008-2011, 2014 Free Software Foundation, Inc. +;; Copyright (C) 2008-2011, 2014, 2016 Free Software Foundation, Inc. ;; ;; Author: Jan Moringen <scym...@users.sourceforge.net> ;; Keywords: Rudel, obby, backend, client @@ -65,7 +65,7 @@ :method-invocation-order :c3) (defmethod rudel-obby/obby_welcome - ((this rudel-obby-client-state-new) version) + ((_this rudel-obby-client-state-new) version) "Handle obby 'welcome' message." ;; Examine announced protocol version. (with-parsed-arguments ((version number)) @@ -84,7 +84,7 @@ :method-invocation-order :c3) (defmethod rudel-obby/net6_encryption - ((this rudel-obby-client-state-encryption-negotiate) value) + ((this rudel-obby-client-state-encryption-negotiate) _value) "Handle net6 'encryption' message." (rudel-send this "net6_encryption_ok") 'encryption-start) @@ -120,7 +120,7 @@ the selected transport `%s' does not support encryption" 'waiting-for-join-info) (defmethod rudel-obby/net6_encryption_failed - ((this rudel-obby-client-state-encryption-start)) + ((_this rudel-obby-client-state-encryption-start)) "Handle net6 'encryption_failed' message." ;; The connection is now established; without encryption though. 'waiting-for-join-info) @@ -172,7 +172,7 @@ session." ) (defmethod rudel-obby/obby_sync_init - ((this rudel-obby-client-state-joining) count) + ((_this rudel-obby-client-state-joining) count) "Handle obby 'sync_init' message." ;; Switch to 'synching' state, passing the number of synchronization ;; items. @@ -180,7 +180,7 @@ session." (list 'session-synching count))) (defmethod rudel-obby/net6_login_failed - ((this rudel-obby-client-state-joining) reason) + ((_this rudel-obby-client-state-joining) reason) "Handle net6 'login_failed' message." (with-parsed-arguments ((reason number)) (with-slots (connection) this @@ -344,12 +344,11 @@ failure.")) (defmethod rudel-obby/obby_document_create ((this rudel-obby-client-state-idle) - owner-id doc-id name suffix encoding) + owner-id doc-id name suffix _encoding) "Handle obby 'document_create' message." (with-parsed-arguments ((owner-id number) (doc-id number) - (suffix number) - (encoding coding-system)) + (suffix number)) (with-slots (connection) this (with-slots (session) connection (let ((owner (rudel-find-user session owner-id @@ -384,8 +383,8 @@ failure.")) nil) (defmethod rudel-obby/obby_document/rename - ((this rudel-obby-client-state-idle) - document user new-name new-suffix) + ((_this rudel-obby-client-state-idle) + document _user new-name new-suffix) "Handle 'rename' submessage of the obby 'document' message." (with-parsed-arguments ((new-suffix number)) (with-slots ((name :object-name) suffix) document @@ -614,12 +613,11 @@ a 'self' user object.")) (defmethod rudel-obby/obby_sync_doclist_document ((this rudel-obby-client-state-session-synching) - owner-id doc-id name suffix encoding &rest subscribed-user-ids) + owner-id doc-id name suffix _encoding &rest subscribed-user-ids) "Handle obby 'sync_doclist_document' message." (with-parsed-arguments ((doc-id number) (owner-id number) - (suffix number) - (encoding coding-system)) + (suffix number)) (with-slots (connection remaining-items) this (with-slots (session) connection ;; Retrieve the subscribed users @@ -652,7 +650,7 @@ a 'self' user object.")) 'we-finalized))) (defmethod object-print ((this rudel-obby-client-state-session-synching) - &rest strings) + &rest _strings) "Append number of remaining items to string representation." (with-slots (remaining-items) this (call-next-method this (format " remaining: %d" remaining-items)))) @@ -687,7 +685,7 @@ a 'self' user object.")) nil) (defmethod rudel-obby/obby_document/sync_init - ((this rudel-obby-client-state-subscribing) document num-bytes) + ((this rudel-obby-client-state-subscribing) _document num-bytes) "Handle 'sync_init' submessage of the obby 'document' message." (with-parsed-arguments ((num-bytes number)) (with-slots (document) this @@ -752,7 +750,7 @@ a 'self' user object.")) ) (defmethod object-print ((this rudel-obby-client-state-document-synching) - &rest strings) + &rest _strings) "Append number of remaining items to string representation." (with-slots (remaining-bytes) this (call-next-method this (format " remaining: %d" remaining-bytes)))) @@ -857,7 +855,7 @@ sends and receives its data.") documents.")) "Class rudel-obby-connection ") -(defmethod initialize-instance ((this rudel-obby-connection) slots) +(defmethod initialize-instance ((this rudel-obby-connection) _slots) ;; Initialize slots of THIS (when (next-method-p) (call-next-method)) @@ -880,24 +878,23 @@ documents.")) (setq transport (rudel-obby-make-transport-filter-stack transport)) ;; Install process filter and sentinel. - (lexical-let ((this1 this)) - ;; Install `rudel-accept' as filter to dispatch messages to the - ;; current state machine state. - (rudel-set-filter transport - (lambda (data) - (rudel-accept this1 data))) - - ;; Install a sentinel that calls `rudel-close' on THIS upon - ;; receiving a 'close' event. - (rudel-set-sentinel transport - (lambda (event) - (case event - (close - (rudel-close this1))))))) - ) + + ;; Install `rudel-accept' as filter to dispatch messages to the + ;; current state machine state. + (rudel-set-filter transport + (lambda (data) + (rudel-accept this data))) + + ;; Install a sentinel that calls `rudel-close' on THIS upon + ;; receiving a 'close' event. + (rudel-set-sentinel transport + (lambda (event) + (case event + (close + (rudel-close this))))))) (defmethod rudel-register-state ((this rudel-obby-connection) - symbol state) + _symbol state) "Register SYMBOL and STATE and set connection slot of STATE." ;; Associate THIS connection to STATE. (oset state :connection this) @@ -992,7 +989,7 @@ documents.")) (with-slots (self) session (rudel-switch this 'subscribing self document))) - (lexical-let ((reporter (make-progress-reporter "Subscribing " 0.0 1.0))) + (let ((reporter (make-progress-reporter "Subscribing " 0.0 1.0))) (flet ((display-progress (state) (cond ;; Syncing document content, we can provide detailed progress. diff --git a/rudel-obby-server.el b/rudel-obby-server.el index 77e5cdd..6da3f91 100644 --- a/rudel-obby-server.el +++ b/rudel-obby-server.el @@ -1,6 +1,6 @@ -;;; rudel-obby-server.el --- Server component of the Rudel obby backend +;;; rudel-obby-server.el --- Server component of the Rudel obby backend -*- lexical-binding:t -*- ;; -;; Copyright (C) 2008-2010, 2014 Free Software Foundation, Inc. +;; Copyright (C) 2008-2010, 2014, 2016 Free Software Foundation, Inc. ;; ;; Author: Jan Moringen <scym...@users.sourceforge.net> ;; Keywords: Rudel, obby, backend, server @@ -48,8 +48,7 @@ ;;; Code: ;; -(eval-when-compile - (require 'cl)) +(require 'cl) (require 'warnings) @@ -110,7 +109,7 @@ the negotiation." 'before-join) (defmethod rudel-obby/net6_encryption_failed - ((this rudel-obby-server-state-encryption-negotiate)) + ((_this rudel-obby-server-state-encryption-negotiate)) "Handle net6 'encryption_failed' message. No action has to be taken, since the client simply proceeds after failed encryption negotiation." @@ -128,7 +127,7 @@ failed encryption negotiation." (defmethod rudel-obby/net6_client_login ((this rudel-obby-server-state-before-join) username color - &optional global-password user-password) + &optional _global-password _user-password) "Handle net6 'client_login' message." (with-parsed-arguments ((color color)) (with-slots (server @@ -502,7 +501,7 @@ connected to the server. This object handles all direct communication with the client, while broadcast messages are handled by the server.") -(defmethod initialize-instance ((this rudel-obby-client) slots) +(defmethod initialize-instance ((this rudel-obby-client) _slots) "Initialize slots of THIS, register states and install filter." ;; Initialize slots of THIS (when (next-method-p) @@ -521,23 +520,22 @@ handled by the server.") (setq transport (rudel-obby-make-transport-filter-stack transport)) ;; Install process filter and sentinel. - (lexical-let ((this1 this)) - ;; Install `rudel-accept' as filter to dispatch messages to the - ;; current state machine state. - (rudel-set-filter transport - (lambda (data) - (rudel-accept this1 data))) - - ;; Install a sentinel that calls `rudel-close' on THIS upon - ;; receiving a 'close' event. - (rudel-set-sentinel transport - (lambda (event) - (case event - (close - (rudel-close this1))))))) - ) -(defmethod rudel-register-state ((this rudel-obby-client) symbol state) + ;; Install `rudel-accept' as filter to dispatch messages to the + ;; current state machine state. + (rudel-set-filter transport + (lambda (data) + (rudel-accept this data))) + + ;; Install a sentinel that calls `rudel-close' on THIS upon + ;; receiving a 'close' event. + (rudel-set-sentinel transport + (lambda (event) + (case event + (close + (rudel-close this))))))) + +(defmethod rudel-register-state ((this rudel-obby-client) _symbol state) "Register SYMBOL and STATE and set connection slot of STATE." ;; Associate THIS connection to STATE. (oset state :connection this) @@ -667,7 +665,7 @@ that joins the associated session.") transformation context objects.")) "Class rudel-obby-server ") -(defmethod initialize-instance ((this rudel-obby-server) slots) +(defmethod initialize-instance ((this rudel-obby-server) _slots) "Initialize slots of THIS and install a dispatch function." ;; Initialize slots of THIS. (when (next-method-p) @@ -679,12 +677,10 @@ transformation context objects.")) ;; Dispatch incoming connections to our `rudel-add-client' method. (with-slots (listener) this - (lexical-let ((this1 this)) - (rudel-set-dispatcher - listener - (lambda (client-transport) - (rudel-add-client this1 client-transport))))) - ) + (rudel-set-dispatcher + listener + (lambda (client-transport) + (rudel-add-client this client-transport))))) (defmethod rudel-end ((this rudel-obby-server)) "" diff --git a/rudel-socket.el b/rudel-socket.el index 1858538..a0b884e 100644 --- a/rudel-socket.el +++ b/rudel-socket.el @@ -1,6 +1,6 @@ -;;; rudel-tcp.el --- socket transport backend for Rudel +;;; rudel-tcp.el --- socket transport backend for Rudel -*- lexical-binding:t -*- ;; -;; Copyright (C) 2009, 2010, 2014 Free Software Foundation, Inc. +;; Copyright (C) 2009, 2010, 2014, 2016 Free Software Foundation, Inc. ;; ;; Author: Jan Moringen <scym...@users.sourceforge.net> ;; Keywords: rudel, socket, transport, backend @@ -37,8 +37,7 @@ ;;; Code: ;; -(eval-when-compile - (require 'cl)) ;; for `lexical-let' and `every' +(require 'cl) ;; for `every' (require 'rudel-backend) (require 'rudel-transport) @@ -79,31 +78,29 @@ directly installed into the underlying process and therefore has to be stored separately.")) "Objects of this class use sockets to transport data.") -(defmethod initialize-instance :after ((this rudel-socket-transport) slots) +(defmethod initialize-instance :after ((this rudel-socket-transport) _slots) "Install process filter and sentinel for THIS." (with-slots (socket) this - (lexical-let ((this1 this)) - (set-process-filter - socket (lambda (process data) - (with-slots (filter) this1 - (when filter - (funcall filter data))))) - - (set-process-sentinel - socket (lambda (process message) - (with-slots (sentinel) this1 - (when sentinel - (case (process-status process) - ;; Nothing to do here. - (run - nil) - - ;; Dispatch events which indicate the - ;; termination of the connection to the - ;; sentinel. - ((closed failed exit finished) - (funcall sentinel 'close))))))))) - ) + (set-process-filter + socket (lambda (_process data) + (with-slots (filter) this + (when filter + (funcall filter data))))) + + (set-process-sentinel + socket (lambda (process _message) + (with-slots (sentinel) this + (when sentinel + (case (process-status process) + ;; Nothing to do here. + (run + nil) + + ;; Dispatch events which indicate the + ;; termination of the connection to the + ;; sentinel. + ((closed failed exit finished) + (funcall sentinel 'close))))))))) (defmethod rudel-send ((this rudel-socket-transport) data) "Send DATA through THIS." @@ -170,7 +167,7 @@ be a transport object representing the incoming connection.")) "TCP transport backend. The transport backend is a factory for TCP transport objects.") -(defmethod initialize-instance ((this rudel-tcp-backend) slots) +(defmethod initialize-instance ((this rudel-tcp-backend) _slots) "Initialize slots and set version of THIS." (when (next-method-p) (call-next-method)) @@ -183,7 +180,7 @@ The transport backend is a factory for TCP transport objects.") (defvar rudel-tcp-ask-connect-info-port-last nil "Last port read by TCP backend's `rudel-ask-connect-info'.") -(defmethod rudel-ask-connect-info ((this rudel-tcp-backend) +(defmethod rudel-ask-connect-info ((_this rudel-tcp-backend) &optional info) "Augment INFO by read a hostname and a port number." ;; Read server host and port. @@ -208,7 +205,7 @@ The transport backend is a factory for TCP transport objects.") (defmethod rudel-make-connection ((this rudel-tcp-backend) info info-callback - &optional progress-callback) + &optional _progress-callback) "Connect to a TCP server using the information in INFO. INFO has to be a property list containing the keys :host and :port." @@ -248,20 +245,19 @@ INFO has to be a property list containing the key :port." (listener (rudel-socket-listener (format "on %s:%s" (or address "*") port))) ;; Create the network process. - (socket (lexical-let ((listener1 listener)) - (apply - #'make-network-process - :name (format "TCP on %s" port) - :service port - :server t - :noquery t - :filter #'ignore - :sentinel #'ignore - :log - (lambda (server socket message) - (rudel-handle-connect listener1 socket)) - (when address - (list :host address)))))) + (socket (apply + #'make-network-process + :name (format "TCP on %s" port) + :service port + :server t + :noquery t + :filter #'ignore + :sentinel #'ignore + :log + (lambda (_server socket _message) + (rudel-handle-connect listener socket)) + (when address + (list :host address))))) ;; Return the listener. (oset listener :socket socket) listener)) diff --git a/rudel-transport-util.el b/rudel-transport-util.el index 8db91fb..1f67fe3 100644 --- a/rudel-transport-util.el +++ b/rudel-transport-util.el @@ -1,6 +1,6 @@ -;;; rudel-transport-util.el --- Utility functions for Rudel transport functionality +;;; rudel-transport-util.el --- Utility functions for Rudel transport functionality -*- lexical-binding:t -*- ;; -;; Copyright (C) 2009, 2010, 2014 Free Software Foundation, Inc. +;; Copyright (C) 2009, 2010, 2014, 2016 Free Software Foundation, Inc. ;; ;; Author: Jan Moringen <scym...@users.sourceforge.net> ;; Keywords: rudel, backend, transport, utility, miscellaneous @@ -153,37 +153,35 @@ are sent unmodified.")) complete messages by calling an assembly function.") (defmethod initialize-instance ((this rudel-assembling-transport-filter) - slots) + _slots) "Initialize THIS using SLOTS and install suitable handlers." ;; Initialize slots. (when (next-method-p) (call-next-method)) (with-slots (transport) this - (lexical-let ((this1 this)) - ;; Install a handler for received data that assembles messages - ;; and passes them to the user-provided handler. - (rudel-set-filter - transport - (lambda (data) - - ;; Assemble complete fragments from stored fragments and - ;; possibly incomplete messages in DATA. - (with-slots (buffer assembly-function) this1 - (rudel-assemble-fragments data buffer assembly-function)) - - ;; Process all complete messages. - (with-slots (filter) this1 - (when filter - (mapc filter data))))) - - ;; Install a handler for sentinel events and pass them to the - ;; user-provided handler. - (rudel-set-sentinel transport (lambda (event) - (with-slots (sentinel) this1 - (when sentinel - (funcall sentinel event))))))) - ) + ;; Install a handler for received data that assembles messages + ;; and passes them to the user-provided handler. + (rudel-set-filter + transport + (lambda (data) + + ;; Assemble complete fragments from stored fragments and + ;; possibly incomplete messages in DATA. + (with-slots (buffer assembly-function) this + (rudel-assemble-fragments data buffer assembly-function)) + + ;; Process all complete messages. + (with-slots (filter) this + (when filter + (mapc filter data))))) + + ;; Install a handler for sentinel events and pass them to the + ;; user-provided handler. + (rudel-set-sentinel transport (lambda (event) + (with-slots (sentinel) this + (when sentinel + (funcall sentinel event))))))) (defmethod rudel-send ((this rudel-assembling-transport-filter) data) "Send DATA using the transport of THIS." @@ -221,33 +219,31 @@ object to transform it into a string representation.")) string representations and structured representations by calling a pair of one parse and one generate function.") -(defmethod initialize-instance ((this rudel-parsing-transport-filter) slots) +(defmethod initialize-instance ((this rudel-parsing-transport-filter) _slots) "Initialize THIS using SLOTS and install suitable handlers." ;; Initialize slots. (when (next-method-p) (call-next-method)) (with-slots (transport) this - (lexical-let ((this1 this)) - ;; Install a handler for received data that parses messages into - ;; structured representations and passes those to the - ;; user-provided handler. - (rudel-set-filter - transport - (lambda (message-data) - ;; Parse and process all complete messages. - (with-slots (parse-function filter) this1 - (when filter - (let ((message (funcall parse-function message-data))) - (funcall filter message)))))) - - ;; Install a handler for sentinel events and pass them to the - ;; user-provided handler. - (rudel-set-sentinel transport (lambda (event) - (with-slots (sentinel) this1 - (when sentinel - (funcall sentinel event))))))) - ) + ;; Install a handler for received data that parses messages into + ;; structured representations and passes those to the + ;; user-provided handler. + (rudel-set-filter + transport + (lambda (message-data) + ;; Parse and process all complete messages. + (with-slots (parse-function filter) this + (when filter + (let ((message (funcall parse-function message-data))) + (funcall filter message)))))) + + ;; Install a handler for sentinel events and pass them to the + ;; user-provided handler. + (rudel-set-sentinel transport (lambda (event) + (with-slots (sentinel) this + (when sentinel + (funcall sentinel event))))))) (defmethod rudel-send ((this rudel-parsing-transport-filter) message) "Apply generate function to MESSAGE, pass result to transport of THIS." @@ -297,25 +293,23 @@ stopped.")) incoming and outgoing data and process it later.") (defmethod initialize-instance ((this rudel-buffering-transport-filter) - slots) + _slots) "Initialize slots of THIS and install filter in underlying transport." ;; Initialize slots. (when (next-method-p) (call-next-method)) (with-slots (transport) this - (lexical-let ((this1 this)) - ;; Install `rudel-handle' as filter in underlying transport. - (rudel-set-filter transport (lambda (data) - (rudel-handle this1 data))) - - ;; Install a handler for sentinel events and pass them to the - ;; user-provided handler. - (rudel-set-sentinel transport (lambda (event) - (with-slots (sentinel) this1 - (when sentinel - (funcall sentinel event))))))) - ) + ;; Install `rudel-handle' as filter in underlying transport. + (rudel-set-filter transport (lambda (data) + (rudel-handle this data))) + + ;; Install a handler for sentinel events and pass them to the + ;; user-provided handler. + (rudel-set-sentinel transport (lambda (event) + (with-slots (sentinel) this + (when sentinel + (funcall sentinel event))))))) (defmethod rudel-send ((this rudel-buffering-transport-filter) data) "Send DATA through THIS, queueing when necessary." @@ -403,27 +397,25 @@ sent through them until certain amounts of data are available for transmission.") (defmethod initialize-instance ((this rudel-collecting-transport-filter) - slots) + _slots) "Initialize slots of THIS and setup filter of underlying transport." ;; Initialize slots of THIS. (when (next-method-p) (call-next-method)) (with-slots (transport) this - (lexical-let ((this1 this)) - ;; Install a filter in the underlying transport. - (rudel-set-filter transport (lambda (data) - (with-slots (filter) this1 - (when filter - (funcall filter data))))) - - ;; Install a handler for sentinel events and pass them to the - ;; user-provided handler. - (rudel-set-sentinel transport (lambda (event) - (with-slots (sentinel) this1 - (when sentinel - (funcall sentinel event))))))) - ) + ;; Install a filter in the underlying transport. + (rudel-set-filter transport (lambda (data) + (with-slots (filter) this + (when filter + (funcall filter data))))) + + ;; Install a handler for sentinel events and pass them to the + ;; user-provided handler. + (rudel-set-sentinel transport (lambda (event) + (with-slots (sentinel) this + (when sentinel + (funcall sentinel event))))))) (defmethod rudel-send ((this rudel-collecting-transport-filter) data) "Send or enqueue DATA." @@ -454,13 +446,11 @@ transmission.") ;; expires. (with-slots (timer delay) this (unless timer - (lexical-let ((this1 this)) - (setq timer (run-at-time - delay nil ;; no repeat - (lambda () - (rudel-flush this1) - (oset this1 :timer nil))))))) - ) + (setq timer (run-at-time + delay nil ;; no repeat + (lambda () + (rudel-flush this) + (oset this :timer nil))))))) (defmethod rudel-maybe-cancel-timer ((this rudel-collecting-transport-filter)) @@ -489,7 +479,7 @@ multiple chunks.") "TODO") (defmethod initialize-instance - ((this rudel-progress-reporting-transport-filter) slots) + ((this rudel-progress-reporting-transport-filter) _slots) "TODO" (when (next-method-p) (call-next-method)) @@ -499,12 +489,10 @@ multiple chunks.") ;; Install a handler as filter in underlying transport. (with-slots (transport) this - (lexical-let ((this1 this)) - (rudel-set-filter transport (lambda (data) - (with-slots (filter) this1 - (when filter - (funcall filter data))))))) - ) + (rudel-set-filter transport (lambda (data) + (with-slots (filter) this + (when filter + (funcall filter data))))))) (defmethod rudel-send ((this rudel-progress-reporting-transport-filter) data) diff --git a/rudel-util.el b/rudel-util.el index 1ed30aa..30b943f 100644 --- a/rudel-util.el +++ b/rudel-util.el @@ -1,6 +1,6 @@ -;;; rudel-util.el --- Miscellaneous functions for Rudel +;;; rudel-util.el --- Miscellaneous functions for Rudel -*- lexical-binding:t -*- ;; -;; Copyright (C) 2008-2010, 2014 Free Software Foundation, Inc. +;; Copyright (C) 2008-2010, 2014, 2016 Free Software Foundation, Inc. ;; ;; Author: Jan Moringen <scym...@users.sourceforge.net> ;; Keywords: rudel, miscellaneous, util @@ -99,8 +99,7 @@ list of hooks." (defmethod object-run-hook-with-args ((this rudel-hook-object) hook &rest arguments) "Run HOOK of THIS with arguments ARGUMENTS." - (let ((hook (slot-value this hook))) - (apply #'run-hook-with-args 'hook this arguments))) + (mapc (lambda (f) (apply f this arguments)) (slot-value this hook))) ;;; Class rudel-impersonator diff --git a/rudel-xmpp-sasl.el b/rudel-xmpp-sasl.el index 2ac5d2b..2bec169 100644 --- a/rudel-xmpp-sasl.el +++ b/rudel-xmpp-sasl.el @@ -1,6 +1,6 @@ -;;; rudel-xmpp-sasl.el --- SASL mechanism for the Rudel XMPP backend +;;; rudel-xmpp-sasl.el --- SASL mechanism for the Rudel XMPP backend -*- lexical-binding:t -*- ;; -;; Copyright (C) 2009, 2010, 2014 Free Software Foundation, Inc. +;; Copyright (C) 2009, 2010, 2014, 2016 Free Software Foundation, Inc. ;; ;; Author: Jan Moringen <scym...@users.sourceforge.net> ;; Keywords: rudel, xmpp, sasl, authentication @@ -51,7 +51,7 @@ () "Start state of the SASL negotiation.") -(defmethod rudel-enter ((this rudel-xmpp-state-sasl-start) +(defmethod rudel-enter ((_this rudel-xmpp-state-sasl-start) name server features) "Extract the list of supported mechanisms from FEATURES. Then switch to the try one state to try them in order." @@ -86,7 +86,7 @@ Then switch to the try one state to try them in order." "State that selects a mechanism and switches to the mechanism start state for that mechanism.") -(defmethod rudel-enter ((this rudel-xmpp-state-sasl-try-one) +(defmethod rudel-enter ((_this rudel-xmpp-state-sasl-try-one) name server mechanisms) "If Emacs support the first mechanism in MECHANISMS, try it, otherwise skip it. Mechanism are tried by switching to the mechanism start state. @@ -247,10 +247,9 @@ mechanism.") ;; Proceed to next step and send response, possibly with ;; response data. - (let* ((sasl-read-passphrase (lexical-let ((this1 this)) - (lambda (prompt) - (rudel-obtain-sasl-password - this1 prompt)))) + (let* ((sasl-read-passphrase (lambda (prompt) + (rudel-obtain-sasl-password + this prompt))) (next (sasl-next-step client step))) (if next ;; If there is another step, send a 'response' element, @@ -304,6 +303,8 @@ password request and passes it to `rudel-obtain-password'." (sasl-mechanism-step . rudel-xmpp-state-sasl-mechanism-step)) "States used during SASL authentication.") +(defvar rudel-xmpp-states) + (eval-after-load "rudel-xmpp" '(dolist (state rudel-xmpp-sasl-states) (add-to-list 'rudel-xmpp-states state))) diff --git a/rudel-xmpp.el b/rudel-xmpp.el index 29d7822..ee980ff 100644 --- a/rudel-xmpp.el +++ b/rudel-xmpp.el @@ -1,6 +1,6 @@ -;;; rudel-xmpp.el --- XMPP transport backend for Rudel +;;; rudel-xmpp.el --- XMPP transport backend for Rudel -*- lexical-binding:t -*- ;; -;; Copyright (C) 2009, 2010, 2014 Free Software Foundation, Inc. +;; Copyright (C) 2009, 2010, 2014, 2016 Free Software Foundation, Inc. ;; ;; Author: Jan Moringen <scym...@users.sourceforge.net> ;; Keywords: rudel, xmpp, transport, backend @@ -69,14 +69,14 @@ "Transport backend works by transporting XMPP messages through XMPP connections.") -(defmethod initialize-instance ((this rudel-xmpp-backend) slots) +(defmethod initialize-instance ((this rudel-xmpp-backend) _slots) "Initialize slots and set version of THIS." (when (next-method-p) (call-next-method)) (oset this :version rudel-xmpp-transport-version)) -(defmethod rudel-ask-connect-info ((this rudel-xmpp-backend) +(defmethod rudel-ask-connect-info ((_this rudel-xmpp-backend) &optional info) "Augment INFO by reading a hostname and a port number." ;; Read server host and port. @@ -145,7 +145,7 @@ called repeatedly to report progress." () "Initial state of new XMPP connections.") -(defmethod rudel-enter ((this rudel-xmpp-state-new) to jid) +(defmethod rudel-enter ((_this rudel-xmpp-state-new) to jid) "Switch to \"negotiate-stream\" state." (list 'negotiate-stream to jid (list 'sasl-start jid to))) @@ -233,7 +233,7 @@ id=\"%s\">" () "") -(defmethod rudel-enter ((this rudel-xmpp-state-authenticated)) +(defmethod rudel-enter ((_this rudel-xmpp-state-authenticated)) "" ;; Switch to negotiate-stream telling it to switch to established in ;; case the negotiation succeeds. @@ -248,7 +248,7 @@ id=\"%s\">" () "") -(defmethod rudel-enter ((this rudel-xmpp-state-authentication-failed)) +(defmethod rudel-enter ((_this rudel-xmpp-state-authentication-failed)) "" 'we-finalize) @@ -367,7 +367,7 @@ Authentication mechanisms can add more states to this list.") the current for processing in a successor state.")) "") -(defmethod initialize-instance ((this rudel-xmpp-transport) slots) +(defmethod initialize-instance ((this rudel-xmpp-transport) _slots) "Initialize THIS and register states." ;; Initialize slots of THIS. (when (next-method-p) @@ -379,15 +379,13 @@ Authentication mechanisms can add more states to this list.") ;; Install a handler that passes received data to the user-provided ;; handler. (with-slots (transport) this - (lexical-let ((this1 this)) - (rudel-set-filter - transport - (lambda (data) - (rudel-accept this1 data))))) - ) + (rudel-set-filter + transport + (lambda (data) + (rudel-accept this data))))) (defmethod rudel-register-state ((this rudel-xmpp-transport) - symbol state) + _symbol state) "Associate THIS to STATE before registering STATE." ;; Associate THIS connection to STATE. (oset state :transport this)