[slime-cvs] CVS slime

CVS User heller heller at common-lisp.net
Wed Mar 9 20:09:49 UTC 2011


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

Modified Files:
	ChangeLog slime.el 
Log Message:
Move some of the logic from slime-sexp-at-point-for-macroexpansion
into slime-sexp-at-point.

* slime.el (slime-bounds-of-sexp-at-point): New.  Special case if
we are at '( as slime-sexp-at-point-for-macroexpansion does.
(slime-bounds-of-symbol-at-point): New.
(slime-symbol-at-point, slime-sexp-at-point): Use the above.

Thank God for the test suite.

--- /project/slime/cvsroot/slime/ChangeLog	2011/02/24 06:38:34	1.2182
+++ /project/slime/cvsroot/slime/ChangeLog	2011/03/09 20:09:48	1.2183
@@ -1,3 +1,13 @@
+2011-03-09  Helmut Eller  <heller at common-lisp.net>
+
+	Move some of the logic from slime-sexp-at-point-for-macroexpansion
+	into slime-sexp-at-point.
+
+	* slime.el (slime-bounds-of-sexp-at-point): New.  Special case if
+	we are at '( as slime-sexp-at-point-for-macroexpansion does.
+	(slime-bounds-of-symbol-at-point): New.
+	(slime-symbol-at-point, slime-sexp-at-point): Use the above.
+
 2011-02-24  Stas Boukarev  <stassats at gmail.com>
 
 	* swank-allegro.lisp (find-topframe): Fix excl::int-newest-frame
--- /project/slime/cvsroot/slime/slime.el	2011/02/18 20:38:41	1.1360
+++ /project/slime/cvsroot/slime/slime.el	2011/03/09 20:09:49	1.1361
@@ -8599,7 +8599,7 @@
 
 (defun slime-beginning-of-symbol ()
   "Move to the beginning of the CL-style symbol at point."
-  (while (re-search-backward "\\(\\sw\\|\\s_\\|\\s\\.\\|\\s\\\\|[#@|]\\)\\=" 
+  (while (re-search-backward "\\(\\sw\\|\\s_\\|\\s\\.\\|\\s\\\\|[#@|]\\)\\="
                              (when (> (point) 2000) (- (point) 2000))
                              t))
   (re-search-forward "\\=#[-+.<|]" nil t)
@@ -8621,19 +8621,40 @@
 (defun slime-symbol-end-pos ()
   (save-excursion (slime-end-of-symbol) (point)))
 
+(defun slime-bounds-of-symbol-at-point ()
+  "Return the bounds of the symbol around point.
+The returned bounds are either nil or non-empty."
+  (let ((bounds (bounds-of-thing-at-point 'slime-symbol)))
+    (if (and bounds
+             (< (car bounds)
+                (cdr bounds)))
+        bounds)))
+
 (defun slime-symbol-at-point ()
   "Return the name of the symbol at point, otherwise nil."
   ;; (thing-at-point 'symbol) returns "" in empty buffers
-  (let ((string (thing-at-point 'slime-symbol)))
-    (and string
-         (not (equal string "")) 
-         (substring-no-properties string))))
+  (let ((bounds (slime-bounds-of-symbol-at-point)))
+    (if bounds
+        (buffer-substring-no-properties (car bounds)
+                                        (cdr bounds)))))
+
+(defun slime-bounds-of-sexp-at-point ()
+  "Return the bounds sexp at point as a pair (or nil)."
+  (or (slime-bounds-of-symbol-at-point)
+      (and (equal (char-after) ?\()
+           (member (char-before) '(?\' ?\, ?\@))
+           ;; hide stuff before ( to avoid quirks with '( etc.
+           (save-restriction
+             (narrow-to-region (point) (point-max))
+             (bounds-of-thing-at-point 'sexp)))
+      (bounds-of-thing-at-point 'sexp)))
 
 (defun slime-sexp-at-point ()
   "Return the sexp at point as a string, otherwise nil."
-  (or (slime-symbol-at-point)
-      (let ((string (thing-at-point 'sexp)))
-        (if string (substring-no-properties string) nil))))
+  (let ((bounds (slime-bounds-of-sexp-at-point)))
+    (if bounds
+        (buffer-substring-no-properties (car bounds)
+                                        (cdr bounds)))))
 
 (defun slime-sexp-at-point-or-error ()
   "Return the sexp at point as a string, othwise signal an error."





More information about the slime-cvs mailing list