[slime-devel] Readtables

Terje Norderhaug terje at in-progress.com
Fri Jan 1 05:47:09 UTC 2010


On Dec 31, 2009, at 9:23 PM, Terje Norderhaug wrote:
> On Dec 31, 2009, at 7:45 AM, Seth Burleigh wrote:
>> Is there any current support for having the REPL respect reader
>> macro characters? For example, if I define the [] pair to act like
>> parentheses the repl shouldn’t automatically send a multiline [  ]
>> form to lisp until a matching ] has been found. On command line
>> REPLs, reader macro characters aren’t evaluated until a matching ]
>> has been found.
>
> One way to have the REPL respect reader macro characters is by making
> evaluation on swank return the index of the first character not read,
> with the client using this as the starting position for the next read.
>
> Below is the minor required modification of swank.

Here are the changes:

diff -u slime-2009-12-31/swank.lisp slime-2009-12-31+/swank.lisp
--- slime-2009-12-31/swank.lisp 2009-12-23 00:15:03.000000000 -0800
+++ slime-2009-12-31+/swank.lisp        2009-12-31 21:43:45.000000000  
-0800
@@ -2213,11 +2213,16 @@
  (defun eval-region (string)
    "Evaluate STRING.
  Return the results of the last form as a list and as secondary  
value the
-last form."
+last form, with third value indicating the index of the first  
character not read in STRING"
    (with-input-from-string (stream string)
      (let (- values)
        (loop
-       (let ((form (read stream nil stream)))
+       (let* ((index (file-position stream))
+              (form (handler-case
+                      (read stream nil stream)
+                      (end-of-file ()
+                       (finish-output)
+                       (return (values values - index))))))
           (when (eq form stream)
             (finish-output)
             (return (values values -)))
@@ -2293,12 +2298,13 @@
      (with-retry-restart (:msg "Retry SLIME REPL evaluation request.")
        (track-package
         (lambda ()
-         (multiple-value-bind (values last-form) (eval-region string)
+         (multiple-value-bind (values last-form index) (eval-region  
string)
             (setq *** **  ** *  * (car values)
                   /// //  // /  / values
                   +++ ++  ++ +  + last-form)
-           (funcall *send-repl-results-function* values))))))
-  nil)
+           (unless index
+             (funcall *send-repl-results-function* values))
+           index))))))


-- Terje Norderhaug
    terje at in-progress.com








More information about the slime-devel mailing list