Function: magit-define-section-jumper

magit-define-section-jumper is a macro defined in magit-section.el.

Signature

(magit-define-section-jumper NAME HEADING TYPE &optional VALUE INSERTER &rest PROPERTIES)

Documentation

Define an interactive function to go to some section.

Together TYPE and VALUE identify the section. HEADING is the displayed heading of the section.

Source Code

;; Defined in ~/.emacs.d/elpa/magit-section-20260330.1102/magit-section.el
(defmacro magit-define-section-jumper
    (name heading type &optional value inserter &rest properties)
  "Define an interactive function to go to some section.
Together TYPE and VALUE identify the section.
HEADING is the displayed heading of the section."
  (declare (indent defun))
  `(transient-define-suffix ,name (&optional expand)
     ,(format "Jump to the section \"%s\".
With a prefix argument also expand it." heading)
     ,@properties
     ,@(and (not (plist-member properties :description))
            (list :description heading))
     ,@(and inserter
            `(:if (##memq ',inserter
                          (symbol-value
                           (intern (format "%s-sections-hook"
                                           (substring (symbol-name major-mode)
                                                      0 -5)))))))
     :inapt-if-not (##magit-get-section
                    (cons (cons ',type ,value)
                          (magit-section-ident magit-root-section)))
     (interactive "P")
     (cond-let
       ([section (magit-get-section
                  (cons (cons ',type ,value)
                        (magit-section-ident magit-root-section)))]
        (goto-char (oref section start))
        (when expand
          (with-local-quit (magit-section-show section))
          (recenter 0)))
       ((message ,(format "Section \"%s\" wasn't found" heading))))))