Function: magit-previous-line

magit-previous-line is an autoloaded, interactive and byte-compiled function defined in magit-extras.el.

Signature

(magit-previous-line &optional ARG TRY-VSCROLL)

Documentation

Like previous-line but with Magit-specific shift-selection.

Magit's selection mechanism is based on the region but selects an area that is larger than the region. This causes previous-line when invoked while holding the shift key to move up one line and thereby select two lines. When invoked inside a hunk body this command does not move point on the first invocation and thereby it only selects a single line. Which inconsistency you prefer is a matter of preference.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-extras.el
;;;###autoload
(defun magit-previous-line (&optional arg try-vscroll)
  "Like `previous-line' but with Magit-specific shift-selection.

Magit's selection mechanism is based on the region but selects an
area that is larger than the region.  This causes `previous-line'
when invoked while holding the shift key to move up one line and
thereby select two lines.  When invoked inside a hunk body this
command does not move point on the first invocation and thereby
it only selects a single line.  Which inconsistency you prefer
is a matter of preference."
  (declare (interactive-only
            "use `forward-line' with negative argument instead."))
  (interactive "p\np")
  (unless arg (setq arg 1))
  (let ((stay (or (magit-diff-inside-hunk-body-p)
                  (magit-section-position-in-heading-p))))
    (if (and stay (= arg 1) (magit--turn-on-shift-select-mode-p))
        (push-mark nil nil t)
      (with-no-warnings
        (handle-shift-selection)
        (previous-line (if stay (max (1- arg) 1) arg) try-vscroll)))))