diff options
| author | Kenichi Handa | 1998-11-24 03:52:08 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-11-24 03:52:08 +0000 |
| commit | e40261d0c4f0c691534866f8abd605b47e1d369d (patch) | |
| tree | 45f22b40424c1ba6c1f993cfa5a905dfbcceeda1 | |
| parent | 2697c1f3504a80b7a29803a5d86a902e49705f97 (diff) | |
| download | emacs-e40261d0c4f0c691534866f8abd605b47e1d369d.tar.gz emacs-e40261d0c4f0c691534866f8abd605b47e1d369d.zip | |
(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.
| -rw-r--r-- | lisp/rect.el | 27 |
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 @@ | |||
| 29 | 29 | ||
| 30 | ;;; Code: | 30 | ;;; Code: |
| 31 | 31 | ||
| 32 | ;;;###autoload | ||
| 33 | (defun move-to-column-force (column) | ||
| 34 | "Move point to column COLUMN rigidly in the current line. | ||
| 35 | If COLUMN is within a multi-column character, replace it by | ||
| 36 | spaces and tab." | ||
| 37 | (let ((col (move-to-column column t))) | ||
| 38 | (if (> col column) | ||
| 39 | (let (pos) | ||
| 40 | (delete-char -1) | ||
| 41 | (insert-char ? (- column (current-column))) | ||
| 42 | (setq pos (point)) | ||
| 43 | (indent-to col) | ||
| 44 | (goto-char pos))) | ||
| 45 | column)) | ||
| 46 | |||
| 32 | ;; extract-rectangle-line stores lines into this list | 47 | ;; extract-rectangle-line stores lines into this list |
| 33 | ;; to accumulate them for extract-rectangle and delete-extract-rectangle. | 48 | ;; to accumulate them for extract-rectangle and delete-extract-rectangle. |
| 34 | (defvar operate-on-rectangle-lines) | 49 | (defvar operate-on-rectangle-lines) |
| @@ -60,10 +75,14 @@ Point is at the end of the segment of this line within the rectangle." | |||
| 60 | (goto-char startlinepos) | 75 | (goto-char startlinepos) |
| 61 | (while (< (point) endlinepos) | 76 | (while (< (point) endlinepos) |
| 62 | (let (startpos begextra endextra) | 77 | (let (startpos begextra endextra) |
| 63 | (move-to-column startcol coerce-tabs) | 78 | (if coerce-tabs |
| 79 | (move-to-column-force startcol) | ||
| 80 | (move-to-column startcol)) | ||
| 64 | (setq begextra (- (current-column) startcol)) | 81 | (setq begextra (- (current-column) startcol)) |
| 65 | (setq startpos (point)) | 82 | (setq startpos (point)) |
| 66 | (move-to-column endcol coerce-tabs) | 83 | (if coerce-tabs |
| 84 | (move-to-column-force endcol) | ||
| 85 | (move-to-column endcol)) | ||
| 67 | ;; If we overshot, move back one character | 86 | ;; If we overshot, move back one character |
| 68 | ;; so that endextra will be positive. | 87 | ;; so that endextra will be positive. |
| 69 | (if (and (not coerce-tabs) (> (current-column) endcol)) | 88 | (if (and (not coerce-tabs) (> (current-column) endcol)) |
| @@ -176,7 +195,7 @@ and point is at the lower right corner." | |||
| 176 | (progn | 195 | (progn |
| 177 | (forward-line 1) | 196 | (forward-line 1) |
| 178 | (or (bolp) (insert ?\n)) | 197 | (or (bolp) (insert ?\n)) |
| 179 | (move-to-column insertcolumn t))) | 198 | (move-to-column-force insertcolumn))) |
| 180 | (setq first nil) | 199 | (setq first nil) |
| 181 | (insert (car lines)) | 200 | (insert (car lines)) |
| 182 | (setq lines (cdr lines))))) | 201 | (setq lines (cdr lines))))) |
| @@ -197,6 +216,8 @@ but instead winds up to the right of the rectangle." | |||
| 197 | (goto-char startpos) | 216 | (goto-char startpos) |
| 198 | ;; Column where rectangle begins. | 217 | ;; Column where rectangle begins. |
| 199 | (let ((begcol (- (current-column) begextra))) | 218 | (let ((begcol (- (current-column) begextra))) |
| 219 | (if (> begextra 0) | ||
| 220 | (move-to-column-force begcol)) | ||
| 200 | (skip-chars-forward " \t") | 221 | (skip-chars-forward " \t") |
| 201 | ;; Width of whitespace to be deleted and recreated. | 222 | ;; Width of whitespace to be deleted and recreated. |
| 202 | (setq whitewidth (- (current-column) begcol))) | 223 | (setq whitewidth (- (current-column) begcol))) |