Index: /branches/ide-1.0/ccl/hemlock/src/morecoms.lisp
===================================================================
--- /branches/ide-1.0/ccl/hemlock/src/morecoms.lisp	(revision 6663)
+++ /branches/ide-1.0/ccl/hemlock/src/morecoms.lisp	(revision 6664)
@@ -123,36 +123,40 @@
   With prefix argument, do it that many times."
   "Delete the P previous characters, expanding tabs into spaces."
-  (let ((point (current-point))
-        (n (or p 1)))
-    (when (minusp n)
-      (editor-error "Delete Previous Character Expanding Tabs only accepts ~
+  (let* ((buffer (current-buffer))
+         (region (hi::%buffer-current-region buffer)))
+    (if region
+      (delete-region region)
+      (let ((point (current-point))
+            (n (or p 1)))
+        (when (minusp n)
+          (editor-error "Delete Previous Character Expanding Tabs only accepts ~
                      positive arguments."))
-    ;; Pre-calculate the number of characters that need to be deleted
-    ;; and any remaining white space filling, allowing modification to
-    ;; be avoided if there are not enough characters to delete.
-    (let ((errorp nil)
-	  (del 0)
-	  (fill 0))
-      (with-mark ((mark point))
-	(dotimes (i n)
-	  (if (> fill 0)
-	      (decf fill)
-	      (let ((prev (previous-character mark)))
-		(cond ((and prev (char= prev #\tab))
-		       (let ((pos (mark-column mark)))
-			 (mark-before mark)
-			 (incf fill (- pos (mark-column mark) 1)))
-		       (incf del))
-		      ((mark-before mark)
-		       (incf del))
-		      (t
-		       (setq errorp t)
-		       (return)))))))
-      (cond ((and (not errorp) (kill-characters point (- del)))
-	     (with-mark ((mark point :left-inserting))
-	       (dotimes (i fill)
-		 (insert-character mark #\space))))
-	    (t
-	     (editor-error "There were not ~D characters before point." n))))))
+        ;; Pre-calculate the number of characters that need to be deleted
+        ;; and any remaining white space filling, allowing modification to
+        ;; be avoided if there are not enough characters to delete.
+        (let ((errorp nil)
+              (del 0)
+              (fill 0))
+          (with-mark ((mark point))
+            (dotimes (i n)
+              (if (> fill 0)
+                (decf fill)
+                (let ((prev (previous-character mark)))
+                  (cond ((and prev (char= prev #\tab))
+                         (let ((pos (mark-column mark)))
+                           (mark-before mark)
+                           (incf fill (- pos (mark-column mark) 1)))
+                         (incf del))
+                        ((mark-before mark)
+                         (incf del))
+                        (t
+                         (setq errorp t)
+                         (return)))))))
+          (cond ((and (not errorp) (kill-characters point (- del)))
+                 (with-mark ((mark point :left-inserting))
+                   (dotimes (i fill)
+                     (insert-character mark #\space))))
+                (t
+                 (editor-error "There were not ~D characters before point." n))))))))
 
 
