Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emacs command to append to ring

Tags:

copy

append

emacs

How can I make an emacs command to copy text (to the kill ring) by appending? (Why is there no such built-in command?)

Appending Kills mentions C-M-w (`append-next-kill') which allows me to append with kill commands such as C-d or C-k. But it's for killing texts instead of copying them.

like image 674
Yoo Avatar asked Nov 25 '09 01:11

Yoo


3 Answers

Actually, there is such a built in command. C-M-w will append a subsequent copy as well as a kill. So you would mark the region you desire to copy, then type C-M-w followed by M-w and the next C-y will yank the joined kills.

like image 158
pajato0 Avatar answered Nov 13 '22 19:11

pajato0


Play with a variation of this in your .emacs file...

(defun append-kill-line (&optional arg)
  "Append kill-line to current kill buffer, prefix arg kills from beginning of line."
  (interactive "P")
  (append-next-kill)
  (kill-line arg)
)

(define-key global-map "\C-x\C-m" 'append-kill-line)
like image 4
Don Avatar answered Nov 13 '22 18:11

Don


Can append-to-register meet your needs?

like image 2
Roger Wang Avatar answered Nov 13 '22 17:11

Roger Wang