Function: magit-section-case
magit-section-case is a macro defined in magit-section.el.
Signature
(magit-section-case &rest CLAUSES)
Documentation
Choose among clauses on the type of the section at point.
Each clause looks like (CONDITION BODY...). The type of the
section is compared against each CONDITION; the BODY forms of the
first match are evaluated sequentially and the value of the last
form is returned. Inside BODY the symbol it is bound to the
section at point. If no clause succeeds or if there is no
section at point, return nil.
See magit-section-match for the forms CONDITION can take.
Additionally a CONDITION of t is allowed in the final clause, and
matches if no other CONDITION match, even if there is no section
at point.
Source Code
;; Defined in ~/.emacs.d/elpa/magit-section-20260330.1102/magit-section.el
(defmacro magit-section-case (&rest clauses)
"Choose among clauses on the type of the section at point.
Each clause looks like (CONDITION BODY...). The type of the
section is compared against each CONDITION; the BODY forms of the
first match are evaluated sequentially and the value of the last
form is returned. Inside BODY the symbol `it' is bound to the
section at point. If no clause succeeds or if there is no
section at point, return nil.
See `magit-section-match' for the forms CONDITION can take.
Additionally a CONDITION of t is allowed in the final clause, and
matches if no other CONDITION match, even if there is no section
at point."
(declare (indent 0)
(debug (&rest (sexp body))))
`(let ((it (magit-current-section)))
(cond ,@(mapcar (lambda (clause)
`(,(or (eq (car clause) t)
`(and it
(magit-section-match-1 ',(car clause) it)))
,@(cdr clause)))
clauses))))