Function: git-rebase-move-line-down

git-rebase-move-line-down is an interactive and byte-compiled function defined in git-rebase.el.

Signature

(git-rebase-move-line-down N)

Documentation

Move the current commit (or command) N lines down.

If N is negative, move the commit up instead. With an active region, move all the lines that the region touches, not just the current line.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/git-rebase.el
(defun git-rebase-move-line-down (n)
  "Move the current commit (or command) N lines down.
If N is negative, move the commit up instead.  With an active
region, move all the lines that the region touches, not just the
current line."
  (interactive "p")
  (pcase-let* ((`(,beg ,end)
                (or (git-rebase-region-bounds)
                    (list (line-beginning-position)
                          (1+ (line-end-position)))))
               (pt-offset (- (point) beg))
               (mark-offset (and mark-active (- (mark) beg))))
    (save-restriction
      (narrow-to-region
       (point-min)
       (1-
        (if git-rebase-show-instructions
            (save-excursion
              (goto-char (point-min))
              (while (or (git-rebase-line-p)
                         ;; The output for --rebase-merges has empty
                         ;; lines and "Branch" comments interspersed.
                         (looking-at-p "^$")
                         (looking-at-p (concat git-rebase-comment-re
                                               " Branch")))
                (forward-line))
              (line-beginning-position))
          (point-max))))
      (if (or (and (< n 0) (= beg (point-min)))
              (and (> n 0) (= end (point-max)))
              (> end (point-max)))
          (ding)
        (goto-char (if (< n 0) beg end))
        (forward-line n)
        (atomic-change-group
          (let ((inhibit-read-only t))
            (insert (delete-and-extract-region beg end)))
          (let ((new-beg (- (point) (- end beg))))
            (when (use-region-p)
              (setq deactivate-mark nil)
              (set-mark (+ new-beg mark-offset)))
            (goto-char (+ new-beg pt-offset))))))))