[climacs-cvs] CVS update: climacs/Persistent/binseq2.lisp climacs/Persistent/persistent-buffer.lisp

Aleksandar Bakic abakic at common-lisp.net
Tue Mar 15 18:41:24 UTC 2005


Update of /project/climacs/cvsroot/climacs/Persistent
In directory common-lisp.net:/tmp/cvs-serv19196/Persistent

Modified Files:
	binseq2.lisp persistent-buffer.lisp 
Log Message:
And end-of-line bug fix and related cleanup.

Date: Tue Mar 15 19:41:19 2005
Author: abakic

Index: climacs/Persistent/binseq2.lisp
diff -u climacs/Persistent/binseq2.lisp:1.1 climacs/Persistent/binseq2.lisp:1.2
--- climacs/Persistent/binseq2.lisp:1.1	Sun Mar 13 21:51:53 2005
+++ climacs/Persistent/binseq2.lisp	Tue Mar 15 19:41:19 2005
@@ -65,7 +65,7 @@
       for e in l
       do
 	(push e curr)
-	(when (eq e #\Newline)
+	(when (eql e #\Newline)
 	  (push (list-obinseq (nreverse curr)) ll)
 	  (setf curr nil))
       finally
@@ -136,7 +136,7 @@
   "If the last line of A does not end with a newline, remove the first
 line of B and append it to the last line of A; otherwise, do nothing."
   (let ((a-last-line (cdr (binseq2-back a 1))))
-    (if (eq (obinseq-back a-last-line 1) #\Newline)
+    (if (eql (obinseq-back a-last-line 1) #\Newline)
 	(values a b)
 	(values
 	 (binseq2-set a (1- (binseq2-length a))
@@ -227,11 +227,11 @@
 (defun binseq2-offset (s i)
   (labels ((%offset (s i o)
 	     (cond
-	       ((or (<= i 0) (eq s 'empty) (eq (car s) 'leaf)) o)
-	       ((<= i (binseq2-length (caddr s))) (%offset (caddr s) i o))
+	       ((or (eq s 'empty) (<= i 0) (eq (car s) 'leaf)) o)
+	       ((< i (binseq2-length (caddr s))) (%offset (caddr s) i o))
 	       (t (%offset (cdddr s) (- i (binseq2-length (caddr s)))
 			   (+ o (binseq2-size (caddr s))))))))
-    (%offset s (1+ i) 0)))
+    (%offset s i 0)))
 
 (defun binseq2-front2 (s i)
   (cond
@@ -246,11 +246,11 @@
 (defun binseq2-line2 (s i)
   (labels ((%line (s i o)
 	     (cond
-	       ((or (<= i 0) (eq s 'empty) (eq (car s) 'leaf)) o)
-	       ((<= i (binseq2-size (caddr s))) (%line (caddr s) i o))
+	       ((or (eq s 'empty) (<= i 0) (eq (car s) 'leaf)) o)
+	       ((< i (binseq2-size (caddr s))) (%line (caddr s) i o))
 	       (t (%line (cdddr s) (- i (binseq2-size (caddr s)))
 			 (+ o (binseq2-length (caddr s))))))))
-    (%line s (1+ i) 0)))
+    (%line s i 0)))
 
 (defun binseq2-back (s i)
   (cond


Index: climacs/Persistent/persistent-buffer.lisp
diff -u climacs/Persistent/persistent-buffer.lisp:1.10 climacs/Persistent/persistent-buffer.lisp:1.11
--- climacs/Persistent/persistent-buffer.lisp:1.10	Sun Mar 13 21:51:53 2005
+++ climacs/Persistent/persistent-buffer.lisp	Tue Mar 15 19:41:19 2005
@@ -373,14 +373,18 @@
     (setf (offset mark) offset)))
 
 (defmethod end-of-line ((mark p-line-mark-mixin))
-  (let* ((curr-offset (offset mark))
-	 (contents (slot-value (buffer mark) 'contents))
-	 (next-line-offset (binseq2-offset
-			    contents
-			    (1+ (binseq2-line2 contents curr-offset)))))
-    (if (> next-line-offset curr-offset)
-	(setf (offset mark) (1- next-line-offset))
-	(setf (offset mark) (size (buffer mark))))))
+  (let* ((offset (offset mark))
+	 (buffer (buffer mark))
+	 (size (size buffer))
+	 (contents (slot-value buffer 'contents))
+	 (next-line-offset
+	  (binseq2-offset contents (1+ (binseq2-line2 contents offset)))))
+    (setf (offset mark)
+	  (cond
+	    ((> next-line-offset offset) (1- next-line-offset))
+	    ((and (> size 0) (eql (binseq2-get2 contents (1- size)) #\Newline))
+	     (1- size))
+	    (t size)))))
 
 (defmethod buffer-line-number ((buffer persistent-buffer) (offset integer))
   (loop for i from 0 below offset




More information about the Climacs-cvs mailing list