[cl-irc-devel] [PATCH] Add `append-hook'
Julien Danjou
julien at danjou.info
Tue Dec 25 20:57:12 UTC 2012
It can be useful to be able to run some hook in last, so let's add a
function to do that.
---
package.lisp | 1 +
protocol.lisp | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/package.lisp b/package.lisp
index 311fa3e..c09537a 100644
--- a/package.lisp
+++ b/package.lisp
@@ -48,6 +48,7 @@
:client-stream
:channels
:add-hook
+ :append-hook
:remove-hook
:remove-hooks
:remove-all-hooks
diff --git a/protocol.lisp b/protocol.lisp
index 1c2ec19..7d89530 100644
--- a/protocol.lisp
+++ b/protocol.lisp
@@ -199,6 +199,7 @@ connection.")
(defgeneric send-irc-message (connection command &rest arguments))
(defgeneric get-hooks (connection class))
(defgeneric add-hook (connection class hook))
+(defgeneric append-hook (connection class hook))
(defgeneric remove-hook (connection class hook))
(defgeneric remove-hooks (connection class))
(defgeneric remove-all-hooks (connection))
@@ -384,6 +385,11 @@ server, via the `connection'."
(setf (gethash class (hooks connection))
(pushnew hook (gethash class (hooks connection)))))
+(defmethod append-hook (connection class hook)
+ "Append `hook' to `class'."
+ (setf (gethash class (hooks connection))
+ (append (gethash class (hooks connection)) (list hook))))
+
(defmethod remove-hook ((connection connection) class hook)
"Remove `hook' from `class'."
(setf (gethash class (hooks connection))
--
1.8.1.rc0
More information about the cl-irc-devel
mailing list