July 1st, 2011 No comments
I was wondering if the comment-dwin (M-;) command could be changed that if i am anywhere in the line the whole line is commented and not a comment started from the end of the line. based on the idea found in a mailing list i altered the command with
;; http://firstname.lastname@example.org/10971693.html (defun comment-dwim-line (&optional arg) (interactive "*P") (comment-normalize-vars) (if (and (not (region-active-p)) (not (looking-at "[ \t]*$"))) (comment-or-uncomment-region (line-beginning-position) (line-end-position)) (comment-dwim arg))) (global-set-key "\M-;" 'comment-dwim-line)
add this to your .emacs file and enjoy.