(defun tiw-comment-line () "comment or uncomment a line according to the first charachter" (save-excursion (beginning-of-line) (if (looking-at comment-start) (uncomment-region (line-beginning-position) (line-end-position) nil) (comment-region (line-beginning-position) (line-end-position) nil))))
(defun tiw-comment-region () "comment or uncomment a region according to the first character" (interactive) (let ((b-p (region-beginning)) (e-p (region-end))) (save-excursion (goto-char (region-beginning)) (if (looking-at comment-start) (uncomment-region b-p e-p nil) (comment-region b-p e-p nil)))))