[slime-devel] Feature: slime-repl-set-package

Michael Weber michaelw+slime at foldr.org
Thu Jan 22 00:28:57 UTC 2004


Hi,

I hacked up something similar to ILISP's C-z P (SET-PACKAGE-LISP).  I
am not at all sure whether this is the right way to do it, but it
seems to work.  It evolved by trial and error, though.

C-c M-p  would be a key binding candidate, I guess.  And it probably
should go into the menu as well.


As an aside: it would be extremely helpful if SLIME and SWANK
functions would be properly documented.


Cheers,
Michael
-------------- next part --------------
cvs server: Diffing .
Index: slime.el
===================================================================
RCS file: /project/slime/cvsroot/slime/slime.el,v
retrieving revision 1.195
diff -u -r1.195 slime.el
--- slime.el	21 Jan 2004 22:00:33 -0000	1.195
+++ slime.el	21 Jan 2004 23:37:23 -0000
@@ -3971,6 +3986,17 @@
     (t
      (error "Busy - can't attach in current state (%S)"
             (slime-current-state)))))
+
+(defun slime-repl-set-package (package)
+  (interactive (list (slime-read-package-name "Package: " 
+					      (slime-find-buffer-package))))
+  (with-current-buffer (slime-output-buffer)
+    (let ((unfinished-input (slime-repl-current-input)))
+      (slime-mark-output-start)
+      (slime-with-output-end-mark
+        (slime-eval `(swank:set-repl-package ,package))
+        (slime-repl-insert-prompt "")
+        (insert unfinished-input)))))
 
 (defun slime-set-package (package)
   (interactive (list (slime-read-package-name "Package: " 
Index: swank.lisp
===================================================================
RCS file: /project/slime/cvsroot/slime/swank.lisp,v
retrieving revision 1.107
diff -u -r1.107 swank.lisp
--- swank.lisp	21 Jan 2004 23:26:32 -0000	1.107
+++ swank.lisp	21 Jan 2004 23:37:26 -0000
@@ -762,6 +762,11 @@
   (setq *package* (guess-package-from-string package))
   (package-name *package*))
 
+(defslimefun set-repl-package (package)
+  (setq *package* (guess-package-from-string package))
+  (send-to-emacs 
+    `(:new-package ,(shortest-package-nickname *package*))))
+
 (defslimefun listener-eval (string)
   (clear-user-input)
   (multiple-value-bind (values last-form) (eval-region string t)


More information about the slime-devel mailing list