* mu4e-mark: use y-or-n-p, not yes-or-no-p to ask for confirmation

This commit is contained in:
djcb 2012-04-28 13:46:38 +03:00
parent b57f1e3314
commit 99c1042769
1 changed files with 13 additions and 11 deletions

View File

@ -52,8 +52,8 @@ where
(defun mu4e~mark-clear () (defun mu4e~mark-clear ()
"Clear the marks subsystem." "Clear the marks subsystem."
(clrhash mu4e~mark-map)) (clrhash mu4e~mark-map))
(defun mu4e-mark-at-point (mark &optional target) (defun mu4e-mark-at-point (mark &optional target)
"Mark (or unmark) message at point. MARK specifies the "Mark (or unmark) message at point. MARK specifies the
@ -143,8 +143,7 @@ provided, function asks for it."
(mu4e-mark-set 'move target)))) (mu4e-mark-set 'move target))))
(defun mu4e-mark-execute-all (&optional no-confirmation)
(defun mu4e-mark-execute-all ()
"Execute the actions for all marked messages in this "Execute the actions for all marked messages in this
buffer. After the actions have been executed succesfully, the buffer. After the actions have been executed succesfully, the
affected messages are *hidden* from the current header list. Since affected messages are *hidden* from the current header list. Since
@ -153,14 +152,17 @@ the messages no longer matches the current one - to get that
certainty, we need to rerun the search, but we don't want to do certainty, we need to rerun the search, but we don't want to do
that automatically, as it may be too slow and/or break the users that automatically, as it may be too slow and/or break the users
flow. Therefore, we hide the message, which in practice seems to flow. Therefore, we hide the message, which in practice seems to
work well." work well.
If NO-CONFIRMATION is non-nil, don't ask user for confirmation."
(interactive) (interactive)
(let ((marknum (hash-table-count mu4e~mark-map))) (let ((marknum (hash-table-count mu4e~mark-map)))
(if (zerop marknum) (if (zerop marknum)
(message "Nothing is marked") (message "Nothing is marked")
(when (yes-or-no-p (when (or no-confirmation
(format "Are you sure you want to execute %d mark%s?" (y-or-n-p
marknum (if (> marknum 1) "s" ""))) (format "Are you sure you want to execute %d mark%s?"
marknum (if (> marknum 1) "s" ""))))
(maphash (maphash
(lambda (docid val) (lambda (docid val)
(let ((mark (nth 0 val)) (target (nth 1 val))) (let ((mark (nth 0 val)) (target (nth 1 val)))
@ -176,7 +178,7 @@ work well."
mu4e~mark-map)) mu4e~mark-map))
(mu4e-mark-unmark-all) (mu4e-mark-unmark-all)
(message nil)))) (message nil))))
(defun mu4e-mark-unmark-all () (defun mu4e-mark-unmark-all ()
"Unmark all marked messages." "Unmark all marked messages."
(interactive) (interactive)
@ -216,6 +218,6 @@ action', return nil means 'don't do anything'"
("ignore marks?" nil ignore))))) ("ignore marks?" nil ignore)))))
;; we determined what to do... now do it ;; we determined what to do... now do it
(when (eq what 'apply) (when (eq what 'apply)
(mu4e-mark-execute-all)))))))) (mu4e-mark-execute-all t))))))))
(provide 'mu4e-mark) (provide 'mu4e-mark)