diff options
| author | Eric S. Raymond | 1993-03-27 01:58:26 +0000 |
|---|---|---|
| committer | Eric S. Raymond | 1993-03-27 01:58:26 +0000 |
| commit | 131ca136d1e3912684c8acba26423736712f0abb (patch) | |
| tree | 47e28e47fda8672ba2a8ca2a65ebb74c87c8c5ed | |
| parent | b0912e2d9b3759d2e51ed7e23d1fe40c3325d717 (diff) | |
| download | emacs-131ca136d1e3912684c8acba26423736712f0abb.tar.gz emacs-131ca136d1e3912684c8acba26423736712f0abb.zip | |
(fill-rectangle) Added. Inspired by Lynn Slater's insert-box package in LCD,
but the interface and implementation are different.
| -rw-r--r-- | lisp/rect.el | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lisp/rect.el b/lisp/rect.el index e440904912f..7e80734a19c 100644 --- a/lisp/rect.el +++ b/lisp/rect.el | |||
| @@ -192,6 +192,30 @@ but instead winds up to the right of the rectangle." | |||
| 192 | (indent-to column))) | 192 | (indent-to column))) |
| 193 | 193 | ||
| 194 | ;;;###autoload | 194 | ;;;###autoload |
| 195 | (defun fill-rectangle (start end text) | ||
| 196 | "Fill each line of the rectangle with corners at point and mark with | ||
| 197 | text, shifting text right. The text previously in the region is not | ||
| 198 | overwritten by the blanks, but instead winds up to the right of the | ||
| 199 | rectangle. Called from a program, takes three args; START, END and | ||
| 200 | TEXT." | ||
| 201 | (interactive "r\nsText:") | ||
| 202 | (operate-on-rectangle 'fill-rectangle-line start end nil) | ||
| 203 | (goto-char start)) | ||
| 204 | |||
| 205 | (defun fill-rectangle-line (startpos begextra endextra) | ||
| 206 | (let ((column (+ (current-column) begextra endextra))) | ||
| 207 | (goto-char startpos) | ||
| 208 | (let ((ocol (current-column))) | ||
| 209 | (skip-chars-forward " \t") | ||
| 210 | (setq column (+ column (- (current-column) ocol)))) | ||
| 211 | (delete-region (point) | ||
| 212 | ;; Use skip-chars-backward's LIM argument to leave | ||
| 213 | ;; characters before STARTPOS undisturbed. | ||
| 214 | (progn (skip-chars-backward " \t" startpos) | ||
| 215 | (point))) | ||
| 216 | (insert text))) | ||
| 217 | |||
| 218 | ;;;###autoload | ||
| 195 | (defun clear-rectangle (start end) | 219 | (defun clear-rectangle (start end) |
| 196 | "Blank out rectangle with corners at point and mark. | 220 | "Blank out rectangle with corners at point and mark. |
| 197 | The text previously in the region is overwritten by the blanks. | 221 | The text previously in the region is overwritten by the blanks. |