diff --git a/TODO b/TODO index 9ad7d677..22f4f2f9 100644 --- a/TODO +++ b/TODO @@ -36,21 +36,14 @@ - restore point after rerunning a search - make the mu4e-bookmarks format similar to the other ones - refresh current query after update? - - + - fix mu4e-mark-set to work from the view buffer as well ** Done (0.8.9.6) - opening urls is too eager (now use M-RET for opening url at point, not just RET, which conflicted with using RET for scrolling) - - - - - - - - + - document quoting of queries + - use mu-error ** Done (0.8.9.5) diff --git a/emacs/mu4e-actions.el b/emacs/mu4e-actions.el index 25a1457e..e0093bd0 100644 --- a/emacs/mu4e-actions.el +++ b/emacs/mu4e-actions.el @@ -54,7 +54,7 @@ headers view and message-view." "Convert the message to pdf, then show it. Works for the message view." (unless (file-executable-p mu4e-msg2pdf) - (error "msg2pdf not found; please set `mu4e-msg2pdf'")) + (mu4e-error "msg2pdf not found; please set `mu4e-msg2pdf'")) (let* ((pdf (shell-command-to-string (concat mu4e-msg2pdf " " @@ -64,7 +64,7 @@ view." (substring pdf 0 -1)))) ;; chop \n (unless (and pdf (file-exists-p pdf)) (message "==> %S %S" pdf (mu4e-msg-field msg :path)) - (error "Failed to create PDF file")) + (mu4e-error "Failed to create PDF file")) (find-file pdf))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -77,7 +77,7 @@ view." the browser to use with the variable `browse-url-generic-program'." (let ((html (mu4e-msg-field msg :body-html)) (tmpfile (format "%s/%d.html" temporary-file-directory (random)))) - (unless html (error "No html part for this message")) + (unless html (mu4e-error "No html part for this message")) (with-temp-file tmpfile (insert html) (save-buffer) @@ -94,7 +94,7 @@ the browser to use with the variable `browse-url-generic-program'." (defun mu4e-action-message-to-speech (msg) "Pronounce the message text using `mu4e-text2speech-command'." (unless (mu4e-msg-field msg :body-txt) - (error "No text body for this message")) + (mu4e-error "No text body for this message")) (with-temp-buffer (insert (mu4e-msg-field msg :body-txt)) (shell-command-on-region (point-min) (point-max) @@ -135,10 +135,10 @@ with `mu4e-compose-attach-captured-message'." current message (in headers or view). You need to set `mu4e-org-contacts-file' to the full path to the file where you store your org-contacts." - (unless (require 'org-capture nil 'noerror) - (error "org-capture is not available.")) + (unless (require 'org-capture nil 'nomu4e-error) + (mu4e-error "org-capture is not available.")) (unless mu4e-org-contacts-file - (error "`mu4e-org-contacts-file' is not defined.")) + (mu4e-error "`mu4e-org-contacts-file' is not defined.")) (let* ((sender (car-safe (mu4e-msg-field msg :from))) (name (car-safe sender)) (email (cdr-safe sender)) (blurb diff --git a/emacs/mu4e-compose.el b/emacs/mu4e-compose.el index 71e25967..6a07485e 100644 --- a/emacs/mu4e-compose.el +++ b/emacs/mu4e-compose.el @@ -79,10 +79,10 @@ replying to messages." "Insert the last captured message file as an attachment." (interactive) (unless mu4e-captured-message - (error "No message has been captured")) + (mu4e-error "No message has been captured")) (let ((path (plist-get mu4e-captured-message :path))) (unless (file-exists-p path) - (error "Captured message file not found")) + (mu4e-error "Captured message file not found")) (mml-attach-file path "application/octet-stream" @@ -214,7 +214,7 @@ message. Return nil if there are no recipients for the particular field." (:cc (mu4e~compose-create-cc-lst origmsg reply-all)) (otherwise - (error "Unsupported field"))))) + (mu4e-error "Unsupported field"))))) (defun mu4e~compose-from-construct () @@ -368,7 +368,7 @@ use the new docid. Returns the full path to the new message." (reply (mu4e~compose-reply-construct msg)) (forward (mu4e~compose-forward-construct msg)) (new (mu4e~compose-newmsg-construct)) - (t (error "unsupported compose-type %S" compose-type))))) + (t (mu4e-error "unsupported compose-type %S" compose-type))))) (when str (with-current-buffer (find-file-noselect draft) (insert str))) @@ -396,7 +396,7 @@ needed, set the Fcc header, and register the handler function." (trash mu4e-trash-folder) (sent mu4e-sent-folder) (otherwise - (error "unsupported value '%S' `mu4e-sent-messages-behavior'." + (mu4e-error "unsupported value '%S' `mu4e-sent-messages-behavior'." mu4e-sent-messages-behavior)))) (fccfile (and mdir (concat mu4e-maildir mdir "/cur/" @@ -555,15 +555,15 @@ The initial STR would be created from either `mu4e~compose-reply-construct', ar`mu4e~compose-forward-construct' or `mu4e~compose-newmsg-construct'. The editing buffer is using Gnus' `message-mode'." - (unless mu4e-maildir (error "mu4e-maildir not set")) - (unless mu4e-drafts-folder (error "mu4e-drafts-folder not set")) + (unless mu4e-maildir (mu4e-error "mu4e-maildir not set")) + (unless mu4e-drafts-folder (mu4e-error "mu4e-drafts-folder not set")) (let ((inhibit-read-only t) (draft (if (member compose-type '(reply forward new)) (mu4e~compose-open-new-draft-file compose-type original-msg) (if (eq compose-type 'edit) (plist-get original-msg :path) - (error "unsupported compose-type %S" compose-type))))) + (mu4e-error "unsupported compose-type %S" compose-type))))) (find-file draft) ;; insert mail-header-separator, which is needed by message mode to separate ;; headers and body. will be removed before saving to disk @@ -661,7 +661,7 @@ a symbol, one of `reply', `forward', `edit', `new'. All but `new' take the message at point as input. Symbol `edit' is only allowed for draft messages." (unless (member compose-type '(reply forward edit new)) - (error "Invalid compose type '%S'" compose-type)) + (mu4e-error "Invalid compose type '%S'" compose-type)) ;; 'new is special, since it takes no existing message as arg therefore, ;; we don't need to call thec backend, and call the handler *directly* (if (eq compose-type 'new) @@ -673,7 +673,7 @@ for draft messages." ;; the current line instead (unless (or (not (eq compose-type 'edit)) (member 'draft (mu4e-field-at-point :flags))) - (error "Editing is only allowed for draft messages")) + (mu4e-error "Editing is only allowed for draft messages")) ;; if there's a visible view window, select that before starting ;; composing a new message, so that one will be replaced by the ;; compose window. The 10-or-so line headers buffer is not a good way diff --git a/emacs/mu4e-headers.el b/emacs/mu4e-headers.el index d4a2362f..7463269b 100644 --- a/emacs/mu4e-headers.el +++ b/emacs/mu4e-headers.el @@ -292,7 +292,7 @@ if provided, or at the end of the buffer otherwise." (:date (format-time-string mu4e-headers-date-format val)) (:flags (mu4e-flags-to-string val)) (:size (mu4e-display-size val)) - (t (error "Unsupported header field (%S)" field))))) + (t (mu4e-error "Unsupported header field (%S)" field))))) (when str (if (not width) str @@ -534,7 +534,6 @@ after the end of the search results." (name (plist-get info :shortname)) (help (plist-get info :help)) (width (cdr item))) - (message "%S %S" item info) (concat (propertize (if width @@ -632,12 +631,12 @@ with DOCID which must be present in the headers buffer." (with-current-buffer mu4e~headers-buffer (let ((inhibit-read-only t) (oldpoint (point))) (unless (mu4e~headers-goto-docid docid) - (error "Cannot find message with docid %S" docid)) + (mu4e-error "Cannot find message with docid %S" docid)) ;; now, we're at the beginning of the header, looking at ;; \004 ;; (which is invisible). jump past that… (unless (re-search-forward mu4e~headers-docid-post nil t) - (error "Cannot find the `mu4e~headers-docid-post' separator")) + (mu4e-error "Cannot find the `mu4e~headers-docid-post' separator")) ;; clear old marks, and add the new ones. (let ((msg (get-text-property (point) 'msg))) @@ -653,7 +652,7 @@ with DOCID which must be present in the headers buffer." (defun mu4e~headers-add-header (str docid point &optional msg) "Add header STR with DOCID to the buffer at POINT if non-nil, or at (point-max) otherwise. If MSG is not nil, add it as the text-property `msg'." - (unless docid (error "Invalid message")) + (unless docid (mu4e-error "Invalid message")) (when (buffer-live-p mu4e~headers-buffer) (with-current-buffer mu4e~headers-buffer (let ((inhibit-read-only t) @@ -676,7 +675,7 @@ non-nill, don't raise an error when the docid is not found." (let ((inhibit-read-only t)) (delete-region (line-beginning-position) (line-beginning-position 2))) (unless ignore-missing - (error "Cannot find message with docid %S" docid))))) + (mu4e-error "Cannot find message with docid %S" docid))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun mu4e~headers-update-global-mode-string () "Determine the mode string for the headers buffers (based on the @@ -729,7 +728,7 @@ the query history stack." of `mu4e-split-view', and return a window for the message view." (mu4e-hide-other-mu4e-buffers) (unless (buffer-live-p mu4e~headers-buffer) - (error "No headers buffer available")) + (mu4e-error "No headers buffer available")) (switch-to-buffer mu4e~headers-buffer) ;; kill the existing view win (when (buffer-live-p mu4e~view-buffer) @@ -810,8 +809,10 @@ matching messages with that mark." (defun mu4e~headers-get-thread-info (msg what) "Get WHAT (a symbol, either path or thread-id) for MSG." - (let* ((thread (or (plist-get msg :thread) (error "No thread info found"))) - (path (or (plist-get thread :path) (error "No threadpath found")))) + (let* ((thread (or (plist-get msg :thread) + (mu4e-error "No thread info found"))) + (path (or (plist-get thread :path) + (mu4e-error "No threadpath found")))) (case what (path path) (thread-id @@ -819,7 +820,7 @@ matching messages with that mark." ;; the thread id is the first segment of the thread path (when (string-match "^\\([[:xdigit:]]+\\):?" path) (match-string 1 path)))) - (otherwise (error "Not supported"))))) + (otherwise (mu4e-error "Not supported"))))) (defun mu4e-headers-mark-thread (&optional subthread) @@ -899,11 +900,11 @@ to get it from; it's a symbol, either 'future or 'past." (case whence (past (unless mu4e~headers-query-past - (error "No more previous queries")) + (mu4e-error "No more previous queries")) (pop mu4e~headers-query-past)) (future (unless mu4e~headers-query-future - (error "No more next queries")) + (mu4e-error "No more next queries")) (pop mu4e~headers-query-future)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -964,7 +965,7 @@ the last search expression." nil 'mu4e~headers-search-hist nil t))) (list filter))) (unless mu4e~headers-last-query - (error "There's nothing to filter")) + (mu4e-error "There's nothing to filter")) (mu4e-headers-search (format "(%s) AND %s" mu4e~headers-last-query filter))) @@ -1039,12 +1040,12 @@ value of `mu4e-split-view': if it's a symbol `horizontal' or current window. " (interactive) (unless (eq major-mode 'mu4e-headers-mode) - (error "Must be in mu4e-headers-mode (%S)" major-mode)) + (mu4e-error "Must be in mu4e-headers-mode (%S)" major-mode)) (let* ((docid (or (mu4e~headers-docid-at-point) - (error "No message at point"))) + (mu4e-error "No message at point"))) (viewwin (mu4e~headers-redraw-get-view-window))) (unless (window-live-p viewwin) - (error "Cannot get a message view")) + (mu4e-error "Cannot get a message view")) (select-window viewwin) (switch-to-buffer (mu4e~headers-get-loading-buf)) (mu4e~proc-view docid mu4e-view-show-images))) @@ -1088,7 +1089,7 @@ determines where the query is taken from and is a symbol, either backward (if LINES is negative). If this succeeds, return the new docid. Otherwise, return nil." (unless (eq major-mode 'mu4e-headers-mode) - (error "Must be in mu4e-headers-mode (%S)" major-mode)) + (mu4e-error "Must be in mu4e-headers-mode (%S)" major-mode)) (let ((succeeded (zerop (forward-line lines))) (docid (mu4e~headers-docid-at-point))) ;; move point, even if this function is called when this window is not @@ -1142,12 +1143,14 @@ N. Otherwise, don't do anything." (horizontal (let ((newval (+ (or n 1) mu4e-headers-visible-lines))) (unless (> newval 0) - (error "Cannot make the number of visible lines any smaller")) + (mu4e-error + "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) - (error "Cannot make the number of visible columns any smaller")) + (mu4e-error + "Cannot make the number of visible columns any smaller")) (setq mu4e-headers-visible-columns newval)))) (let ((viewwin (mu4e~headers-redraw-get-view-window))) (when (window-live-p viewwin) @@ -1181,7 +1184,7 @@ region if there is a region, then move to the next message." to ensure we don't disturb other windows." (interactive) (unless (eq major-mode 'mu4e-headers-mode) - (error "Must be in mu4e-headers-mode (%S)" major-mode)) + (mu4e-error "Must be in mu4e-headers-mode (%S)" major-mode)) (mu4e-mark-handle-when-leaving) (let ((curbuf (current-buffer)) (curwin (selected-window)) (headers-visible)) diff --git a/emacs/mu4e-main.el b/emacs/mu4e-main.el index 4c3f5388..e0b617af 100644 --- a/emacs/mu4e-main.el +++ b/emacs/mu4e-main.el @@ -142,7 +142,7 @@ clicked." "Toggle sending mail mode, either queued or direct." (interactive) (unless (file-directory-p smtpmail-queue-dir) - (error "`smtp-queue-dir' does not exist")) + (mu4e-error "`smtp-queue-dir' does not exist")) (setq smtpmail-queue-mail (not smtpmail-queue-mail)) (message (concat "Outgoing mail will now be " diff --git a/emacs/mu4e-mark.el b/emacs/mu4e-mark.el index c6a4c976..e0327174 100644 --- a/emacs/mu4e-mark.el +++ b/emacs/mu4e-mark.el @@ -101,7 +101,7 @@ The following marks are available, and the corresponding props: `deferred' n mark this message for *something* (decided later) `unmark' n unmark this message" (interactive) - (let* ((docid (mu4e~headers-docid-at-point)) + (let* ((docid (mu4e-field-at-point :docid)) ;; get a cell with the mark char and the 'target' 'move' already has a ;; target (the target folder) the other ones get a pseudo "target", as ;; info for the user. @@ -116,10 +116,12 @@ The following marks are available, and the corresponding props: (unflag '("-" . "unflag")) (deferred '("*" . "deferred")) (unmark '(" " . nil)) - (otherwise (error "Invalid mark %S" mark)))) + (otherwise (mu4e-error "Invalid mark %S" mark)))) (markkar (car markcell)) (target (cdr markcell))) - (unless docid (error "No message on this line")) + (unless docid (mu4e-error "No message on this line")) + (unless (eq major-mode 'mu4e-headers-mode) + (mu4e-error "Not in headers-mode")) (save-excursion (when (mu4e~headers-mark docid markkar) ;; update the hash -- remove everything current, and if add the new stuff, @@ -172,8 +174,7 @@ headers in the region." the region, for moving to maildir TARGET. If target is not provided, function asks for it." (interactive) - (unless (mu4e~headers-docid-at-point) - (error "No message at point.")) + (mu4e-field-at-point :docid) ;; will raise an error if there is none (let* ((target (or target (mu4e-ask-maildir "Move message to: "))) (target (if (string= (substring target 0 1) "/") target @@ -259,10 +260,10 @@ If NO-CONFIRMATION is non-nil, don't ask user for confirmation." (unflag (mu4e~proc-move docid nil "-F-N")) (trash (unless mu4e-trash-folder - (error "`mu4e-trash-folder' not set")) + (mu4e-error "`mu4e-trash-folder' not set")) (mu4e~proc-move docid mu4e-trash-folder "+T-N")) (delete (mu4e~proc-remove docid)) - (otherwise (error "Unrecognized mark %S" mark))))) + (otherwise (mu4e-error "Unrecognized mark %S" mark))))) mu4e~mark-map)) (mu4e-mark-unmark-all) (message nil)))) @@ -271,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))) - (error "Nothing is marked")) + (mu4e-error "Nothing is marked")) (maphash (lambda (docid val) (save-excursion diff --git a/emacs/mu4e-proc.el b/emacs/mu4e-proc.el index b66cabf8..7bab0339 100644 --- a/emacs/mu4e-proc.el +++ b/emacs/mu4e-proc.el @@ -58,7 +58,7 @@ the length (in hex).") (defun mu4e~proc-start () "Start the mu server process." (unless (file-executable-p mu4e-mu-binary) - (error (format "`mu4e-mu-binary' (%S) not found" mu4e-mu-binary))) + (mu4e-error (format "`mu4e-mu-binary' (%S) not found" mu4e-mu-binary))) (let* ((process-connection-type nil) ;; use a pipe (args '("server")) (args (append args (when mu4e-mu-home @@ -358,7 +358,7 @@ The results are reported through either (:update ... ) or (:error ) sexp, which are handled my `mu4e-update-func' and `mu4e-error-func', respectively." (unless (or maildir flags) - (error "At least one of maildir and flags must be specified")) + (mu4e-error "At least one of maildir and flags must be specified")) (let* ((idparam (mu4e--docid-msgid-param docid-or-msgid)) (flagstr (when flags @@ -409,9 +409,9 @@ for type `new'. The result will be delivered to the function registered as `mu4e-compose-func'." (unless (member type '(forward reply edit new)) - (error "Unsupported compose-type %S" type)) + (mu4e-error "Unsupported compose-type %S" type)) (unless (eq (null docid) (eq type 'new)) - (error "`new' implies docid not-nil, and vice-versa")) + (mu4e-error "`new' implies docid not-nil, and vice-versa")) (mu4e~proc-send-command "compose type:%s docid:%d" (symbol-name type) docid)) @@ -437,7 +437,7 @@ mean: (temp (format "action:temp docid:%d index:%d what:%s param:\"%s\"" docid partidx what param)) - (otherwise (error "Unsupported action %S" action)))))) + (otherwise (mu4e-error "Unsupported action %S" action)))))) (mu4e~proc-send-command cmd))) diff --git a/emacs/mu4e-utils.el b/emacs/mu4e-utils.el index 747df150..0843208b 100644 --- a/emacs/mu4e-utils.el +++ b/emacs/mu4e-utils.el @@ -54,16 +54,18 @@ e-mail message (if there is any." "Offer to create DIR if it does not exist yet. Return t if the dir already existed, or has been created, nil otherwise." (if (and (file-exists-p dir) (not (file-directory-p dir))) - (error "%s exists, but is not a directory." dir)) + (mu4e-error "%s exists, but is not a directory." dir)) (cond ((file-directory-p dir) t) ((yes-or-no-p (mu4e-format "%s does not exist yes. Create now?" dir)) (mu4e~proc-mkdir dir)) (t nil))) - + (defun mu4e-format (frm &rest args) "Create [mu4e]-prefixed string based on format FRM and ARGS." - (concat "[" mu4e-logo "] " (apply 'format frm args))) + (concat + "[" (propertize "mu4e" 'face 'mu4e-title-face) "] " + (apply 'format frm args))) (defun mu4e-message (frm &rest args) "Like `message', but prefixed with mu4e. If we're waiting for @@ -71,6 +73,11 @@ user-input, don't show anyhting." (unless (waiting-for-user-input-p) (message "%s" (apply 'mu4e-format frm args)))) +(defun mu4e-error (frm &rest args) + "Create [mu4e]-prefixed error based on format FRM and ARGS." + (mu4e-log 'error (apply 'mu4e-format frm args)) + (message "%s" (apply 'mu4e-format frm args))) + (defun mu4e~read-char-choice (prompt choices) "Compatiblity wrapper for `read-char-choice', which is emacs-24 only." @@ -110,7 +117,7 @@ Function will return the cdr of the list element." (lambda (option) ;; try to detect old-style options, and warn (when (characterp (car-safe (cdr-safe option))) - (error (concat "Please use the new format for options/actions; " + (mu4e-error (concat "Please use the new format for options/actions; " "see the manual"))) (let* ((kar (substring (car option) 0 1)) (val (cdr option))) @@ -128,7 +135,7 @@ Function will return the cdr of the list element." (find-if (lambda (option) (eq response (string-to-char (car option)))) options))) - (unless chosen (error "%S not found" response)) + (unless chosen (mu4e-error "%S not found" response)) (cdr chosen))) @@ -180,7 +187,7 @@ list of maildirs will not change until you restart mu4e." name. If the special shortcut 'o' (for _o_ther) is used, or if `mu4e-maildir-shortcuts is not defined, let user choose from all maildirs under `mu4e-maildir." - (unless mu4e-maildir (error "`mu4e-maildir' is not defined")) + (unless mu4e-maildir (mu4e-error "`mu4e-maildir' is not defined")) (let ((prompt (mu4e-format "%s" prompt))) (if (not mu4e-maildir-shortcuts) (ido-completing-read prompt @@ -201,7 +208,7 @@ maildirs under `mu4e-maildir." (ido-completing-read prompt (mu4e-get-maildirs mu4e-maildir)) (or (car-safe (find-if (lambda (item) (= kar (cdr item))) mu4e-maildir-shortcuts)) - (error "Invalid shortcut '%c'" kar))))))) + (mu4e-error "Invalid shortcut '%c'" kar))))))) (defun mu4e-ask-maildir-check-exists (prompt) @@ -222,7 +229,7 @@ the region, for moving to maildir TARGET. If target is not provided, function asks for it." (interactive) (unless (mu4e~headers-docid-at-point) - (error "No message at point.")) + (mu4e-error "No message at point.")) (let* ((target (or target (mu4e-ask-maildir "Move message to: "))) (target (if (string= (substring target 0 1) "/") target @@ -238,7 +245,7 @@ provided, function asks for it." (defun mu4e-ask-bookmark (prompt &optional kar) "Ask the user for a bookmark (using PROMPT) as defined in `mu4e-bookmarks', then return the corresponding query." - (unless mu4e-bookmarks (error "`mu4e-bookmarks' is not defined")) + (unless mu4e-bookmarks (mu4e-error "`mu4e-bookmarks' is not defined")) (let* ((prompt (mu4e-format "%s" prompt)) (bmarks (mapconcat @@ -262,7 +269,7 @@ KAR, or raise an error if none is found." mu4e-bookmarks))) (if chosen-bm (nth 0 chosen-bm) - (error "Invalid shortcut '%c'" kar)))) + (mu4e-error "Invalid shortcut '%c'" kar)))) ;;; converting flags->string and vice-versa ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -451,7 +458,7 @@ there is no message at point." ((eq major-mode 'mu4e-view-mode) mu4e~view-msg)))) (if (and (null msg) raise-err) - (error "No message at point") + (mu4e-error "No message at point") msg))) (defun mu4e-field-at-point (field) @@ -536,7 +543,7 @@ and update the database afterwards, and show the progress in a split-window." (interactive) (unless mu4e-get-mail-command - (error "`mu4e-get-mail-command' is not defined")) + (mu4e-error "`mu4e-get-mail-command' is not defined")) ;; delete any old update buffer (when (buffer-live-p mu4e~update-buffer-name) (with-current-buffer mu4e~update-buffer-name @@ -581,27 +588,27 @@ This is used by the completion function in mu4e-compose." (defun mu4e~check-requirements () "Check for the settings required for running mu4e." (unless (and mu4e-mu-binary (file-executable-p mu4e-mu-binary)) - (error "Please set `mu4e-mu-binary' to the full path to the mu + (mu4e-error "Please set `mu4e-mu-binary' to the full path to the mu binary.")) (unless mu4e-maildir - (error "Please set `mu4e-maildir' to the full path to your + (mu4e-error "Please set `mu4e-maildir' to the full path to your Maildir directory.")) ;; expand mu4e-maildir, mu4e-attachment-dir (setq mu4e-maildir (expand-file-name mu4e-maildir) mu4e-attachment-dir (expand-file-name mu4e-attachment-dir)) (unless (mu4e-create-maildir-maybe mu4e-maildir) - (error "%s is not a valid maildir directory" mu4e-maildir)) + (mu4e-error "%s is not a valid maildir directory" mu4e-maildir)) (dolist (var '( mu4e-sent-folder mu4e-drafts-folder mu4e-trash-folder)) (unless (and (boundp var) (symbol-value var)) - (error "Please set %S" var)) + (mu4e-error "Please set %S" var)) (let* ((dir (symbol-value var)) (path (concat mu4e-maildir dir))) (unless (string= (substring dir 0 1) "/") - (error "%S must start with a '/'" dir)) + (mu4e-error "%S must start with a '/'" dir)) (unless (mu4e-create-maildir-maybe path) - (error "%s (%S) does not exist" path var))))) + (mu4e-error "%s (%S) does not exist" path var))))) (defun mu4e~start (&optional func) @@ -617,14 +624,14 @@ FUNC (if non-nil) afterwards." ;; explicit version checks are a bit questionable, ;; better to check for specific features (unless (>= emacs-major-version 23) - (error "Emacs >= 23.x is required for mu4e")) + (mu4e-error "Emacs >= 23.x is required for mu4e")) ;; set up the 'pong' handler func (lexical-let ((func func)) (setq mu4e-pong-func (lambda (version doccount) (unless (string= version mu4e-mu-version) - (error "mu server has version %s, but we need %s" + (mu4e-error "mu server has version %s, but we need %s" version mu4e-mu-version)) (when func (funcall func)) (when (and mu4e-update-interval (null mu4e-update-timer)) @@ -676,7 +683,7 @@ discarded if nil. After retrieving mail, update the database. Note, function is asynchronous, returns (almost) immediately, and all the processing takes part in the background, unless buf is non-nil." (unless mu4e-get-mail-command - (error "`mu4e-get-mail-command' is not defined")) + (mu4e-error "`mu4e-get-mail-command' is not defined")) (let* ((process-connection-type t) (proc (start-process-shell-command mu4e-update-mail-name buf mu4e-get-mail-command))) @@ -723,13 +730,15 @@ either 'to-server, 'from-server or 'misc. This function is meant for debugging." (from-server 'font-lock-type-face) (to-server 'font-lock-function-name-face) (misc 'font-lock-variable-name-face) - (otherwise (error "Unsupported log type")))) + (error 'font-lock-warning-face) + (otherwise (mu4e-error "Unsupported log type")))) (msg (propertize (apply 'format frm args) 'face msg-face))) (goto-char (point-max)) (insert tstamp (case type (from-server " <- ") - (to-server " -> " ) + (to-server " -> ") + (error " !! ") (otherwise " ")) msg "\n") @@ -763,7 +772,7 @@ mu4e logs some of its internal workings to a log-buffer. See (interactive) (let ((buf (get-buffer mu4e~log-buffer-name))) (unless (buffer-live-p buf) - (error "No debug log available")) + (mu4e-error "No debug log available")) (switch-to-buffer buf))) @@ -794,9 +803,9 @@ This includes expanding e.g. 3-5 into 3,4,5. If the letter #'(lambda (x) (cond ((> x n) - (error "Attachment %d bigger than maximum (%d)" x n)) + (mu4e-error "Attachment %d bigger than maximum (%d)" x n)) ((< x 1) - (error "Attachment number must be greater than 0 (%d)" x)))) + (mu4e-error "Attachment number must be greater than 0 (%d)" x)))) list))) diff --git a/emacs/mu4e-vars.el b/emacs/mu4e-vars.el index c2b7a143..d5e63b7f 100644 --- a/emacs/mu4e-vars.el +++ b/emacs/mu4e-vars.el @@ -337,17 +337,9 @@ headers)." :group 'mu4e-faces) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; internal variables / constants - -(defconst mu4e-logo - (propertize "mu4e" 'face 'mu4e-title-face) - "A propertized string for the mu4e 'logo'.") -(defconst mu4e-prefix - (concat "[" mu4e-logo "]") - "Prefix for mu4e minibuffer input.") - + +;; headers info (defconst mu4e-header-info '( (:attachments . ( :name "Attachments" @@ -410,11 +402,9 @@ list, and the fields the message view). Most fields should be self-explanatory. A special one is `:from-or-to', which is equal to `:from' unless `:from' matches `mu4e-user-mail-address-regexp', in which case it will be equal to `:to'.") - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; run-time vars used in multiple places @@ -441,7 +431,7 @@ mu4e starts.") ;; from the server (defun mu4e~default-handler (&rest args) "*internal* Dummy handler function." - (error "Not handled: %S" args)) + (mu4e-error "Not handled: %S" args)) (defvar mu4e-error-func 'mu4e~default-handler "A function called for each error returned from the server diff --git a/emacs/mu4e-view.el b/emacs/mu4e-view.el index 01fad4f0..cae625ec 100644 --- a/emacs/mu4e-view.el +++ b/emacs/mu4e-view.el @@ -193,7 +193,7 @@ plist." (if sizestr (mu4e~view-construct-header field sizestr)))) ;; attachments (:attachments (mu4e~view-construct-attachments msg)) - (t (error "Unsupported field: %S" field))))) + (t (mu4e-error "Unsupported field: %S" field))))) mu4e-view-fields "") "\n" (mu4e-body-text msg))) @@ -668,12 +668,12 @@ number them so they can be opened using `mu4e-view-go-to-url'." current message." `(progn (unless '(buffer-live-p mu4e~view-headers-buffer) - (error "no headers-buffer connected")) + (mu4e-error "no headers-buffer connected")) (let* ((docid (mu4e-field-at-point :docid))) (with-current-buffer mu4e~view-headers-buffer (if (and docid (mu4e~headers-goto-docid docid)) ,@body - (error "cannot find corresponding message in headers + (mu4e-error "cannot find corresponding message in headers buffer.")))))) (defun mu4e-view-headers-next(&optional n) @@ -775,7 +775,7 @@ all messages in the thread at point in the headers view." attachment numbers, as per `mu4e-split-ranges-to-numbers', and return the corresponding string." (let* ((count (hash-table-count mu4e~view-attach-map)) (def)) - (when (zerop count) (error "No attachments for this message")) + (when (zerop count) (mu4e-error "No attachments for this message")) (if (not multi) (if (= count 1) (read-number (mu4e-format "%s: " prompt) 1) @@ -799,7 +799,7 @@ number ATTNUM." message-at-point if nil) to disk." (interactive) (unless mu4e-attachment-dir - (error "`mu4e-attachment-dir' is not set")) + (mu4e-error "`mu4e-attachment-dir' is not set")) (let* ((msg (or msg (mu4e-message-at-point))) (attnum (or attnum (mu4e~view-get-attach-num "Attachment to save" msg))) @@ -932,7 +932,7 @@ attachments) in response to a (mu4e~proc-extract 'temp ... )." ;; make the buffer read-only since it usually does not make ;; sense to edit the temp buffer; use C-x C-q if you insist... (setq buffer-read-only t)) - (t (error "Unsupported action %S" what)))) + (t (mu4e-error "Unsupported action %S" what)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; marking @@ -1015,7 +1015,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 (error "Invalid number for URL")) + (unless url (mu4e-error "Invalid number for URL")) (funcall (mu4e~view-browse-url-func url)))) (defconst mu4e~view-raw-buffer-name "*mu4e-raw-view*" @@ -1027,7 +1027,7 @@ user that unmarking only works in the header list." (let ((path (mu4e-field-at-point :path)) (buf (get-buffer-create mu4e~view-raw-buffer-name))) (unless (and path (file-readable-p path)) - (error "Not a readable file: %S" path)) + (mu4e-error "Not a readable file: %S" path)) (with-current-buffer buf (let ((inhibit-read-only t)) (erase-buffer) @@ -1048,7 +1048,7 @@ the results." ensure we don't disturb other windows." (interactive) (unless (eq major-mode 'mu4e-view-mode) - (error "Must be in mu4e-view-mode (%S)" major-mode)) + (mu4e-error "Must be in mu4e-view-mode (%S)" major-mode)) (let ((curbuf (current-buffer)) (curwin (selected-window)) (headers-win)) (walk-windows diff --git a/emacs/org-mu4e.el b/emacs/org-mu4e.el index 31a41a2d..cefdabad 100644 --- a/emacs/org-mu4e.el +++ b/emacs/org-mu4e.el @@ -196,7 +196,7 @@ mode." (add-hook 'post-command-hook 'org~mu4e-mime-switch-headers-or-body t t) (let ((func (lookup-key (current-local-map) keyseq))) (unless (functionp func) - (error "Invalid key binding")) + (mu4e-error "Invalid key binding")) (add-hook 'message-send-hook 'org~mu4e-mime-convert-to-html-maybe t t) (funcall func))) @@ -219,7 +219,7 @@ or org-mode (when in the body)," (org-mode) (add-hook 'before-save-hook (lambda () - (error "Switch to mu4e-compose-mode (M-m) before saving.")) nil t) + (mu4e-error "Switch to mu4e-compose-mode (M-m) before saving.")) nil t) (org~mu4e-mime-decorate-headers) (local-set-key (kbd "M-m") (lambda (key) @@ -242,9 +242,9 @@ or org-mode (when in the body)," body using org-mode." (interactive) (unless (member major-mode '(org-mode mu4e-compose-mode)) - (error "Need org-mode or mu4e-compose-mode")) + (mu4e-error "Need org-mode or mu4e-compose-mode")) (unless (executable-find "dvipng") - (error "Required program dvipng not found")) + (mu4e-error "Required program dvipng not found")) ;; we can check if we're already in mu4e-compose-mode by checking ;; if the post-command-hook is set; hackish... (if (not (member 'org~mu4e-mime-switch-headers-or-body post-command-hook))