Function: cua--insert-rectangle

cua--insert-rectangle is a byte-compiled function defined in cua-rect.el.gz.

Signature

(cua--insert-rectangle RECT &optional BELOW PASTE-COLUMN LINE-COUNT)

Documentation

Insert rectangle RECT similarly to insert-rectangle.

In contrast to insert-rectangle, don't set mark and exit with point at either next to top right or below bottom left corner

Note: In overwrite mode, the rectangle is inserted as separate text lines.

Source Code

;; Defined in /usr/src/emacs/lisp/emulation/cua-rect.el.gz
(defun cua--insert-rectangle (rect &optional below paste-column line-count)
  "Insert rectangle RECT similarly to `insert-rectangle'.
In contrast to `insert-rectangle', don't set mark and exit with
point at either next to top right or below bottom left corner

Note: In overwrite mode, the rectangle is inserted as separate text lines."
  (if (eq below 'auto)
      (setq below (and (bolp)
                       (or (eolp) (eobp) (= (1+ (point)) (point-max))))))
  (unless paste-column
    (setq paste-column (current-column)))
  (let ((lines rect)
        (first t)
	(tabify-start (cua--tabify-start (point) (point)))
	last-column
        p)
    (while (or lines below)
      (or first
          (if overwrite-mode
              (insert ?\n)
            (forward-line 1)
            (or (bolp) (insert ?\n))))
      (unless overwrite-mode
	(move-to-column paste-column t))
      (if (not lines)
          (setq below nil)
        (insert-for-yank (car lines))
	(unless last-column
	  (setq last-column (current-column)))
        (setq lines (cdr lines))
        (and first (not below)
             (setq p (point))))
      (setq first nil)
      (if (and line-count (= (setq line-count (1- line-count)) 0))
	  (setq lines nil)))
    (when (and line-count last-column (not overwrite-mode))
      (while (> line-count 0)
	(forward-line 1)
	(or (bolp) (insert ?\n))
	(move-to-column paste-column t)
        (insert-char ?\s (- last-column paste-column -1))
	(setq line-count (1- line-count))))
    (when (and tabify-start
	       (not overwrite-mode))
      (tabify tabify-start (point)))
    (and p (not overwrite-mode)
         (goto-char p))))