summaryrefslogtreecommitdiff
path: root/init
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
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')
-rw-r--r--init/km-func.el10
-rw-r--r--init/km-keychord.el2
2 files changed, 12 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))
diff --git a/init/km-keychord.el b/init/km-keychord.el
index 720855b..75017a8 100644
--- a/init/km-keychord.el
+++ b/init/km-keychord.el
@@ -15,3 +15,5 @@
(key-chord-define-global ",e" 'eval-region)
(key-chord-define-global ",w" 'km/sync-mail)
+
+(key-chord-define-global ",c" 'km/toggle-line-or-region-comment)