Function: magit-section-backward

magit-section-backward is an interactive and byte-compiled function defined in magit-section.el.

Signature

(magit-section-backward)

Documentation

Move to the beginning of the current or the previous visible section.

When point is at the beginning of a section then move to the beginning of the previous visible section. Otherwise move to the beginning of the current section.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/magit-section-20260330.1102/magit-section.el
(defun magit-section-backward ()
  "Move to the beginning of the current or the previous visible section.
When point is at the beginning of a section then move to the
beginning of the previous visible section.  Otherwise move to
the beginning of the current section."
  (interactive)
  (if (bobp)
      (user-error "No previous section")
    (let ((section (magit-current-section)) children)
      (cond
        ((and (= (point)
                 (1- (oref section end)))
              (setq children (oref section children)))
         (magit-section-goto (car (last children))))
        ((and (oref section parent)
              (not (= (point)
                      (oref section start))))
         (magit-section-goto section))
        (t
         (let ((prev (car (magit-section-siblings section 'prev))))
           (if prev
               (while (and (not (oref prev hidden))
                           (setq children (oref prev children)))
                 (setq prev (car (last children))))
             (setq prev (oref section parent)))
           (cond (prev
                  (magit-section-goto prev))
                 ((oref section parent)
                  (user-error "No previous section"))
                 ;; Eob special cases.
                 ((not (get-text-property (1- (point)) 'invisible))
                  (magit-section-goto -1))
                 (t
                  (goto-char (previous-single-property-change
                              (1- (point)) 'invisible))
                  (forward-line -1)
                  (magit-section-goto (magit-current-section))))))))))