Function: magit-cancel-section

magit-cancel-section is a byte-compiled function defined in magit-section.el.

Signature

(magit-cancel-section &optional IF-EMPTY)

Documentation

Cancel inserting the section that is currently being inserted.

Canceling returns from the inner most use of magit-insert-section and removes all text that was inserted by that.

If optional IF-EMPTY is non-nil, then only cancel the section, if it is empty. If a section is split into a heading and a body (i.e., when its content slot is non-nil), then only check if the body is empty.

Source Code

;; Defined in ~/.emacs.d/elpa/magit-section-20260330.1102/magit-section.el
(defun magit-cancel-section (&optional if-empty)
  "Cancel inserting the section that is currently being inserted.

Canceling returns from the inner most use of `magit-insert-section' and
removes all text that was inserted by that.

If optional IF-EMPTY is non-nil, then only cancel the section, if it is
empty.  If a section is split into a heading and a body (i.e., when its
`content' slot is non-nil), then only check if the body is empty."
  (when (and magit-insert-section--current
             (or (not if-empty)
                 (= (point) (or (oref magit-insert-section--current content)
                                (oref magit-insert-section--current start)))))
    (if (eq magit-insert-section--current magit-root-section)
        (insert "(empty)\n")
      (delete-region (oref magit-insert-section--current start)
                     (point))
      (setq magit-insert-section--current nil)
      (throw 'cancel-section nil))))