Emacs lisp function to copy the current line

March 14th, 2010 | Tags:

I used to have some elisp code stolen from somewhere which copy the current line. Then I find most of time I don’t want the prefix whitespaces copied, so I modified it a bit as a tiny try to cure my lisp-parenthesis-horror.

(defun copy-line (&optional arg)
       "Save current line from the first non-whitespce character into Kill-Ring without mark the line "
       (interactive "P")
       (let ((beg (progn (back-to-indentation) (point)))
             (end (line-end-position)))
         (copy-region-as-kill beg end))
       )
(global-set-key (kbd "C-c l") (quote copy-line))

It seems that lisp is not as daunting as haskell…