It can be useful to be able to run some hook in last, so let's add an option do that. --- protocol.lisp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/protocol.lisp b/protocol.lisp index 1c2ec19..cd5ddd7 100644 --- a/protocol.lisp +++ b/protocol.lisp @@ -198,7 +198,7 @@ connection.") (defgeneric read-irc-message (connection)) (defgeneric send-irc-message (connection command &rest arguments)) (defgeneric get-hooks (connection class)) -(defgeneric add-hook (connection class hook)) +(defgeneric add-hook (connection class hook &optional last)) (defgeneric remove-hook (connection class hook)) (defgeneric remove-hooks (connection class)) (defgeneric remove-all-hooks (connection)) @@ -379,10 +379,13 @@ server, via the `connection'." (gethash class (hooks connection)))
;;applies to both irc and dcc-connections -(defmethod add-hook (connection class hook) - "Add `hook' to `class'." +(defmethod add-hook (connection class hook &optional last) + "Add `hook' to `class'. +If `last' is not nil, put this hook last." (setf (gethash class (hooks connection)) - (pushnew hook (gethash class (hooks connection))))) + (if last + (append (gethash class (hooks connection)) (list hook)) + (pushnew hook (gethash class (hooks connection))))))
(defmethod remove-hook ((connection connection) class hook) "Remove `hook' from `class'."