[slime-cvs] CVS slime
CVS User trittweiler
trittweiler at common-lisp.net
Sat May 9 19:26:00 UTC 2009
Update of /project/slime/cvsroot/slime
In directory cl-net:/tmp/cvs-serv30975
Modified Files:
swank-source-file-cache.lisp swank-sbcl.lisp ChangeLog
Log Message:
* swank-source-file-cache.lisp (read-snippet-from-string): New.
* swank-sbcl.lisp (source-hint-snippet): Use it.
(emacs-buffer-source-location): Use it, too.
(string-path-snippet): Ditto. Additionally: Make sure the returned
string is truncated by *SOURCE-SNIPPET-SIZE*.
--- /project/slime/cvsroot/slime/swank-source-file-cache.lisp 2008/04/24 01:24:14 1.9
+++ /project/slime/cvsroot/slime/swank-source-file-cache.lisp 2009/05/09 19:26:00 1.10
@@ -98,9 +98,13 @@
If POSITION is given, set the STREAM's file position first."
(when position
(file-position stream position))
- #+SBCL (skip-comments-and-whitespace stream)
+ #+sbcl (skip-comments-and-whitespace stream)
(read-upto-n-chars stream *source-snippet-size*))
+(defun read-snippet-from-string (string &optional position)
+ (with-input-from-string (s string)
+ (read-snippet s position)))
+
(defun skip-comments-and-whitespace (stream)
(case (peek-char nil stream)
((#\Space #\Tab #\Newline #\Linefeed #\Page)
--- /project/slime/cvsroot/slime/swank-sbcl.lisp 2009/04/29 22:29:18 1.240
+++ /project/slime/cvsroot/slime/swank-sbcl.lisp 2009/05/09 19:26:00 1.241
@@ -697,7 +697,8 @@
`(:snippet ,snippet))))))))
(defun string-path-snippet (string form-path position)
- (if form-path
+ (if (null form-path)
+ (read-snippet-from-string string)
;; If we have a form-path, use it to derive a more accurate
;; snippet, so that we can point to the individual form rather
;; than just the toplevel form.
@@ -705,8 +706,7 @@
(let ((*read-suppress* t))
(read-from-string string nil nil :start position))
(declare (ignore data))
- (subseq string position end))
- string))
+ (subseq string position (min end *source-snippet-size*)))))
(defun source-file-position (filename write-date form-path character-offset)
(let ((source (get-source-code filename write-date))
@@ -717,9 +717,7 @@
(or character-offset 0)))))
(defun source-hint-snippet (filename write-date position)
- (let ((source (get-source-code filename write-date)))
- (with-input-from-string (s source)
- (read-snippet s position))))
+ (read-snippet-from-string (get-source-code filename write-date) position))
(defun function-source-location (function &optional name)
(declare (type function function))
@@ -1003,8 +1001,7 @@
&allow-other-keys)
plist
(let* ((pos (string-source-position code-location emacs-string))
- (snipped (with-input-from-string (s emacs-string)
- (read-snippet s pos))))
+ (snipped (read-snippet-from-string emacs-string pos)))
(make-location `(:buffer ,emacs-buffer)
`(:offset ,emacs-position ,pos)
`(:snippet ,snipped))))
--- /project/slime/cvsroot/slime/ChangeLog 2009/05/08 18:11:14 1.1738
+++ /project/slime/cvsroot/slime/ChangeLog 2009/05/09 19:26:00 1.1739
@@ -1,3 +1,12 @@
+2009-05-09 Tobias C. Rittweiler <tcr at freebits.de>
+
+ * swank-source-file-cache.lisp (read-snippet-from-string): New.
+
+ * swank-sbcl.lisp (source-hint-snippet): Use it.
+ (emacs-buffer-source-location): Use it, too.
+ (string-path-snippet): Ditto. Additionally: Make sure the returned
+ string is truncated by *SOURCE-SNIPPET-SIZE*.
+
2009-05-08 Tobias C. Rittweiler <tcr at freebits.de>
* slime.el (slime-search-suppressed-forms-internal): Not properly
More information about the slime-cvs
mailing list