Created
July 10, 2014 18:03
-
-
Save hub-cap/1324d00b01c5bd9fe1bd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Original idea from | |
;; http://www.opensubscriber.com/message/[email protected]/10971693.html | |
(defun comment-dwim-line (&optional arg) | |
"Replacement for the comment-dwim command. | |
If no region is selected and current line is not blank and we are not at the end of the line, | |
then comment current line. | |
Replaces default behaviour of comment-dwim, when it inserts comment at the end of the line." | |
(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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment