Function: rectangle--duplicate-right
rectangle--duplicate-right is a byte-compiled function defined in
rect.el.gz.
Signature
(rectangle--duplicate-right N DISPLACEMENT)
Documentation
Duplicate the rectangular region N times on the right-hand side.
Leave the region moved DISPLACEMENT region-wide steps to the right.
Source Code
;; Defined in /usr/src/emacs/lisp/rect.el.gz
(defun rectangle--duplicate-right (n displacement)
"Duplicate the rectangular region N times on the right-hand side.
Leave the region moved DISPLACEMENT region-wide steps to the right."
(let ((cols (rectangle--pos-cols (point) (mark))))
(apply-on-rectangle
(lambda (startcol endcol)
(let ((lines (list nil)))
(extract-rectangle-line startcol endcol lines)
(move-to-column endcol t)
(dotimes (_ n)
(insert (cadr lines)))))
(min (point) (mark))
(max (point) (mark)))
;; Recompute the rectangle state.
(let* ((p (point))
(m (mark))
(point-col (car cols))
(mark-col (cdr cols))
(d (* displacement (abs (- point-col mark-col)))))
(rectangle--reset-crutches)
(goto-char m)
(move-to-column (+ mark-col d) t)
(if (= d 0)
(set-mark (point))
(push-mark (point)))
(goto-char p)
(move-to-column (+ point-col d) t))))