duplicate-thing
duplicate-thing copied to clipboard
Idea: duplicate-thing-and-comment
When I edit code, I often want to comment the thing which I have duplicated. Here's a function that I currently use for that job. Something like this might fit well in the duplicate-thing package. What do you think?
;; https://stackoverflow.com/questions/23588549/emacs-copy-region-line-and-comment-at-the-same-time
(defun copy-and-comment-region (beg end &optional arg)
"Duplicate the region and comment-out the copied text.
See `comment-region' for behavior of a prefix arg."
(interactive "r\nP")
(copy-region-as-kill beg end)
(goto-char end)
(yank)
(comment-region beg end arg)
(forward-line))