[mcclim-cvs] CVS mcclim/Drei

thenriksen thenriksen at common-lisp.net
Mon Feb 12 19:32:58 UTC 2007


Update of /project/mcclim/cvsroot/mcclim/Drei
In directory clnet:/tmp/cvs-serv27220

Modified Files:
	core.lisp core-commands.lisp 
Log Message:
Improved `delete-indentation', now does the intuitive thing.


--- /project/mcclim/cvsroot/mcclim/Drei/core.lisp	2007/01/14 17:57:01	1.3
+++ /project/mcclim/cvsroot/mcclim/Drei/core.lisp	2007/02/12 19:32:58	1.4
@@ -285,19 +285,19 @@
 (defmethod indent-line ((mark right-sticky-mark) indentation tab-width)
   (indent-line* mark indentation tab-width nil))
 
-(defun delete-indentation (mark)
-  (beginning-of-line mark)
-  (unless (beginning-of-buffer-p mark)
-    (delete-range mark -1)
-    (loop until (end-of-buffer-p mark)
-          while (buffer-whitespacep (object-after mark))
-          do (delete-range mark 1))
-    (loop until (beginning-of-buffer-p mark)
-          while (buffer-whitespacep (object-before mark))
-          do (delete-range mark -1))
-    (when (and (not (beginning-of-buffer-p mark))
-	       (constituentp (object-before mark)))
-      (insert-object mark #\Space))))
+(defgeneric delete-indentation (syntax mark)
+  (:documentation "Delete all indentation in the line of `mark'
+with the whitespace rules of `syntax'. The default method just
+removes leading whitespace characters."))
+
+(defmethod delete-indentation ((syntax syntax) (mark mark))
+  (let ((working-mark (clone-mark mark)))
+    (beginning-of-line working-mark)
+    (let ((end-offset (loop for offset from (offset working-mark) below (size *current-buffer*)
+                         unless (whitespacep syntax (buffer-object *current-buffer* offset))
+                         return offset)))
+      (when end-offset
+        (delete-region working-mark end-offset)))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; 
--- /project/mcclim/cvsroot/mcclim/Drei/core-commands.lisp	2006/11/14 10:31:37	1.3
+++ /project/mcclim/cvsroot/mcclim/Drei/core-commands.lisp	2007/02/12 19:32:58	1.4
@@ -257,7 +257,7 @@
 the current line, and point after that space. If there is no 
 previous non-blank line, deletes all whitespace at the 
 beginning of the buffer at leaves point there."
-  (delete-indentation *current-point*))
+  (delete-indentation *current-syntax* *current-point*))
 
 (set-key 'com-delete-indentation
 	 'indent-table




More information about the Mcclim-cvs mailing list