[slime-cvs] CVS update: slime/swank.lisp
Luke Gorrie
lgorrie at common-lisp.net
Sat Nov 1 22:56:06 UTC 2003
Update of /project/slime/cvsroot/slime
In directory common-lisp.net:/tmp/cvs-serv873
Modified Files:
swank.lisp
Log Message:
(*slime-features*): Variable remembering the FEATURES list.
(sync-state-to-emacs): Update Emacs about any state changes -
currently this just means changes to the FEATURES list.
(eval-string): Call `sync-state-to-emacs' before sending result.
(eval-region): With optional PACKAGE-UPDATE-P, if the evaluation
changes the current package, tell Emacs about the new package.
(listener-eval): Tell `eval-region' to notify Emacs of package
changes, so that e.g. (in-package :swank) does the right thing when
evaluated in the REPL.
Date: Sat Nov 1 17:56:06 2003
Author: lgorrie
Index: slime/swank.lisp
diff -u slime/swank.lisp:1.49 slime/swank.lisp:1.50
--- slime/swank.lisp:1.49 Sat Nov 1 10:45:10 2003
+++ slime/swank.lisp Sat Nov 1 17:56:06 2003
@@ -114,6 +114,15 @@
(let ((*package* *swank-io-package*))
(read-from-string string))))
+(defvar *slime-features* nil
+ "The feature list that has been sent to Emacs.")
+
+(defun sync-state-to-emacs ()
+ "Update Emacs if any relevant Lisp state has changed."
+ (unless (eq *slime-features* *features*)
+ (setq *slime-features* *features*)
+ (send-to-emacs (list :new-features (mapcar #'symbol-name *features*)))))
+
(defun send-to-emacs (object)
"Send `object' to Emacs."
(let* ((string (prin1-to-string-for-emacs object))
@@ -191,6 +200,7 @@
(setq result (eval (read-form string)))
(force-output)
(setq ok t))
+ (sync-state-to-emacs)
(send-to-emacs (if ok `(:ok ,result) '(:aborted)))))))
(defslimefun interactive-eval (string)
@@ -200,14 +210,21 @@
(force-output)
(format nil "~{~S~^, ~}" values)))
-(defun eval-region (string)
- (with-input-from-string (stream string)
- (loop for form = (read stream nil stream)
- until (eq form stream)
- for - = form
- for values = (multiple-value-list (eval form))
- do (force-output)
- finally (return (values values -)))))
+(defun eval-region (string &optional package-update-p)
+ "Evaluate STRING and return the result.
+If PACKAGE-UPDATE-P is non-nil, and evaluation causes a package
+change, then send Emacs an update."
+ (let ((*package* *buffer-package*))
+ (unwind-protect
+ (with-input-from-string (stream string)
+ (loop for form = (read stream nil stream)
+ until (eq form stream)
+ for - = form
+ for values = (multiple-value-list (eval form))
+ do (force-output)
+ finally (return (values values -))))
+ (when (and package-update-p (not (eq *package* *buffer-package*)))
+ (send-to-emacs (list :new-package (package-name *package*)))))))
(defslimefun interactive-eval-region (string)
(let ((*package* *buffer-package*))
@@ -237,7 +254,7 @@
(package-name *package*))
(defslimefun listener-eval (string)
- (multiple-value-bind (values last-form) (eval-region string)
+ (multiple-value-bind (values last-form) (eval-region string t)
(setq +++ ++ ++ + + last-form
*** ** ** * * (car values)
/// // // / / values)
More information about the slime-cvs
mailing list