[slime-devel] Customizing GC messages

Helmut Eller heller at common-lisp.net
Thu May 5 09:16:27 UTC 2005


Raymond Toy <rtoy at earthlink.net> writes:

> However, for a long time, I've had GC notify function that would also
> print out how much time (user and real) GC took.  What is the proper
> way of modifying slimes GC hook functions?

The simplest way is probably something like:

  (defun my-hook1 (&rest args) 
    (when swank::*emacs-connection*
      (swank::eval-in-emacs `(slime-background-message "%s"
                               ,(prin1-to-string args))
                             t)))

  (defun my-hook2 (&rest args) ...)

  (setq swank-backend::*install-gc-hooks* nil)
  (setq ext:*gc-notify-before* #'my-hook1)
  (setq ext:*gc-notify-after* #'my-hook2)

This basically disables the SLIME's default hooks and uses
my-hook{1,2} instead.  Testing whether swank::*emacs-connection* is
non-nil makes sure that we can send something to Emacs.  eval-in-emacs
sends a sexp to Emacs and evaluates it there.  Note that the symbol in
the first position of that sexp is treated specially: it is downcased
and the (CL) package prefix is stripped off, so that it makes more
sense to Emacs.  

You can, of course, use something other than slime-background-message.
Especially if you use the typeout frame it might be annoying to the
have the GC messages in that frame.

BTW, is there a way to get the size of the different GC generations in
CMUCL?

Helmut.



More information about the slime-devel mailing list