Function: copy-rectangle-to-register

copy-rectangle-to-register is an interactive and byte-compiled function defined in register.el.gz.

Signature

(copy-rectangle-to-register REGISTER START END &optional DELETE-FLAG)

Documentation

Copy rectangular region of text between START and END into REGISTER.

If DELETE-FLAG is non-nil (interactively, prefix arg), delete the region after copying. To insert this register into a buffer, use C-x r g (insert-register).

Called from Lisp, takes four args: REGISTER, START, END and DELETE-FLAG. START and END are buffer positions giving two corners of rectangle.

Interactively, prompt for REGISTER using register-read-with-preview, and use mark and point as START and END.

View in manual

Probably introduced at or before Emacs version 19.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/register.el.gz
(defun copy-rectangle-to-register (register start end &optional delete-flag)
  "Copy rectangular region of text between START and END into REGISTER.
If DELETE-FLAG is non-nil (interactively, prefix arg), delete the region
after copying.
To insert this register into a buffer, use \\[insert-register].

Called from Lisp, takes four args: REGISTER, START, END and DELETE-FLAG.
START and END are buffer positions giving two corners of rectangle.

Interactively, prompt for REGISTER using `register-read-with-preview',
and use mark and point as START and END."
  (interactive (list (register-read-with-preview
		      "Copy rectangle to register: ")
		     (region-beginning)
		     (region-end)
		     current-prefix-arg))
  (let ((rectangle (if delete-flag
		       (delete-extract-rectangle start end)
		     (extract-rectangle start end))))
    (set-register register rectangle)
    (when (and (null delete-flag)
	       (called-interactively-p 'interactive))
      (setq deactivate-mark t)
      (indicate-copied-region (length (car rectangle))))))