I write a elisp function to copy the current line if no region has be selected, but it does not work on emacs 24.5. When I hit the "M-w" keystrokes , there comes a message "Mark set" in the minibuffer. Did I miss something?
(defun copy-region-or-current-line (beg end)
  "copy current if no region selected, copy the region otherwise"
  (interactive "r")
  (let ((cur-pos (point)))
    (if (region-active-p)
        (kill-ring-save beg end)
      (progn
        (kill-whole-line)
        (yank)
        (goto-char cur-pos)))))
(global-set-key (kbd "M-w") 'copy-region-or-current-line)