summaryrefslogtreecommitdiff
path: root/lisp/rect.el
diff options
context:
space:
mode:
authorEric S. Raymond <esr@snark.thyrsus.com>1993-03-27 01:58:26 +0000
committerEric S. Raymond <esr@snark.thyrsus.com>1993-03-27 01:58:26 +0000
commit0c1b24b6921e4c8177d0990ea01e746291028d7a (patch)
tree7736f09c74aff926da469117dab045caace82ec0 /lisp/rect.el
parent1f5fb93ddc21e88c2dad0d87b96f5246b9f46c23 (diff)
downloademacs-0c1b24b6921e4c8177d0990ea01e746291028d7a.tar.gz
(fill-rectangle) Added. Inspired by Lynn Slater's insert-box package in LCD,
but the interface and implementation are different.
Diffstat (limited to 'lisp/rect.el')
-rw-r--r--lisp/rect.el24
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."
(indent-to column)))
;;;###autoload
+(defun fill-rectangle (start end text)
+ "Fill each line of the rectangle with corners at point and mark with
+text, shifting text right. The text previously in the region is not
+overwritten by the blanks, but instead winds up to the right of the
+rectangle. Called from a program, takes three args; START, END and
+TEXT."
+ (interactive "r\nsText:")
+ (operate-on-rectangle 'fill-rectangle-line start end nil)
+ (goto-char start))
+
+(defun fill-rectangle-line (startpos begextra endextra)
+ (let ((column (+ (current-column) begextra endextra)))
+ (goto-char startpos)
+ (let ((ocol (current-column)))
+ (skip-chars-forward " \t")
+ (setq column (+ column (- (current-column) ocol))))
+ (delete-region (point)
+ ;; Use skip-chars-backward's LIM argument to leave
+ ;; characters before STARTPOS undisturbed.
+ (progn (skip-chars-backward " \t" startpos)
+ (point)))
+ (insert text)))
+
+;;;###autoload
(defun clear-rectangle (start end)
"Blank out rectangle with corners at point and mark.
The text previously in the region is overwritten by the blanks.