Commit da01d465 authored by Jonas Bernoulli's avatar Jonas Bernoulli

magit-confirm: Support third-party meta actions

Instead of hard-coding meta actions in `magit-confirm' add a new
variable `magit--no-confirm-alist' to let third-paries to add their
own meta actions.
parent add4a7f3
......@@ -577,6 +577,10 @@ ACTION is a member of option `magit-slow-confirm'."
(yes-or-no-p prompt)
(y-or-n-p prompt)))
(defvar magit--no-confirm-alist
'((safe-with-wip magit-wip-before-change-mode
discard reverse stage-all-changes unstage-all-changes)))
(cl-defun magit-confirm (action &optional prompt prompt-n noabort
(items nil sitems))
(declare (indent defun))
......@@ -586,13 +590,14 @@ ACTION is a member of option `magit-slow-confirm'."
(car items)))
(or (cond ((and (not (eq action t))
(or (eq magit-no-confirm t)
(memq action
,@(and magit-wip-before-change-mode
(memq 'safe-with-wip magit-no-confirm)
`(discard reverse
(memq action magit-no-confirm)
(cl-member-if (pcase-lambda (`(,key ,var . ,sub))
(and (memq key magit-no-confirm)
(memq action sub)
(or (not var)
(and (boundp var)
(symbol-value var)))))
(or (not sitems) items))
((not sitems)
(magit-y-or-n-p prompt action))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment