* mu4e: use (user-error ..), not (error ..) for user errors

This commit is contained in:
djcb
2012-09-06 10:33:53 +03:00
parent 4508417e34
commit e342f9a5c4
6 changed files with 29 additions and 22 deletions

View File

@ -103,10 +103,17 @@ user-input, don't show anyhting."
nil))
(defun mu4e-error (frm &rest args)
"Create [mu4e]-prefixed error based on format FRM and ARGS."
"Create [mu4e]-prefixed error based on format FRM and ARGS. Does
a local-exit and does not return."
(mu4e-log 'error (apply 'mu4e-format frm args))
(error "%s" (apply 'mu4e-format frm args)))
(defun mu4e-warn (frm &rest args)
"Create [mu4e]-prefixed warning based on format FRM and
ARGS. Does a local-exit and does not return."
(mu4e-log 'error (apply 'mu4e-format frm args))
(user-error "%s" (apply 'mu4e-format frm args)))
(defun mu4e~read-char-choice (prompt choices)
"Compatiblity wrapper for `read-char-choice', which is emacs-24
only."
@ -166,7 +173,7 @@ Function will return the cdr of the list element."
options)))
(if chosen
(cdr chosen)
(mu4e-error "Unknown shortcut '%c'" response))))
(mu4e-warn "Unknown shortcut '%c'" response))))
(defun mu4e~get-maildirs-1 (path mdir)
@ -229,7 +236,7 @@ maildirs under `mu4e-maildir."
(ido-completing-read prompt (mu4e-get-maildirs))
(or (car-safe
(find-if (lambda (item) (= kar (cdr item))) mu4e-maildir-shortcuts))
(mu4e-error "Unknown shortcut '%c'" kar)))))))
(mu4e-warn "Unknown shortcut '%c'" kar)))))))
(defun mu4e-ask-maildir-check-exists (prompt)
@ -250,7 +257,7 @@ the region, for moving to maildir TARGET. If target is not
provided, function asks for it."
(interactive)
(unless (mu4e~headers-docid-at-point)
(mu4e-error "No message at point."))
(mu4e-warn "No message at point."))
(let* ((target (or target (mu4e-ask-maildir "Move message to: ")))
(target (if (string= (substring target 0 1) "/")
target
@ -291,7 +298,7 @@ KAR, or raise an error if none is found."
mu4e-bookmarks)))
(if chosen-bm
(nth 0 chosen-bm)
(mu4e-error "Unknown shortcut '%c'" kar))))
(mu4e-warn "Unknown shortcut '%c'" kar))))
;;; converting flags->string and vice-versa ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -476,7 +483,7 @@ there is no message at point."
(get-text-property (point) 'msg))
((eq major-mode 'mu4e-view-mode)
mu4e~view-msg))))
(if (and (null msg) raise-err)
(if (and (null msg) raise-err)
(mu4e-warn "No message at point")
msg)))
@ -545,7 +552,7 @@ process."
(defun mu4e-error-handler (errcode errmsg)
"Handler function for showing an error."
;; don't use mu4e-error here; it's running in the process filter ctx
(case errcode
(case errcode
(4 (user-error "No matches for this search query."))
(t (error "Error %d: %s" errcode errmsg))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -855,9 +862,9 @@ This includes expanding e.g. 3-5 into 3,4,5. If the letter
(mapc
#'(lambda (x)
(cond
((> x n)
((> x n)
(mu4e-warn "Attachment %d bigger than maximum (%d)" x n))
((< x 1)
((< x 1)
(mu4e-warn "Attachment number must be greater than 0 (%d)" x))))
list)))