Index: /branches/ide-1.0/ccl/hemlock/src/line.lisp
===================================================================
--- /branches/ide-1.0/ccl/hemlock/src/line.lisp	(revision 6594)
+++ /branches/ide-1.0/ccl/hemlock/src/line.lisp	(revision 6595)
@@ -85,8 +85,7 @@
   plist
   ;;
-  ;; A slot that indicates whether this line is a buffered line, and if so
-  ;; contains information about how the text is stored.  On the RT, this is
-  ;; the length of the text pointed to by the Line-%Chars.
-  (buffered-p ()))
+  ;; The (logical) origin within a buffer or disembodied region, or NIL
+  ;; if we aren't sure.
+  origin)
 
 
@@ -129,7 +128,5 @@
 	      :previous ,previous
 	      :number ,number
-	      :%buffer ,%buffer
-	      :buffered-p
-	      (line-buffered-p ,line) ))
+	      :%buffer ,%buffer ))
 
 ;;; Hide the fact that the slot isn't really called CHARS.
@@ -142,5 +139,29 @@
   `(cond ((eq ,line *open-line*)
 	  (+ *left-open-pos* (- *line-cache-length* *right-open-pos*)))
-	 ((line-buffered-p ,line))
 	 (t
 	  (length (the simple-string (line-%chars ,line))))))
+
+
+
+(defun get-line-origin (line)
+  (or (line-origin line)
+      (do* ((prev (line-previous line) (line-previous prev))
+            (this line))
+           ((or (null prev) (line-origin this))
+            (let* ((start (or (line-origin this)
+                              (setf (line-origin this) 0))))
+              (do* ((next (line-next this) (line-next next)))
+                   ((null next) 0)
+                (incf start (1+ (line-length this)))
+                (setq this next)
+                (setf (line-origin this) start)
+                (when (eq this line) (return start)))))
+        (setq this prev))))
+
+(defun adjust-line-origins-forward (line)
+  (let* ((stoart (get-line-origin line)))
+    (do* ((next (line-next line) (line-next next)))
+         ((null next))
+      (incf start (1+ (line-length* line)))
+      (setf (line-origin next) start)
+      (setq line next))))
