[slime-cvs] CVS slime

CVS User crhodes crhodes at common-lisp.net
Fri Oct 8 09:03:25 UTC 2010


Update of /project/slime/cvsroot/slime
In directory cl-net:/tmp/cvs-serv19842

Modified Files:
	ChangeLog slime.el swank-backend.lisp swank.lisp 
Log Message:
add richer location information to the position arg in compile-string-for-emacs

R's source location recording infrastructure works with line/column offsets
rather than with character offsets, so to get the right srcrefs associated
with some string source we need to communicate line and column information
from the source buffer.  Unfortunately, only the emacs side can do that -- in
principle, the R side has no direct access to the source file at all.  This
means a protocol change, converting the position argument in
swank:compile-string-for-emacs to a list of <position>s in the slime
source location grammar.  At present, pass in both :position and :line
kinds, and have swank:compile-string-for-emacs extract just the :position for
passing on to swank-compile-string.


--- /project/slime/cvsroot/slime/ChangeLog	2010/10/07 17:15:07	1.2148
+++ /project/slime/cvsroot/slime/ChangeLog	2010/10/08 09:03:24	1.2149
@@ -1,3 +1,19 @@
+2010-10-08  Christophe Rhodes  <csr21 at cantab.net>
+
+	Pass more detailed source location information to
+	swank:compile-string-for-emacs.  Motivated by R's source location
+	needs (where srcrefs are line/column based).
+
+	* slime.el (slime-compile-string): Generate :line location format
+	from start-offset, passing it through to
+	swank:compile-file-for-emacs.
+	(find-definition.2): Use new-style position.
+
+	* swank.lisp (compile-string-for-emacs): Use only the offset from
+	the position argument.
+
+	* swank-backend.lisp (swank-compile-string): Fix docstring typo.
+
 2010-10-07  Nikodemus Siivola  <nikodemus at random-state.net>
 
 	Hanging on to a *log-output* from a previous image is bad on SBCL
--- /project/slime/cvsroot/slime/slime.el	2010/10/02 11:16:54	1.1343
+++ /project/slime/cvsroot/slime/slime.el	2010/10/08 09:03:24	1.1344
@@ -2639,14 +2639,18 @@
     (run-with-timer (or timeout 0.2) nil 'delete-overlay overlay)))
 
 (defun slime-compile-string (string start-offset)
-  (slime-eval-async 
-   `(swank:compile-string-for-emacs
-     ,string
-     ,(buffer-name)
-     ,start-offset
-     ,(if (buffer-file-name) (slime-to-lisp-filename (buffer-file-name)))
-     ',slime-compilation-policy)
-   #'slime-compilation-finished))
+  (let* ((line (save-excursion
+                 (goto-char start-offset)
+                 (list (line-number-at-pos) (1+ (current-column)))))
+         (position `((:position ,start-offset) (:line , at line))))
+    (slime-eval-async 
+      `(swank:compile-string-for-emacs
+        ,string
+        ,(buffer-name)
+        ',position
+        ,(if (buffer-file-name) (slime-to-lisp-filename (buffer-file-name)))
+        ',slime-compilation-policy)
+      #'slime-compilation-finished)))
 
 (defun slime-compilation-finished (result)
   (with-struct (slime-compilation-result. notes duration successp
@@ -7727,7 +7731,7 @@
        `(swank:compile-string-for-emacs
          ,buffer-content
          ,(buffer-name)
-         ,0
+         '((:position 0) (:line 1 1))
          ,nil
          ,nil))
       (let ((bufname (buffer-name)))
--- /project/slime/cvsroot/slime/swank-backend.lisp	2010/09/18 09:34:05	1.201
+++ /project/slime/cvsroot/slime/swank-backend.lisp	2010/10/08 09:03:24	1.202
@@ -434,7 +434,7 @@
 implementations to compile with optimization qualities of its
 value.
 
-Should return T on successfull compilation, NIL otherwise.
+Should return T on successful compilation, NIL otherwise.
 ")
 
 (definterface swank-compile-file (input-file output-file load-p 
--- /project/slime/cvsroot/slime/swank.lisp	2010/10/02 11:16:54	1.730
+++ /project/slime/cvsroot/slime/swank.lisp	2010/10/08 09:03:24	1.731
@@ -2853,15 +2853,16 @@
 (defslimefun compile-string-for-emacs (string buffer position filename policy)
   "Compile STRING (exerpted from BUFFER at POSITION).
 Record compiler notes signalled as `compiler-condition's."
-  (with-buffer-syntax ()
-    (collect-notes
-     (lambda () 
-       (let ((*compile-print* t) (*compile-verbose* nil))
-         (swank-compile-string string
-                               :buffer buffer
-                               :position position 
-                               :filename filename
-                               :policy policy))))))
+  (let ((offset (cadr (assoc :position position))))
+    (with-buffer-syntax ()
+      (collect-notes
+       (lambda () 
+         (let ((*compile-print* t) (*compile-verbose* nil))
+           (swank-compile-string string
+                                 :buffer buffer
+                                 :position offset 
+                                 :filename filename
+                                 :policy policy)))))))
 
 (defslimefun compile-multiple-strings-for-emacs (strings policy)
   "Compile STRINGS (exerpted from BUFFER at POSITION).





More information about the slime-cvs mailing list