[climacs-cvs] CVS climacs

thenriksen thenriksen at common-lisp.net
Wed Apr 12 19:37:23 UTC 2006


Update of /project/climacs/cvsroot/climacs
In directory clnet:/tmp/cvs-serv3490

Modified Files:
	lisp-syntax.lisp 
Log Message:
Added `first-form', `rest-forms' functions that work as expected,
changed `package-of' to use them. Also removed call to Clouseau
(oops).


--- /project/climacs/cvsroot/climacs/lisp-syntax.lisp	2006/04/12 18:52:00	1.48
+++ /project/climacs/cvsroot/climacs/lisp-syntax.lisp	2006/04/12 19:37:23	1.49
@@ -1080,17 +1080,14 @@
   (let ((buffer (buffer syntax)))
     (flet ((test (x)
 	     (when (typep x 'complete-list-form)
-	       (let ((candidate (second-noncomment (children x))))
+	       (let ((candidate (first-form (children x))))
 		 (and (typep candidate 'token-mixin)
-		      (eq (parse-symbol (coerce (buffer-sequence (buffer syntax)
-								 (start-offset candidate)
-								 (end-offset candidate))
-						'string))
+		      (eq (token-to-symbol syntax candidate)
 			  'cl:in-package))))))
       (with-slots (stack-top) syntax
 	(let ((form (find-if #'test (children stack-top))))
 	  (when form
-	    (let ((package-form (third-noncomment (children form))))
+	    (let ((package-form (second-form (children form))))
 	      (when package-form 
 		(let ((package-name
 		       (typecase package-form
@@ -1183,6 +1180,39 @@
   "Returns the third non-comment in list."
   (nth-noncomment 2 list))
 
+(defun rest-forms (list)
+  "Returns the remainder of the list after the first form,
+stripping leading non-forms."
+  (loop for rest on list
+     count (typep (car rest) 'form)
+       into forms
+     until (= forms 2)
+     finally (return rest)))
+
+(defun nth-form (n list)
+  "Returns the nth form in list."
+  (loop for item in list
+     count (typep item 'form)
+       into forms
+     until (> forms n)
+     finally (return item)))
+
+(defun elt-form (list n)
+  "Returns the nth form in list."
+  (nth-form n list))
+
+(defun first-form (list)
+  "Returns the first form in list."
+  (nth-form 0 list))
+
+(defun second-form (list)
+  "Returns the second form in list."
+  (nth-form 1 list))
+
+(defun third-form (list)
+  "Returns the third formw in list."
+  (nth-form 2 list))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;
 ;;; display
@@ -2165,7 +2195,6 @@
   (beginning-of-line mark)
   (with-slots (stack-top) syntax
     (let ((path (compute-path syntax (offset mark))))
-      (clouseau:inspector path)
       (multiple-value-bind (tree offset)
 	  (indent-form syntax stack-top path)
 	(setf (offset mark) (start-offset tree))




More information about the Climacs-cvs mailing list