changeset 2380:e67f6d2679e3

(fill-rectangle) Added. Inspired by Lynn Slater's insert-box package in LCD, but the interface and implementation are different.
author Eric S. Raymond <esr@snark.thyrsus.com>
date Sat, 27 Mar 1993 01:58:26 +0000
parents 06abd963ec25
children f8ae5fc2c196
files lisp/rect.el
diffstat 1 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/rect.el	Sat Mar 27 01:58:24 1993 +0000
+++ b/lisp/rect.el	Sat Mar 27 01:58:26 1993 +0000
@@ -192,6 +192,30 @@
     (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.