[climacs-cvs] CVS update: climacs/base-test.lisp climacs/base.lisp climacs/buffer-test.lisp

Aleksandar Bakic abakic at common-lisp.net
Sun Feb 6 00:03:30 UTC 2005


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

Modified Files:
	base-test.lisp base.lisp buffer-test.lisp 
Log Message:
Changes to (un)tabify-*region methods, and corresponding tests.

Initial tests for indent-line.

Date: Sun Feb  6 01:03:26 2005
Author: abakic

Index: climacs/base-test.lisp
diff -u climacs/base-test.lisp:1.4 climacs/base-test.lisp:1.5
--- climacs/base-test.lisp:1.4	Sat Jan 29 23:23:08 2005
+++ climacs/base-test.lisp	Sun Feb  6 01:03:26 2005
@@ -770,3 +770,107 @@
        (buffer-sequence buffer 0 (size buffer))
        (offset m))))
   "Cli Ma Cs climacs" 9)
+
+(deftest standard-buffer-tabify-buffer-region.test-1
+  (let ((buffer (make-instance 'standard-buffer)))
+    (insert-buffer-sequence buffer 0 "c       l       im              acs")
+    (climacs-base::tabify-buffer-region buffer 0 (size buffer) 8)    
+    (buffer-sequence buffer 0 (size buffer)))
+  "c	l	im		acs")
+
+(deftest standard-buffer-tabify-buffer-region.test-2
+  (let ((buffer (make-instance 'standard-buffer)))
+    (insert-buffer-sequence buffer 0 "c      l       im              acs")
+    (climacs-base::tabify-buffer-region buffer 0 (size buffer) 8)    
+    (buffer-sequence buffer 0 (size buffer)))
+  "c      l       im	       acs")
+
+(deftest standard-buffer-tabify-region.test-1
+  (let ((buffer (make-instance 'standard-buffer)))
+    (insert-buffer-sequence buffer 0 "clim    acs")
+    (let ((m1 (make-instance 'standard-left-sticky-mark
+			     :buffer buffer :offset 3))
+	  (m2 (make-instance 'standard-right-sticky-mark
+			     :buffer buffer :offset 7)))
+      (tabify-region m2 m1 4)
+      (buffer-sequence buffer 0 (size buffer))))
+  "clim	acs")
+
+(deftest standard-buffer-tabify-region.test-2
+  (let ((buffer (make-instance 'standard-buffer)))
+    (insert-buffer-sequence buffer 0 "clim    acs")
+    (let ((m1 (make-instance 'standard-right-sticky-mark
+			     :buffer buffer :offset 3)))
+      (tabify-region 7 m1 4)
+      (buffer-sequence buffer 0 (size buffer))))
+  "clim	acs")
+
+(deftest standard-buffer-tabify-region.test-3
+  (let ((buffer (make-instance 'standard-buffer)))
+    (insert-buffer-sequence buffer 0 "clim    acs")
+    (let ((m1 (make-instance 'standard-left-sticky-mark
+			     :buffer buffer :offset 7)))
+      (tabify-region 3 m1 4)
+      (buffer-sequence buffer 0 (size buffer))))
+  "clim	acs")
+
+(deftest standard-buffer-untabify-buffer-region.test-1
+  (let ((buffer (make-instance 'standard-buffer)))
+    (insert-buffer-sequence buffer 0 "c	l	im		acs")
+    (climacs-base::untabify-buffer-region buffer 0 (size buffer) 8)
+    (buffer-sequence buffer 0 (size buffer)))
+  "c       l       im              acs")
+
+(deftest standard-buffer-untabify-buffer-region.test-2
+  (let ((buffer (make-instance 'standard-buffer)))
+    (insert-buffer-sequence buffer 0 "c      l       im	       acs")
+    (climacs-base::untabify-buffer-region buffer 0 (size buffer) 8)    
+    (buffer-sequence buffer 0 (size buffer)))
+  "c      l       im              acs")
+
+(deftest standard-buffer-untabify-region.test-1
+  (let ((buffer (make-instance 'standard-buffer)))
+    (insert-buffer-sequence buffer 0 "clim	acs")
+    (let ((m1 (make-instance 'standard-left-sticky-mark
+			     :buffer buffer :offset 3))
+	  (m2 (make-instance 'standard-right-sticky-mark
+			     :buffer buffer :offset 5)))
+      (untabify-region m2 m1 4)
+      (buffer-sequence buffer 0 (size buffer))))
+  "clim    acs")
+
+(deftest standard-buffer-untabify-region.test-2
+  (let ((buffer (make-instance 'standard-buffer)))
+    (insert-buffer-sequence buffer 0 "clim	acs")
+    (let ((m1 (make-instance 'standard-right-sticky-mark
+			     :buffer buffer :offset 3)))
+      (untabify-region 5 m1 4)
+      (buffer-sequence buffer 0 (size buffer))))
+  "clim    acs")
+
+(deftest standard-buffer-untabify-region.test-3
+  (let ((buffer (make-instance 'standard-buffer)))
+    (insert-buffer-sequence buffer 0 "clim	acs")
+    (let ((m1 (make-instance 'standard-left-sticky-mark
+			     :buffer buffer :offset 5)))
+      (untabify-region 3 m1 4)
+      (buffer-sequence buffer 0 (size buffer))))
+  "clim    acs")
+
+(deftest standard-buffer-indent-line.test-1
+  (let ((buffer (make-instance 'standard-buffer)))
+    (insert-buffer-sequence buffer 0 "  	climacs   ")
+    (let ((m (make-instance 'standard-left-sticky-mark
+			    :buffer buffer :offset 0)))
+      (indent-line m 4 nil)
+      (buffer-sequence buffer 0 (size buffer))))
+  "    climacs   ")
+
+(deftest standard-buffer-indent-line.test-2
+  (let ((buffer (make-instance 'standard-buffer)))
+    (insert-buffer-sequence buffer 0 "  	climacs   ")
+    (let ((m (make-instance 'standard-right-sticky-mark
+			    :buffer buffer :offset 0)))
+      (indent-line m 5 4)
+      (buffer-sequence buffer 0 (size buffer))))
+  "	 climacs   ")


Index: climacs/base.lisp
diff -u climacs/base.lisp:1.31 climacs/base.lisp:1.32
--- climacs/base.lisp:1.31	Sat Feb  5 08:04:03 2005
+++ climacs/base.lisp	Sun Feb  6 01:03:26 2005
@@ -382,14 +382,23 @@
 
 (defmethod tabify-region ((mark1 mark) (mark2 mark) tab-width)
   (assert (eq (buffer mark1) (buffer mark2)))
-  (tabify-buffer-region (buffer mark1) (offset mark1) (offset mark2)
-                         tab-width))
-
-(defmethod tabify-region ((offset integer) (mark mark) tab-width)
-  (tabify-buffer-region (buffer mark) offset (offset mark) tab-width))
-
-(defmethod tabify-region ((mark mark) (offset integer) tab-width)
-  (tabify-buffer-region (buffer mark) (offset mark) offset tab-width))
+  (let ((offset1 (offset mark1))
+	(offset2 (offset mark2)))
+    (when (> offset1 offset2)
+      (rotatef offset1 offset2))
+    (tabify-buffer-region (buffer mark1) offset1 offset2 tab-width)))
+
+(defmethod tabify-region ((offset1 integer) (mark2 mark) tab-width)
+  (let ((offset2 (offset mark2)))
+    (when (> offset1 offset2)
+      (rotatef offset1 offset2))
+    (tabify-buffer-region (buffer mark2) offset1 offset2 tab-width)))
+
+(defmethod tabify-region ((mark1 mark) (offset2 integer) tab-width)
+  (let ((offset1 (offset mark1)))
+    (when (> offset1 offset2)
+      (rotatef offset1 offset2))
+    (tabify-buffer-region (buffer mark1) offset1 offset2 tab-width)))
 
 (defun untabify-buffer-region (buffer offset1 offset2 tab-width)
   (loop for offset = offset1 then (1+ offset)
@@ -411,14 +420,23 @@
 
 (defmethod untabify-region ((mark1 mark) (mark2 mark) tab-width)
   (assert (eq (buffer mark1) (buffer mark2)))
-  (untabify-buffer-region (buffer mark1) (offset mark1) (offset mark2)
-                          tab-width))
-
-(defmethod untabify-region ((offset integer) (mark mark) tab-width)
-  (untabify-buffer-region (buffer mark) offset (offset mark) tab-width))
-
-(defmethod untabify-region ((mark mark) (offset integer) tab-width)
-  (untabify-buffer-region (buffer mark) (offset mark) offset tab-width))
+  (let ((offset1 (offset mark1))
+	(offset2 (offset mark2)))
+    (when (> offset1 offset2)
+      (rotatef offset1 offset2))
+    (untabify-buffer-region (buffer mark1) offset1 offset2 tab-width)))
+
+(defmethod untabify-region ((offset1 integer) (mark2 mark) tab-width)
+  (let ((offset2 (offset mark2)))
+    (when (> offset1 offset2)
+      (rotatef offset1 offset2))
+    (untabify-buffer-region (buffer mark2) offset1 offset2 tab-width)))
+
+(defmethod untabify-region ((mark1 mark) (offset2 integer) tab-width)
+  (let ((offset1 (offset mark1)))
+    (when (> offset1 offset2)
+      (rotatef offset1 offset2))
+    (untabify-buffer-region (buffer mark1) offset1 offset2 tab-width)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; 


Index: climacs/buffer-test.lisp
diff -u climacs/buffer-test.lisp:1.13 climacs/buffer-test.lisp:1.14
--- climacs/buffer-test.lisp:1.13	Sat Feb  5 22:34:43 2005
+++ climacs/buffer-test.lisp	Sun Feb  6 01:03:26 2005
@@ -234,11 +234,14 @@
   (let ((buffer (make-instance 'standard-buffer)))
     (insert-buffer-sequence buffer 0 "climacs")
     (let ((m (make-instance 'standard-left-sticky-mark
-			    :buffer buffer :offset 3)))
+			    :buffer buffer :offset 3))
+	  (m2 (make-instance 'standard-left-sticky-mark
+			     :buffer buffer :offset 5)))
       (insert-sequence m "ClimacS")
       (and (= (size buffer) 14)
 	   (eq (buffer m) buffer)
 	   (= (offset m) 3)
+	   (= (offset m2) 12)
 	   (buffer-sequence buffer 0 14))))
   "cliClimacSmacs")
 
@@ -246,11 +249,14 @@
   (let ((buffer (make-instance 'standard-buffer)))
     (insert-buffer-sequence buffer 0 "climacs")
     (let ((m (make-instance 'standard-right-sticky-mark
-			    :buffer buffer :offset 3)))
+			    :buffer buffer :offset 3))
+	  (m2 (make-instance 'standard-right-sticky-mark
+			     :buffer buffer :offset 5)))
       (insert-sequence m "ClimacS")
       (and (= (size buffer) 14)
 	   (eq (buffer m) buffer)
 	   (= (offset m) 10)
+	   (= (offset m2) 12)
 	   (buffer-sequence buffer 0 14))))
   "cliClimacSmacs")
 




More information about the Climacs-cvs mailing list