# HG changeset patch # User Eric S. Raymond # Date 733197506 0 # Node ID e67f6d2679e35e3ca85117fc48e8e05508e5a34b # Parent 06abd963ec255193fcd5599cff94e81b7813e489 (fill-rectangle) Added. Inspired by Lynn Slater's insert-box package in LCD, but the interface and implementation are different. diff -r 06abd963ec25 -r e67f6d2679e3 lisp/rect.el --- 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.