branch: elpa/magit commit ff44ee1bc3d1bd8f3e922d13e4e32e66578a286b Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@bernoul.li>
git-rebase-kill-line: If the line is commented then uncomment it --- docs/magit.org | 3 ++- lisp/git-rebase.el | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/magit.org b/docs/magit.org index db431592ac..81dbf4f3e8 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 d86b9f8c53..8213f15faa 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))