Hi,
currently, using slime with SBCL isn't very satisfying when you're fond of the C-c C-k function: if you compile the file and it contains read errors, SLIME will think the file compiled ok and try to load it.
This fix requires a recent SBCL (as of 0.8.12.39), but it does this:
When the file-compiler aborts, it catches the error, and presents it in the *compiler notes* (or whatever it's called today) buffer; it will not try to load the resulting FASL file. The SBCL file compiler aborts as soon as it hits a reader error; so the note output is not really correct. SLIME users should then feel encouraged to fix the reader error(s) and re-try compilation.
Does that make sense? Then this patch is for you:
Index: README =================================================================== RCS file: /project/slime/cvsroot/slime/README,v retrieving revision 1.10 diff -u -r1.10 README --- README 16 Jul 2004 23:44:36 -0000 1.10 +++ README 19 Jul 2004 21:26:36 -0000 @@ -12,7 +12,7 @@
In Emacs Lisp:
- (add-to-list 'load-path "/the/path/to/this/directory") + (add-to-list 'load-path "/home/asf/dl/cvs/slime") (require 'slime) (setup-slime)
Index: swank-sbcl.lisp =================================================================== RCS file: /project/slime/cvsroot/slime/swank-sbcl.lisp,v retrieving revision 1.95 diff -u -r1.95 swank-sbcl.lisp --- swank-sbcl.lisp 13 Jul 2004 18:14:03 -0000 1.95 +++ swank-sbcl.lisp 19 Jul 2004 21:26:37 -0000 @@ -168,6 +168,11 @@ (setq *previous-compiler-condition* condition) (signal-compiler-condition condition context))))
+(defun handle-file-compiler-termination (condition) + "Handle a condition that caused the file compiler to terminate." + (handle-notification-condition + (sb-int:encapsulated-condition condition))) + (defun signal-compiler-condition (condition context) (signal (make-condition 'compiler-condition @@ -176,7 +181,8 @@ (sb-c:compiler-error :error) (sb-ext:compiler-note :note) (style-warning :style-warning) - (warning :warning)) + (warning :warning) + (error :error)) :short-message (brief-compiler-message-for-emacs condition) :references ;; FIXME: delete the reader conditionaloid after sbcl @@ -278,7 +284,8 @@
(defimplementation call-with-compilation-hooks (function) (declare (type function function)) - (handler-bind ((sb-c:compiler-error #'handle-notification-condition) + (handler-bind ((sb-c:fatal-compiler-error #'handle-file-compiler-termination) + (sb-c:compiler-error #'handle-notification-condition) (sb-ext:compiler-note #'handle-notification-condition) (style-warning #'handle-notification-condition) (warning #'handle-notification-condition)) @@ -287,13 +294,12 @@ (defvar *trap-load-time-warnings* nil)
(defimplementation swank-compile-file (filename load-p) - (flet ((loadit (fasl-file) (when (and load-p fasl-file) (load fasl-file)))) - (cond (*trap-load-time-warnings* - (with-compilation-hooks () - (loadit (compile-file filename)))) - (t - (loadit (with-compilation-hooks () - (compile-file filename))))))) + (handler-case + (let ((output-file (with-compilation-hooks () + (compile-file filename)))) + (when (and load-p output-file) + (load output-file))) + (sb-c:fatal-compiler-error () nil)))
(defimplementation swank-compile-string (string &key buffer position) (let ((form (read-from-string (format nil "(~S () ~A)" 'lambda string))))
Have fun,