From 3bcee5db219a1b6f418c27e30f41cf1939c95c96 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Thu, 20 Jun 2013 16:17:38 -0400 Subject: 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. --- init/km-func.el | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'init/km-func.el') 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)) -- cgit v1.2.3