summaryrefslogtreecommitdiff
path: root/lisp/rect.el
diff options
context:
space:
mode:
authorJim Blandy <jimb@redhat.com>1992-11-16 01:40:15 +0000
committerJim Blandy <jimb@redhat.com>1992-11-16 01:40:15 +0000
commita8b90b2555c8ea4df95d7578115fd0b7360772d0 (patch)
tree043e83984a312dc27e42ddad000cf98e480207c5 /lisp/rect.el
parent4d65acd0978f86314767a917c78b22d867b6717c (diff)
downloademacs-a8b90b2555c8ea4df95d7578115fd0b7360772d0.tar.gz
* 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.
Diffstat (limited to 'lisp/rect.el')
-rw-r--r--lisp/rect.el36
1 files changed, 11 insertions, 25 deletions
diff --git a/lisp/rect.el b/lisp/rect.el
index 99e698f2810..6c2ae12817a 100644
--- a/lisp/rect.el
+++ b/lisp/rect.el
@@ -45,24 +45,16 @@ Point is at the end of the segment of this line within the rectangle."
(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 @@ and point is at the lower right corner."
(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 @@ and point is at the lower right corner."
(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 @@ but insted winds up to the right of the rectangle."
(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 @@ When called from a program, requires two args which specify the corners."
(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