[slime-cvs] CVS update: slime/swank-backend.lisp
Luke Gorrie
lgorrie at common-lisp.net
Sun Jun 20 05:46:25 UTC 2004
Update of /project/slime/cvsroot/slime
In directory common-lisp.net:/tmp/cvs-serv11966
Modified Files:
swank-backend.lisp
Log Message:
(add-hook, run-hook): Added an Emacs-like hook mechiansm. The hope is
that this will make some sections of the code more self-describing by
showing where they hook in.
(*new-connection-hook*): Hook run when a new connection is
established. Initialized to '(swank-backend:emacs-connected).
(*pre-reply-hook*): Hook run before sending a reply to Emacs.
Date: Sat Jun 19 22:46:24 2004
Author: lgorrie
Index: slime/swank-backend.lisp
diff -u slime/swank-backend.lisp:1.53 slime/swank-backend.lisp:1.54
--- slime/swank-backend.lisp:1.53 Wed Jun 16 15:03:58 2004
+++ slime/swank-backend.lisp Sat Jun 19 22:46:24 2004
@@ -25,6 +25,10 @@
#:position-pos
#:print-output-to-string
#:quit-lisp
+ #:*new-connection-hook*
+ #:*pre-reply-hook*
+ #:add-hook
+ #:run-hook
))
(in-package :swank-backend)
@@ -98,7 +102,30 @@
(cons `(,(first name) (,(reader (second name)) ,tmp)))
(t (error "Malformed syntax in WITH-STRUCT: ~A" name))))
, at body)))))
-
+
+;;;; Hooks
+;;;
+;;; We use Emacs-like `add-hook' and `run-hook' utilities to support
+;;; simple indirection. The interface is more CLish than the Emacs
+;;; Lisp one.
+
+(defmacro add-hook (place function)
+ "Add FUNCTION to the list of values on HOOK-VARIABLE."
+ `(pushnew ,function ,place))
+
+(defun run-hook (functions &rest arguments)
+ "Call each of FUNCTIONS with ARGUMENTS."
+ (dolist (function functions)
+ (apply function arguments)))
+
+(defvar *new-connection-hook* '(emacs-connected)
+ "This hook is run each time a connection is established.
+The connection structure is given as the argument.")
+
+(defvar *pre-reply-hook* '()
+ "Hook run (without arguments) immediately before replying to an RPC.")
+
+
;;;; TCP server
(definterface create-socket (host port)
More information about the slime-cvs
mailing list