summaryrefslogtreecommitdiff
path: root/lisp/rect.el
diff options
context:
space:
mode:
authorKenichi Handa <handa@m17n.org>1998-11-24 03:52:08 +0000
committerKenichi Handa <handa@m17n.org>1998-11-24 03:52:08 +0000
commite40261d0c4f0c691534866f8abd605b47e1d369d (patch)
tree45f22b40424c1ba6c1f993cfa5a905dfbcceeda1 /lisp/rect.el
parent2697c1f3504a80b7a29803a5d86a902e49705f97 (diff)
downloademacs-e40261d0c4f0c691534866f8abd605b47e1d369d.tar.gz
(move-to-column-force): New function.
(operate-on-rectangle): If coerce-tabs is non-nil, call move-to-column-force instead of move-to-column. (insert-rectangle): Call move-to-column-force instead of move-to-column. (open-rectangle-line): If begextra is not zero, call move-to-column-force.
Diffstat (limited to 'lisp/rect.el')
-rw-r--r--lisp/rect.el27
1 files changed, 24 insertions, 3 deletions
diff --git a/lisp/rect.el b/lisp/rect.el
index 4636abe1315..9ba8edf2499 100644
--- a/lisp/rect.el
+++ b/lisp/rect.el
@@ -29,6 +29,21 @@
;;; Code:
+;;;###autoload
+(defun move-to-column-force (column)
+ "Move point to column COLUMN rigidly in the current line.
+If COLUMN is within a multi-column character, replace it by
+spaces and tab."
+ (let ((col (move-to-column column t)))
+ (if (> col column)
+ (let (pos)
+ (delete-char -1)
+ (insert-char ? (- column (current-column)))
+ (setq pos (point))
+ (indent-to col)
+ (goto-char pos)))
+ column))
+
;; extract-rectangle-line stores lines into this list
;; to accumulate them for extract-rectangle and delete-extract-rectangle.
(defvar operate-on-rectangle-lines)
@@ -60,10 +75,14 @@ Point is at the end of the segment of this line within the rectangle."
(goto-char startlinepos)
(while (< (point) endlinepos)
(let (startpos begextra endextra)
- (move-to-column startcol coerce-tabs)
+ (if coerce-tabs
+ (move-to-column-force startcol)
+ (move-to-column startcol))
(setq begextra (- (current-column) startcol))
(setq startpos (point))
- (move-to-column endcol coerce-tabs)
+ (if coerce-tabs
+ (move-to-column-force endcol)
+ (move-to-column endcol))
;; If we overshot, move back one character
;; so that endextra will be positive.
(if (and (not coerce-tabs) (> (current-column) endcol))
@@ -176,7 +195,7 @@ and point is at the lower right corner."
(progn
(forward-line 1)
(or (bolp) (insert ?\n))
- (move-to-column insertcolumn t)))
+ (move-to-column-force insertcolumn)))
(setq first nil)
(insert (car lines))
(setq lines (cdr lines)))))
@@ -197,6 +216,8 @@ but instead winds up to the right of the rectangle."
(goto-char startpos)
;; Column where rectangle begins.
(let ((begcol (- (current-column) begextra)))
+ (if (> begextra 0)
+ (move-to-column-force begcol))
(skip-chars-forward " \t")
;; Width of whitespace to be deleted and recreated.
(setq whitewidth (- (current-column) begcol)))