The following Emacs Lisp function duplicates the current line and comments the first line (using the prefix for the current mode) .
(defun upn-comment-and-duplicate ()
"Comments current line after duplicating."
(interactive)
(let (
(beg (line-beginning-position))
(end (+ 1 (line-end-position))))
(copy-region-as-kill beg end)
(beginning-of-line)
(yank)
(comment-region beg end)))
Post a Comment