;; to accumulate them for extract-rectangle and delete-extract-rectangle.
(defvar operate-on-rectangle-lines)
-;; ### NOTE: this function is untouched, but not used anymore appart in
+;; ### NOTE: this function is untouched, but not used anymore apart from
;; `delete-whitespace-rectangle'. `apply-on-rectangle' is used instead. --dv
(defun operate-on-rectangle (function start end coerce-tabs)
"Call FUNCTION for each line of rectangle with corners at START, END.
(goto-char start))
(defun open-rectangle-line (startcol endcol fill)
- (let (spaces)
- (when (= (move-to-column-force startcol (or fill 'coerce)) startcol)
- (unless (and (not fill)
- (= (point) (point-at-eol)))
- (indent-to endcol)))
- ))
+ (when (= (move-to-column-force startcol (or fill 'coerce)) startcol)
+ (unless (and (not fill)
+ (= (point) (point-at-eol)))
+ (indent-to endcol))))
(defun delete-whitespace-rectangle-line (startcol endcol fill)
(when (= (move-to-column-force startcol (or fill 'coerce)) startcol)
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))
+ (apply-on-rectangle 'string-rectangle-line start end string
+ (bound-and-true-p 'delete-selection-mode)))
-(defun string-rectangle-line (startcol endcol string)
+(defun string-rectangle-line (startcol endcol string delete)
(move-to-column-force startcol)
+ (if delete
+ (delete-rectangle-line startcol endcol nil))
(insert string))
+;;;###autoload
+(defun replace-rectangle (start end string)
+ "Like `string-rectangle', but replace the original region."
+ (interactive "*r\nsString rectangle: ")
+ (apply-on-rectangle 'string-rectangle-line start end string t))
+
;;;###autoload
(defun clear-rectangle (start end &optional fill)
"Blank out the region-rectangle.