Function: prepend-to-register
prepend-to-register is an interactive and byte-compiled function
defined in register.el.gz.
Signature
(prepend-to-register REGISTER START END &optional DELETE-FLAG)
Documentation
Prepend region of text between START and END to REGISTER.
If DELETE-FLAG is non-nil (interactively, prefix arg), delete the region after prepending. Called from program, takes four args: REGISTER, START, END and DELETE-FLAG. START and END are buffer positions indicating what to prepend.
Interactively, prompt for REGISTER using register-read-with-preview,
and use mark and point as START and END.
Probably introduced at or before Emacs version 24.3.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/register.el.gz
(defun prepend-to-register (register start end &optional delete-flag)
"Prepend region of text between START and END to REGISTER.
If DELETE-FLAG is non-nil (interactively, prefix arg), delete the region
after prepending.
Called from program, takes four args: REGISTER, START, END and DELETE-FLAG.
START and END are buffer positions indicating what to prepend.
Interactively, prompt for REGISTER using `register-read-with-preview',
and use mark and point as START and END."
(interactive (list (register-read-with-preview
"Prepend to register: "
(lambda (regval)
(or (null regval) (stringp regval))))
(region-beginning)
(region-end)
current-prefix-arg))
(let ((reg (get-register register))
(text (filter-buffer-substring start end))
(separator (and register-separator (get-register register-separator))))
(set-register
register (cond ((not reg) text)
((stringp reg) (concat text separator reg))
(t (user-error "Register does not contain text")))))
(setq deactivate-mark t)
(cond (delete-flag
(delete-region start end))
((called-interactively-p 'interactive)
(indicate-copied-region))))