title: Emacs Copy Current Line
body: <p>For some reason, copying lines in Emacs is very unintuitive and difficult. If I'm doing something wrong here, please let me know. It is surprising that Emacs does not have this by default somewhere.</p>
  
  <p>I am trying to write a function that copies a line. I always used to have:</p>
  
  <pre><code>(global-set-key (kbd "C-x c") "\C-a\C- \C-n\M-w")
  </code></pre>
  
  <p>This is a little annoying since it copies any new line after the line. I decided to change it to:</p>
  
  <pre><code>(global-set-key (kbd "C-x c") "\M-m\C- \C-e\M-w")
  </code></pre>
  
  <p>Now, I saw: <a href="http://www.emacswiki.org/emacs/CopyingWholeLines" rel="nofollow">http://www.emacswiki.org/emacs/CopyingWholeLines</a>  and it appears that their copy-line function prints a message with the number of lines it copied. I am trying to insert that message into my global-set-key above but it is not working. Basically, I am unable to run a raw sequence as above in a function. So I conveyed each keystroke into a function and did this:</p>
  
  <pre><code>(defun copy-line ()
     (interactive)
     (kill-ring-save
      (back-to-indentation)
      (move-end-of-line 1))
      (message "1 line copied"))
  ;; optional key binding                 
  (global-set-key "\C-c\C-k" 'copy-line)
  </code></pre>
  
  <p>This however, throws a <code>wrong number of arguments</code> error. </p>
  
  <p>My first question: How can I put <code>(message "1 line copied")</code> into my global-set-key above?</p>
  
  <p>My second question: using the standard copy-line found in the link above:</p>
  
  <pre><code>(defun copy-line (arg)
        "Copy lines (as many as prefix argument) in the kill ring"
        (interactive "p")
        (kill-ring-save (line-beginning-position)
                        (line-beginning-position (+ 1 arg)))
        (message "%d line%s copied" arg (if (= 1 arg) "" "s")))
  </code></pre>
  
  <p>From the message, it appears that you can have multiple lines copied. However, when selecting multiple lines and copying, only one is copied. Why is the message structured in this way? How can it select multiple lines?</p>