aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Bernoulli <jonas@bernoul.li>2025-04-15 19:45:35 +0200
committerJonas Bernoulli <jonas@bernoul.li>2025-04-15 19:45:35 +0200
commitff44ee1bc3d1bd8f3e922d13e4e32e66578a286b (patch)
tree6f60d473a92f6bf3df57d0441eee78706dd3b5c3
parent69b310e1096265579399ec3be9af73182e7895cc (diff)
git-rebase-kill-line: If the line is commented then uncomment it
-rw-r--r--docs/magit.org3
-rw-r--r--lisp/git-rebase.el13
2 files changed, 10 insertions, 6 deletions
diff --git a/docs/magit.org b/docs/magit.org
index db43159..81dbf4f 100644
--- a/docs/magit.org
+++ b/docs/magit.org
@@ -6124,7 +6124,8 @@ the following suffix commands.
- Key: k (git-rebase-kill-line) ::
- Kill the current action line.
+ Comment the current action line, or if it is already commented, then
+ uncomment it.
- Key: c (git-rebase-pick) ::
diff --git a/lisp/git-rebase.el b/lisp/git-rebase.el
index d86b9f8..8213f15 100644
--- a/lisp/git-rebase.el
+++ b/lisp/git-rebase.el
@@ -330,8 +330,8 @@ instance with all nil values is returned."
"Set action of commit line to ACTION.
If the region is active, operate on all lines that it touches.
Otherwise, operate on the current line. As a special case, an
-ACTION of nil comments the rebase line, regardless of its action
-type."
+ACTION of nil comments or uncomments the rebase line, regardless
+of its action type."
(pcase (git-rebase-region-bounds t)
(`(,beg ,end)
(let ((end-marker (copy-marker end))
@@ -346,9 +346,11 @@ type."
(let ((inhibit-read-only t))
(magit-delete-line)
(insert (concat action " " target " " trailer "\n"))))
- ((and action-type (not (or action comment-p)))
+ ((and (not action) action-type)
(let ((inhibit-read-only t))
- (insert comment-start " "))
+ (if comment-p
+ (delete-region beg (+ beg 2))
+ (insert comment-start " ")))
(forward-line))
(t
;; In the case of --rebase-merges, commit lines may have
@@ -454,7 +456,8 @@ current line."
(funcall (default-value 'redisplay-unhighlight-region-function) rol))
(defun git-rebase-kill-line ()
- "Kill the current action line.
+ "Comment the current action line.
+If the action line is already commented, then uncomment it.
If the region is active, act on all lines touched by the region."
(interactive)
(git-rebase-set-action nil))