Function: copy-to-register

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

Signature

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

Documentation

Copy region of text between START and END into REGISTER.

If DELETE-FLAG is non-nil (interactively, prefix arg), delete the region after copying. Called from Lisp, takes five args: REGISTER, START, END, DELETE-FLAG, and REGION. START and END are buffer positions indicating what to copy. The optional argument REGION, if non-nil, means START..END denotes the region.

Interactively, prompt for REGISTER using register-read-with-preview and use mark and point as START and END; REGION is always non-nil in this case.

View in manual

Probably introduced at or before Emacs version 19.20.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/register.el.gz
(defun copy-to-register (register start end &optional delete-flag region)
  "Copy region of text between START and END into REGISTER.
If DELETE-FLAG is non-nil (interactively, prefix arg), delete the region
after copying.
Called from Lisp, takes five args: REGISTER, START, END, DELETE-FLAG,
and REGION.  START and END are buffer positions indicating what to copy.
The optional argument REGION, if non-nil, means START..END denotes the
region.

Interactively, prompt for REGISTER using `register-read-with-preview'
and use mark and point as START and END; REGION is always non-nil in
this case."
  (interactive (list (register-read-with-preview "Copy to register: ")
		     (region-beginning)
		     (region-end)
		     current-prefix-arg
		     t))
  (set-register register (if region
			     (funcall region-extract-function delete-flag)
			   (prog1 (filter-buffer-substring start end)
			     (if delete-flag (delete-region start end)))))
  (setq deactivate-mark t)
  (cond (delete-flag)
	((called-interactively-p 'interactive)
	 (indicate-copied-region))))