Created
January 9, 2015 08:35
-
-
Save tkareine/a22a6adf963125cbd445 to your computer and use it in GitHub Desktop.
Comment or uncomment region or current line
This file contains 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
(defun tkareine/active-region-or-line () | |
(if mark-active (list (region-beginning) (region-end)) | |
(list (line-beginning-position) | |
(line-beginning-position 2)))) | |
(defun tkareine/comment-or-uncomment-region-or-line () | |
(interactive) | |
(let ((region (tkareine/active-region-or-line))) | |
(when region | |
(let ((rbegin (car region)) | |
(rend (cadr region))) | |
(comment-or-uncomment-region rbegin rend))))) | |
(global-set-key (kbd "C-c c") 'tkareine/comment-or-uncomment-region-or-line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment