Function: evil-yank-rectangle

evil-yank-rectangle is a byte-compiled function defined in evil-common.el.

Signature

(evil-yank-rectangle BEG END &optional REGISTER YANK-HANDLER)

Documentation

Save the rectangle defined by region BEG and END into the kill-ring.

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-common.el
(defun evil-yank-rectangle (beg end &optional register yank-handler)
  "Save the rectangle defined by region BEG and END into the kill-ring."
  (let ((lines (list nil)))
    (evil-apply-on-rectangle #'extract-rectangle-line beg end lines)
    ;; We remove spaces from the beginning and the end of the next.
    ;; Spaces are inserted explicitly in the yank-handler in order to
    ;; NOT insert lines full of spaces.
    (setq lines (nreverse (cdr lines)))
    ;; `text' is used as default insert text when pasting this rectangle
    ;; in another program, e.g., using the X clipboard.
    (let ((yank-handler (list (or yank-handler #'evil-yank-block-handler)
                              lines
                              t
                              #'evil-delete-yanked-rectangle))
          (text (mapconcat #'identity lines "\n")))
      (put-text-property 0 (length text) 'yank-handler yank-handler text)
      (when register
        (evil-set-register register text))
      (when evil-was-yanked-without-register
        (evil-set-register ?0 text)) ; "0 register contains last yanked text
      (unless (eq register ?_)
        (kill-new text))
      text)))