Function: append-to-register

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

Signature

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

Documentation

Append region of text between START and END to REGISTER.

If DELETE-FLAG is non-nil (interactively, prefix arg), delete the region after appending. Called from Lisp, takes four args: REGISTER, START, END and DELETE-FLAG. START and END are buffer positions indicating what to append.

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 24.3.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/register.el.gz
(defun append-to-register (register start end &optional delete-flag)
  "Append region of text between START and END to REGISTER.
If DELETE-FLAG is non-nil (interactively, prefix arg), delete the region
after appending.
Called from Lisp, takes four args: REGISTER, START, END and DELETE-FLAG.
START and END are buffer positions indicating what to append.

Interactively, prompt for REGISTER using `register-read-with-preview',
and use mark and point as START and END."
  (interactive (list (register-read-with-preview
		      "Append 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 reg separator text))
                    (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))))