duplicate-thing icon indicating copy to clipboard operation
duplicate-thing copied to clipboard

Idea: duplicate-thing-and-comment

Open kwstat opened this issue 3 years ago • 0 comments

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))

kwstat avatar Jul 30 '21 16:07 kwstat