[slime-cvs] CVS slime

CVS User trittweiler trittweiler at common-lisp.net
Wed Feb 11 20:55:01 UTC 2009


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

Modified Files:
	slime.el ChangeLog 
Log Message:

	* slime.el (slime-current-tlf, slime-current-form-path): New
	functions; can be handy when inspecting source-locations while
	debugging M-.


--- /project/slime/cvsroot/slime/slime.el	2009/02/11 20:00:57	1.1121
+++ /project/slime/cvsroot/slime/slime.el	2009/02/11 20:55:01	1.1122
@@ -3059,6 +3059,47 @@
   (goto-char (point-min))
   (slime-forward-source-path source-path))
 
+;;; The following two functions can be handy when inspecting
+;;; source-location while debugging `M-.'.
+;;;
+(defun slime-current-tlf-number ()
+  "Return the current toplevel number."
+  (interactive)
+  (let ((original-pos (car (slime-region-for-defun-at-point)))
+        (n 0))
+    (save-excursion
+      ;; We use this and no repeated `beginning-of-defun's to get
+      ;; reader conditionals right.
+      (goto-char (point-min))
+      (while (progn (slime-forward-sexp)
+                    (< (point) original-pos))
+        (incf n)))
+    n))
+
+;;; This is similiar to `slime-enclosing-form-paths' in the
+;;; `slime-parse' contrib except that this does not do any duck-tape
+;;; parsing, and gets reader conditionals right.
+(defun slime-current-form-path ()
+  "Returns the path from the beginning of the current toplevel
+form to the atom at point, or nil if we're in front of a tlf."
+  (interactive)
+  (let ((source-path nil))
+    (save-excursion
+      ;; Moving forward to get reader conditionals right.
+      (loop for inner-pos = (point)
+            for outer-pos = (nth-value 1 (syntax-ppss))
+            while outer-pos do
+            (goto-char outer-pos)
+            (unless (eq (char-before) ?#) ; when at #(...) continue.
+              (forward-char)
+              (let ((n 0))
+                (while (progn (slime-forward-sexp)
+                              (< (point) inner-pos))
+                  (incf n))
+                (push n source-path)
+                (goto-char outer-pos)))))
+    source-path))
+
 (defun slime-forward-positioned-source-path (source-path)
   "Move forward through a sourcepath from a fixed position.
 The point is assumed to already be at the outermost sexp, making the
@@ -7938,10 +7979,10 @@
 (defun slime-forward-any-comment ()
   "Skip the whole comment at point, or the comment where point is
 within. This includes nested comments (#| ... |#)."
-  (while (forward-comment 1)) ; We may be exactly in front of a semicolon.
+  (forward-comment (buffer-size)) ; We may be exactly in front of a semicolon.
   (when-let (comment-start (nth 8 (slime-current-parser-state)))
     (goto-char comment-start)
-    (while (forward-comment 1))))
+    (forward-comment (buffer-size))))
 
 (defun slime-forward-reader-conditional ()
   "Move past any reader conditional (#+ or #-) at point."
--- /project/slime/cvsroot/slime/ChangeLog	2009/02/11 20:00:57	1.1677
+++ /project/slime/cvsroot/slime/ChangeLog	2009/02/11 20:55:01	1.1678
@@ -1,5 +1,11 @@
 2009-02-11  Tobias C. Rittweiler  <tcr at freebits.de>
 
+	* slime.el (slime-current-tlf, slime-current-form-path): New
+	functions; can be handy when inspecting source-locations while
+	debugging M-.
+
+2009-02-11  Tobias C. Rittweiler  <tcr at freebits.de>
+
 	* slime.el: Barf if emacs-major-version <= 20. We support 21 and up.
 	(slime-emacs-20-p): Removed.
 





More information about the slime-cvs mailing list