From e342f9a5c40d725127327b72ad904442bcb55d73 Mon Sep 17 00:00:00 2001 From: djcb Date: Thu, 6 Sep 2012 10:33:53 +0300 Subject: [PATCH] * mu4e: use (user-error ..), not (error ..) for user errors --- mu4e/mu4e-compose.el | 6 +++--- mu4e/mu4e-headers.el | 12 ++++++------ mu4e/mu4e-main.el | 2 +- mu4e/mu4e-mark.el | 4 ++-- mu4e/mu4e-utils.el | 25 ++++++++++++++++--------- mu4e/mu4e-view.el | 2 +- 6 files changed, 29 insertions(+), 22 deletions(-) diff --git a/mu4e/mu4e-compose.el b/mu4e/mu4e-compose.el index 2b7328d6..2f032c6d 100644 --- a/mu4e/mu4e-compose.el +++ b/mu4e/mu4e-compose.el @@ -89,10 +89,10 @@ forwarded or edited) in `mu4e-compose-pre-hook.") "Insert the last captured message file as an attachment." (interactive) (unless mu4e-captured-message - (mu4e-error "No message has been captured")) + (mu4e-warn "No message has been captured")) (let ((path (plist-get mu4e-captured-message :path))) (unless (file-exists-p path) - (mu4e-error "Captured message file not found")) + (mu4e-warn "Captured message file not found")) (mml-attach-file path "application/octet-stream" @@ -689,7 +689,7 @@ for draft messages." (mu4e-error "Invalid compose type '%S'" compose-type)) (when (and (eq compose-type 'edit) (not (member 'draft (mu4e-field-at-point :flags)))) - (mu4e-error "Editing is only allowed for draft messages")) + (mu4e-warn "Editing is only allowed for draft messages")) ;; run the hooks (mu4e~compose-run-hooks compose-type) diff --git a/mu4e/mu4e-headers.el b/mu4e/mu4e-headers.el index 8d18b9a6..df346997 100644 --- a/mu4e/mu4e-headers.el +++ b/mu4e/mu4e-headers.el @@ -964,11 +964,11 @@ to get it from; it's a symbol, either 'future or 'past." (case whence (past (unless mu4e~headers-query-past - (mu4e-error "No more previous queries")) + (mu4e-warn "No more previous queries")) (pop mu4e~headers-query-past)) (future (unless mu4e~headers-query-future - (mu4e-error "No more next queries")) + (mu4e-warn "No more next queries")) (pop mu4e~headers-query-future)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1029,7 +1029,7 @@ the last search expression." nil 'mu4e~headers-search-hist nil t))) (list filter))) (unless mu4e~headers-last-query - (mu4e-error "There's nothing to filter")) + (mu4e-warn "There's nothing to filter")) (mu4e-headers-search (format "(%s) AND %s" mu4e~headers-last-query filter))) @@ -1106,7 +1106,7 @@ current window. " (unless (eq major-mode 'mu4e-headers-mode) (mu4e-error "Must be in mu4e-headers-mode (%S)" major-mode)) (let* ((docid (or (mu4e~headers-docid-at-point) - (mu4e-error "No message at point"))) + (mu4e-warn "No message at point"))) (viewwin (mu4e~headers-redraw-get-view-window))) (unless (window-live-p viewwin) (mu4e-error "Cannot get a message view")) @@ -1208,13 +1208,13 @@ N. Otherwise, don't do anything." (horizontal (let ((newval (+ (or n 1) mu4e-headers-visible-lines))) (unless (> newval 0) - (mu4e-error + (mu4e-warn "Cannot make the number of visible lines any smaller")) (setq mu4e-headers-visible-lines newval))) (vertical (let ((newval (+ (or n 1) mu4e-headers-visible-columns))) (unless (> newval 0) - (mu4e-error + (mu4e-warn "Cannot make the number of visible columns any smaller")) (setq mu4e-headers-visible-columns newval)))) (let ((viewwin (mu4e~headers-redraw-get-view-window))) diff --git a/mu4e/mu4e-main.el b/mu4e/mu4e-main.el index 89654310..1215e1d1 100644 --- a/mu4e/mu4e-main.el +++ b/mu4e/mu4e-main.el @@ -28,7 +28,7 @@ (require 'mu4e-utils) ;; utility functions -(defconst mu4e~main-buffer-name "*mu4e-main*" +(defconst mu4e~main-buffer-name " *mu4e-main*" "*internal* Name of the mu4e main view buffer.") (defvar mu4e-main-mode-map diff --git a/mu4e/mu4e-mark.el b/mu4e/mu4e-mark.el index 6cebbb70..6e257445 100644 --- a/mu4e/mu4e-mark.el +++ b/mu4e/mu4e-mark.el @@ -119,7 +119,7 @@ The following marks are available, and the corresponding props: (otherwise (mu4e-error "Invalid mark %S" mark)))) (markkar (car markcell)) (target (cdr markcell))) - (unless docid (mu4e-error "No message on this line")) + (unless docid (mu4e-warn "No message on this line")) (unless (eq major-mode 'mu4e-headers-mode) (mu4e-error "Not in headers-mode")) (save-excursion @@ -272,7 +272,7 @@ If NO-CONFIRMATION is non-nil, don't ask user for confirmation." "Unmark all marked messages." (interactive) (when (or (null mu4e~mark-map) (zerop (hash-table-count mu4e~mark-map))) - (mu4e-error "Nothing is marked")) + (mu4e-warn "Nothing is marked")) (maphash (lambda (docid val) (save-excursion diff --git a/mu4e/mu4e-utils.el b/mu4e/mu4e-utils.el index 5aeb9d82..c6dfbcb7 100644 --- a/mu4e/mu4e-utils.el +++ b/mu4e/mu4e-utils.el @@ -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." ((eq major-mode 'mu4e-view-mode) mu4e~view-msg)))) (if (and (null msg) raise-err) - (mu4e-error "No message at point") + (mu4e-warn "No message at point") msg))) (defun mu4e-field-at-point (field) @@ -545,7 +552,7 @@ process." "Handler function for showing an error." ;; don't use mu4e-error here; it's running in the process filter ctx (case errcode - (4 (error "No matches for this search query.")) + (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 #'(lambda (x) (cond ((> x n) - (mu4e-error "Attachment %d bigger than maximum (%d)" x n)) + (mu4e-warn "Attachment %d bigger than maximum (%d)" x n)) ((< x 1) - (mu4e-error "Attachment number must be greater than 0 (%d)" x)))) + (mu4e-warn "Attachment number must be greater than 0 (%d)" x)))) list))) diff --git a/mu4e/mu4e-view.el b/mu4e/mu4e-view.el index 8cfda623..118b54f1 100644 --- a/mu4e/mu4e-view.el +++ b/mu4e/mu4e-view.el @@ -1121,7 +1121,7 @@ user that unmarking only works in the header list." "Go to a numbered url." (interactive "n[mu4e] Visit url with number: ") (let ((url (gethash num mu4e~view-link-map))) - (unless url (mu4e-error "Invalid number for URL")) + (unless url (mu4e-warn "Invalid number for URL")) (funcall (mu4e~view-browse-url-func url)))) (defconst mu4e~view-raw-buffer-name "*mu4e-raw-view*"