summaryrefslogtreecommitdiff
path: root/init/km-func.el
diff options
context:
space:
mode:
authorKyle Meyer <meyerkya@gmail.com>2013-06-20 16:17:38 -0400
committerKyle Meyer <meyerkya@gmail.com>2013-06-30 20:53:18 -0400
commit3bcee5db219a1b6f418c27e30f41cf1939c95c96 (patch)
tree7090b9471ca0d809af51624c9e1deeaf109e0b1c /init/km-func.el
parent29ca27738c8d49221a4a5a8d26ed7fab5906d8ae (diff)
downloademacs.d-3bcee5db219a1b6f418c27e30f41cf1939c95c96.tar.gz
toggle comment in line or region
comment-dwim does not have the behavior I'd like for a single line: it starts a comment at the end of that line instead of commenting that line.
Diffstat (limited to 'init/km-func.el')
-rw-r--r--init/km-func.el10
1 files changed, 10 insertions, 0 deletions
diff --git a/init/km-func.el b/init/km-func.el
index 4b3db51..1f2c809 100644
--- a/init/km-func.el
+++ b/init/km-func.el
@@ -63,3 +63,13 @@ user."
(interactive)
(save-buffer)
(kill-this-buffer))
+
+(defun km/toggle-line-or-region-comment ()
+ "Comment/uncomment the current line or region"
+ (interactive)
+ (let (beg end)
+ (if (region-active-p)
+ (setq beg (region-beginning) end (region-end))
+ (setq beg (line-beginning-position) end (line-end-position)))
+ (comment-or-uncomment-region beg end))
+ (forward-line))