changeset 1619:6147d2164331

* rect.el (operate-on-rectangle): Use move-to-column's FORCE argument instead of implementing it ourselves. (rectangle-coerce-tab): No longer used; deleted. * rect.el (open-rectangle): Leave point at the upper corner of the rectangle just opened, in imitation of open-line. Fix doc typo. (open-rectangle-line): Use skip-chars-backward's LIM argument to leave spaces before the line segment's beginning undisturbed. * rect.el: Provide 'rect.
author Jim Blandy <jimb@redhat.com>
date Mon, 16 Nov 1992 01:40:15 +0000
parents a5486162a65a
children 787f816e1f4b
files lisp/rect.el
diffstat 1 files changed, 11 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/rect.el	Mon Nov 16 01:39:23 1992 +0000
+++ b/lisp/rect.el	Mon Nov 16 01:40:15 1992 +0000
@@ -45,24 +45,16 @@
      (forward-line 1)
      (setq endlinepos (point-marker)))
     (if (< endcol startcol)
-	(let ((tem startcol))
-	  (setq startcol endcol endcol tem)))
+	(setq startcol (prog1 endcol (setq endcol startcol))))
     (if (/= endcol startcol)
 	(save-excursion
 	 (goto-char startlinepos)
 	 (while (< (point) endlinepos)
 	   (let (startpos begextra endextra)
-	     (move-to-column startcol)
-	     (and coerce-tabs
-		  (> (current-column) startcol)
-		  (rectangle-coerce-tab startcol))
+	     (move-to-column startcol coerce-tabs)
 	     (setq begextra (- (current-column) startcol))
 	     (setq startpos (point))
-	     (move-to-column endcol)
-	     (if (> (current-column) endcol)
-		 (if coerce-tabs
-		     (rectangle-coerce-tab endcol)
-		   (forward-char -1)))
+	     (move-to-column endcol coerce-tabs)
 	     (setq endextra (- endcol (current-column)))
 	     (if (< begextra 0)
 		 (setq endextra (+ endextra begextra)
@@ -167,11 +159,7 @@
 	  (progn
 	   (forward-line 1)
 	   (or (bolp) (insert ?\n))
-	   (move-to-column insertcolumn)
-	   (if (> (current-column) insertcolumn)
-	       (rectangle-coerce-tab insertcolumn))
-	   (if (< (current-column) insertcolumn)
-	       (indent-to insertcolumn))))
+	   (move-to-column insertcolumn t)))
       (setq first nil)
       (insert (car lines))
       (setq lines (cdr lines)))))
@@ -180,9 +168,10 @@
 (defun open-rectangle (start end)
   "Blank out rectangle with corners at point and mark, shifting text right.
 The text previously in the region is not overwritten by the blanks,
-but insted winds up to the right of the rectangle."
+but instead winds up to the right of the rectangle."
   (interactive "r")
-  (operate-on-rectangle 'open-rectangle-line start end nil))
+  (operate-on-rectangle 'open-rectangle-line start end nil)
+  (goto-char start))
 
 (defun open-rectangle-line (startpos begextra endextra)
   (let ((column (+ (current-column) begextra endextra)))
@@ -191,7 +180,9 @@
       (skip-chars-forward " \t")
       (setq column (+ column (- (current-column) ocol))))
     (delete-region (point)
-                   (progn (skip-chars-backward " \t")
+		   ;; Use skip-chars-backward's LIM argument to leave
+		   ;; characters before STARTPOS undisturbed.
+                   (progn (skip-chars-backward " \t" startpos)
 			  (point)))
     (indent-to column)))
 
@@ -212,11 +203,6 @@
 			  (point)))
     (indent-to column)))
 
-(defun rectangle-coerce-tab (column)
-  (let ((aftercol (current-column))
-	(indent-tabs-mode nil))
-    (delete-char -1)
-    (indent-to aftercol)
-    (backward-char (- aftercol column))))
+(provide 'rect)
 
 ;;; rect.el ends here