Subject: bug#5366: (un)comment-line macros

From: Mads Jensen <[email-masked]>
Date: Tue, 12 Jan 2010 20:39:39 +0100

Hi,

I wrote the following two very simple macros. Nevertheless, I find them
very useless, and would be pleased if you could include them in a future
version of emacs.

(defun comment-line ()
   "comments the line"
   (interactive)
   (let ((start (point-at-bol))
	(end (point-at-eol)))
     (save-excursion
       (indent-region start end)
       (comment-region start end)
       (if (not (string= major-mode "text-mode"))
           (indent-for-tab-command)))))

(defun uncomment-line ()
   "uncomments the current line"
   (interactive)
   (let ((start (point-at-bol))
         (end (point-at-eol)))
     (save-excursion
       (uncomment-region start end)
       (if (not (string= major-mode "text-mode"))
           (indent-region start end)))))

I bound them to "C-c l" and "C-c u" respectively.

Yours sincerely,
Mads Jensen