R‎ > ‎Emacs Commands‎ > ‎Custom Emacs Functions‎ > ‎

Copy Line (rather than kill)

posted Apr 12, 2010, 6:57 AM by David Eagle
;;Copy Line function
(defun copy-line (&optional arg)
  "Do a kill-line but copy rather than kill.  This function directly calls
kill-line, so see documentation of kill-line for how to use it including prefix
argument and relevant variables.  This function works by temporarily making the
buffer read-only, so I suggest setting kill-read-only-ok to t."
  (interactive "P")
  (toggle-read-only 1)
  (kill-line arg)
  (toggle-read-only 0))
(setq-default kill-read-only-ok t)
(global-set-key [hyper k] 'copy-line)