-This command does not delete or overwrite any existing text.
-
-Called from a program, takes three args; START, END and STRING."
- (interactive "r\nsString rectangle: ")
- (operate-on-rectangle 'string-rectangle-line start end t string)) ; XEmacs
-
-;; XEmacs: add string arg
-(defun string-rectangle-line (startpos begextra endextra string)
- (let (whitespace)
- (goto-char startpos)
- ;; Compute horizontal width of following whitespace.
- (let ((ocol (current-column)))
- (skip-chars-forward " \t")
- (setq whitespace (- (current-column) ocol)))
- ;; Delete the following whitespace.
- (delete-region startpos (point))
- ;; Insert the desired string.
- (insert string)
- ;; Insert the same width of whitespace that we had before.
- (indent-to (+ (current-column) whitespace))))
+
+If `pending-delete-mode' is active the string replace the region.
+Otherwise this command does not delete or overwrite any existing text.
+
+When called from a program, the rectangle's corners are START and END."
+ (interactive "*r\nsString rectangle: ")
+ (defvar pending-delete-mode)
+ (apply-on-rectangle 'string-rectangle-line start end string
+ (and (boundp 'pending-delete-mode) pending-delete-mode)))
+
+(defun replace-rectangle (start end string)
+ "Like `string-rectangle', but unconditionally replace the original region,
+as if `pending-delete-mode' were active."
+ (interactive "*r\nsString rectangle: ")
+ (apply-on-rectangle 'string-rectangle-line start end string t))
+
+
+(defun clear-rectangle-line (startcol endcol fill)
+ (let ((pt (point-at-eol))
+ spaces)
+ (when (= (move-to-column startcol (or fill 'coerce)) startcol)
+ (if (and (not fill)
+ (<= (save-excursion (goto-char pt) (current-column)) endcol))
+ (delete-region (point) pt)
+ ;; else
+ (setq pt (point))
+ (move-to-column endcol t)
+ (setq spaces (- (point) pt))
+ (delete-region pt (point))
+ (indent-to (+ (current-column) spaces))))
+ ))