- "Insert STRING on each line of the rectangle with corners at point and mark
-(START and END when called from a program), shifting text right. The left edge
-of the rectangle specifies the column for insertion. This command does not
-delete or overwrite any existing text."
- (interactive "r\nsString rectangle: ")
- (apply-on-rectangle 'string-rectangle-line start end string))
-
-(defun string-rectangle-line (startcol endcol string)
- (move-to-column-force startcol)
- (insert string))
+ "Replace rectangle contents with STRING on each line.
+The length of STRING need not be the same as the rectangle width.
+
+Called from a program, takes three args; START, END and STRING."
+ (interactive
+ (progn (barf-if-buffer-read-only)
+ (list
+ (region-beginning)
+ (region-end)
+ (read-string (format "String rectangle (default `%s'): "
+ (or (car string-rectangle-history) ""))
+ nil 'string-rectangle-history
+ (car string-rectangle-history)))))
+ (apply-on-rectangle 'string-rectangle-line start end string t))
+
+;;;###autoload
+(defalias 'replace-rectangle 'string-rectangle)
+
+;;;###autoload
+(defun string-insert-rectangle (start end string)
+ "Insert STRING on each line of region-rectangle, shifting text right.
+
+When called from a program, the rectangle's corners are START and END.
+The left edge of the rectangle specifies the column for insertion.
+This command does not delete or overwrite any existing text."
+ (interactive
+ (progn (barf-if-buffer-read-only)
+ (list
+ (region-beginning)
+ (region-end)
+ (read-string (format "String insert rectangle (default `%s'): "
+ (or (car string-rectangle-history) ""))
+ nil 'string-rectangle-history
+ (car string-rectangle-history)))))
+ (apply-on-rectangle 'string-rectangle-line start end string nil))