1
0
mirror of https://github.com/djcb/mu.git synced 2024-06-21 06:56:48 +02:00

* add/use mu4e-error

This commit is contained in:
djcb 2012-07-10 12:11:06 +03:00
parent 129b5ad264
commit 985d5340bc
11 changed files with 109 additions and 113 deletions

13
TODO
View File

@ -36,21 +36,14 @@
- restore point after rerunning a search - restore point after rerunning a search
- make the mu4e-bookmarks format similar to the other ones - make the mu4e-bookmarks format similar to the other ones
- refresh current query after update? - refresh current query after update?
- fix mu4e-mark-set to work from the view buffer as well
** Done (0.8.9.6) ** Done (0.8.9.6)
- opening urls is too eager (now use M-RET for opening url at point, not just - opening urls is too eager (now use M-RET for opening url at point, not just
RET, which conflicted with using RET for scrolling) RET, which conflicted with using RET for scrolling)
- document quoting of queries
- use mu-error
** Done (0.8.9.5) ** Done (0.8.9.5)

View File

@ -54,7 +54,7 @@ headers view and message-view."
"Convert the message to pdf, then show it. Works for the message "Convert the message to pdf, then show it. Works for the message
view." view."
(unless (file-executable-p mu4e-msg2pdf) (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 (let* ((pdf
(shell-command-to-string (shell-command-to-string
(concat mu4e-msg2pdf " " (concat mu4e-msg2pdf " "
@ -64,7 +64,7 @@ view."
(substring pdf 0 -1)))) ;; chop \n (substring pdf 0 -1)))) ;; chop \n
(unless (and pdf (file-exists-p pdf)) (unless (and pdf (file-exists-p pdf))
(message "==> %S %S" pdf (mu4e-msg-field msg :path)) (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))) (find-file pdf)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -77,7 +77,7 @@ view."
the browser to use with the variable `browse-url-generic-program'." the browser to use with the variable `browse-url-generic-program'."
(let ((html (mu4e-msg-field msg :body-html)) (let ((html (mu4e-msg-field msg :body-html))
(tmpfile (format "%s/%d.html" temporary-file-directory (random)))) (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 (with-temp-file tmpfile
(insert html) (insert html)
(save-buffer) (save-buffer)
@ -94,7 +94,7 @@ the browser to use with the variable `browse-url-generic-program'."
(defun mu4e-action-message-to-speech (msg) (defun mu4e-action-message-to-speech (msg)
"Pronounce the message text using `mu4e-text2speech-command'." "Pronounce the message text using `mu4e-text2speech-command'."
(unless (mu4e-msg-field msg :body-txt) (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 (with-temp-buffer
(insert (mu4e-msg-field msg :body-txt)) (insert (mu4e-msg-field msg :body-txt))
(shell-command-on-region (point-min) (point-max) (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 current message (in headers or view). You need to set
`mu4e-org-contacts-file' to the full path to the file where you `mu4e-org-contacts-file' to the full path to the file where you
store your org-contacts." store your org-contacts."
(unless (require 'org-capture nil 'noerror) (unless (require 'org-capture nil 'nomu4e-error)
(error "org-capture is not available.")) (mu4e-error "org-capture is not available."))
(unless mu4e-org-contacts-file (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))) (let* ((sender (car-safe (mu4e-msg-field msg :from)))
(name (car-safe sender)) (email (cdr-safe sender)) (name (car-safe sender)) (email (cdr-safe sender))
(blurb (blurb

View File

@ -79,10 +79,10 @@ replying to messages."
"Insert the last captured message file as an attachment." "Insert the last captured message file as an attachment."
(interactive) (interactive)
(unless mu4e-captured-message (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))) (let ((path (plist-get mu4e-captured-message :path)))
(unless (file-exists-p path) (unless (file-exists-p path)
(error "Captured message file not found")) (mu4e-error "Captured message file not found"))
(mml-attach-file (mml-attach-file
path path
"application/octet-stream" "application/octet-stream"
@ -214,7 +214,7 @@ message. Return nil if there are no recipients for the particular field."
(:cc (:cc
(mu4e~compose-create-cc-lst origmsg reply-all)) (mu4e~compose-create-cc-lst origmsg reply-all))
(otherwise (otherwise
(error "Unsupported field"))))) (mu4e-error "Unsupported field")))))
(defun mu4e~compose-from-construct () (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)) (reply (mu4e~compose-reply-construct msg))
(forward (mu4e~compose-forward-construct msg)) (forward (mu4e~compose-forward-construct msg))
(new (mu4e~compose-newmsg-construct)) (new (mu4e~compose-newmsg-construct))
(t (error "unsupported compose-type %S" compose-type))))) (t (mu4e-error "unsupported compose-type %S" compose-type)))))
(when str (when str
(with-current-buffer (find-file-noselect draft) (with-current-buffer (find-file-noselect draft)
(insert str))) (insert str)))
@ -396,7 +396,7 @@ needed, set the Fcc header, and register the handler function."
(trash mu4e-trash-folder) (trash mu4e-trash-folder)
(sent mu4e-sent-folder) (sent mu4e-sent-folder)
(otherwise (otherwise
(error "unsupported value '%S' `mu4e-sent-messages-behavior'." (mu4e-error "unsupported value '%S' `mu4e-sent-messages-behavior'."
mu4e-sent-messages-behavior)))) mu4e-sent-messages-behavior))))
(fccfile (and mdir (fccfile (and mdir
(concat mu4e-maildir mdir "/cur/" (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' `mu4e~compose-reply-construct', ar`mu4e~compose-forward-construct'
or `mu4e~compose-newmsg-construct'. The editing buffer is using or `mu4e~compose-newmsg-construct'. The editing buffer is using
Gnus' `message-mode'." Gnus' `message-mode'."
(unless mu4e-maildir (error "mu4e-maildir not set")) (unless mu4e-maildir (mu4e-error "mu4e-maildir not set"))
(unless mu4e-drafts-folder (error "mu4e-drafts-folder not set")) (unless mu4e-drafts-folder (mu4e-error "mu4e-drafts-folder not set"))
(let ((inhibit-read-only t) (let ((inhibit-read-only t)
(draft (draft
(if (member compose-type '(reply forward new)) (if (member compose-type '(reply forward new))
(mu4e~compose-open-new-draft-file compose-type original-msg) (mu4e~compose-open-new-draft-file compose-type original-msg)
(if (eq compose-type 'edit) (if (eq compose-type 'edit)
(plist-get original-msg :path) (plist-get original-msg :path)
(error "unsupported compose-type %S" compose-type))))) (mu4e-error "unsupported compose-type %S" compose-type)))))
(find-file draft) (find-file draft)
;; insert mail-header-separator, which is needed by message mode to separate ;; insert mail-header-separator, which is needed by message mode to separate
;; headers and body. will be removed before saving to disk ;; 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 take the message at point as input. Symbol `edit' is only allowed
for draft messages." for draft messages."
(unless (member compose-type '(reply forward edit new)) (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, ;; '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* ;; we don't need to call thec backend, and call the handler *directly*
(if (eq compose-type 'new) (if (eq compose-type 'new)
@ -673,7 +673,7 @@ for draft messages."
;; the current line instead ;; the current line instead
(unless (or (not (eq compose-type 'edit)) (unless (or (not (eq compose-type 'edit))
(member 'draft (mu4e-field-at-point :flags))) (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 ;; if there's a visible view window, select that before starting
;; composing a new message, so that one will be replaced by the ;; 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 ;; compose window. The 10-or-so line headers buffer is not a good way

View File

@ -292,7 +292,7 @@ if provided, or at the end of the buffer otherwise."
(:date (format-time-string mu4e-headers-date-format val)) (:date (format-time-string mu4e-headers-date-format val))
(:flags (mu4e-flags-to-string val)) (:flags (mu4e-flags-to-string val))
(:size (mu4e-display-size val)) (:size (mu4e-display-size val))
(t (error "Unsupported header field (%S)" field))))) (t (mu4e-error "Unsupported header field (%S)" field)))))
(when str (when str
(if (not width) (if (not width)
str str
@ -534,7 +534,6 @@ after the end of the search results."
(name (plist-get info :shortname)) (name (plist-get info :shortname))
(help (plist-get info :help)) (help (plist-get info :help))
(width (cdr item))) (width (cdr item)))
(message "%S %S" item info)
(concat (concat
(propertize (propertize
(if width (if width
@ -632,12 +631,12 @@ with DOCID which must be present in the headers buffer."
(with-current-buffer mu4e~headers-buffer (with-current-buffer mu4e~headers-buffer
(let ((inhibit-read-only t) (oldpoint (point))) (let ((inhibit-read-only t) (oldpoint (point)))
(unless (mu4e~headers-goto-docid docid) (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 ;; now, we're at the beginning of the header, looking at
;; <docid>\004 ;; <docid>\004
;; (which is invisible). jump past that… ;; (which is invisible). jump past that…
(unless (re-search-forward mu4e~headers-docid-post nil t) (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. ;; clear old marks, and add the new ones.
(let ((msg (get-text-property (point) 'msg))) (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) (defun mu4e~headers-add-header (str docid point &optional msg)
"Add header STR with DOCID to the buffer at POINT if non-nil, or "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'." 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) (when (buffer-live-p mu4e~headers-buffer)
(with-current-buffer mu4e~headers-buffer (with-current-buffer mu4e~headers-buffer
(let ((inhibit-read-only t) (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)) (let ((inhibit-read-only t))
(delete-region (line-beginning-position) (line-beginning-position 2))) (delete-region (line-beginning-position) (line-beginning-position 2)))
(unless ignore-missing (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 () (defun mu4e~headers-update-global-mode-string ()
"Determine the mode string for the headers buffers (based on the "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." of `mu4e-split-view', and return a window for the message view."
(mu4e-hide-other-mu4e-buffers) (mu4e-hide-other-mu4e-buffers)
(unless (buffer-live-p mu4e~headers-buffer) (unless (buffer-live-p mu4e~headers-buffer)
(error "No headers buffer available")) (mu4e-error "No headers buffer available"))
(switch-to-buffer mu4e~headers-buffer) (switch-to-buffer mu4e~headers-buffer)
;; kill the existing view win ;; kill the existing view win
(when (buffer-live-p mu4e~view-buffer) (when (buffer-live-p mu4e~view-buffer)
@ -810,8 +809,10 @@ matching messages with that mark."
(defun mu4e~headers-get-thread-info (msg what) (defun mu4e~headers-get-thread-info (msg what)
"Get WHAT (a symbol, either path or thread-id) for MSG." "Get WHAT (a symbol, either path or thread-id) for MSG."
(let* ((thread (or (plist-get msg :thread) (error "No thread info found"))) (let* ((thread (or (plist-get msg :thread)
(path (or (plist-get thread :path) (error "No threadpath found")))) (mu4e-error "No thread info found")))
(path (or (plist-get thread :path)
(mu4e-error "No threadpath found"))))
(case what (case what
(path path) (path path)
(thread-id (thread-id
@ -819,7 +820,7 @@ matching messages with that mark."
;; the thread id is the first segment of the thread path ;; the thread id is the first segment of the thread path
(when (string-match "^\\([[:xdigit:]]+\\):?" path) (when (string-match "^\\([[:xdigit:]]+\\):?" path)
(match-string 1 path)))) (match-string 1 path))))
(otherwise (error "Not supported"))))) (otherwise (mu4e-error "Not supported")))))
(defun mu4e-headers-mark-thread (&optional subthread) (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 (case whence
(past (past
(unless mu4e~headers-query-past (unless mu4e~headers-query-past
(error "No more previous queries")) (mu4e-error "No more previous queries"))
(pop mu4e~headers-query-past)) (pop mu4e~headers-query-past))
(future (future
(unless mu4e~headers-query-future (unless mu4e~headers-query-future
(error "No more next queries")) (mu4e-error "No more next queries"))
(pop mu4e~headers-query-future)))) (pop mu4e~headers-query-future))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -964,7 +965,7 @@ the last search expression."
nil 'mu4e~headers-search-hist nil t))) nil 'mu4e~headers-search-hist nil t)))
(list filter))) (list filter)))
(unless mu4e~headers-last-query (unless mu4e~headers-last-query
(error "There's nothing to filter")) (mu4e-error "There's nothing to filter"))
(mu4e-headers-search (mu4e-headers-search
(format "(%s) AND %s" mu4e~headers-last-query filter))) (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. " current window. "
(interactive) (interactive)
(unless (eq major-mode 'mu4e-headers-mode) (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) (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))) (viewwin (mu4e~headers-redraw-get-view-window)))
(unless (window-live-p viewwin) (unless (window-live-p viewwin)
(error "Cannot get a message view")) (mu4e-error "Cannot get a message view"))
(select-window viewwin) (select-window viewwin)
(switch-to-buffer (mu4e~headers-get-loading-buf)) (switch-to-buffer (mu4e~headers-get-loading-buf))
(mu4e~proc-view docid mu4e-view-show-images))) (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 backward (if LINES is negative). If this succeeds, return the new
docid. Otherwise, return nil." docid. Otherwise, return nil."
(unless (eq major-mode 'mu4e-headers-mode) (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))) (let ((succeeded (zerop (forward-line lines)))
(docid (mu4e~headers-docid-at-point))) (docid (mu4e~headers-docid-at-point)))
;; move point, even if this function is called when this window is not ;; move point, even if this function is called when this window is not
@ -1142,12 +1143,14 @@ N. Otherwise, don't do anything."
(horizontal (horizontal
(let ((newval (+ (or n 1) mu4e-headers-visible-lines))) (let ((newval (+ (or n 1) mu4e-headers-visible-lines)))
(unless (> newval 0) (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))) (setq mu4e-headers-visible-lines newval)))
(vertical (vertical
(let ((newval (+ (or n 1) mu4e-headers-visible-columns))) (let ((newval (+ (or n 1) mu4e-headers-visible-columns)))
(unless (> newval 0) (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)))) (setq mu4e-headers-visible-columns newval))))
(let ((viewwin (mu4e~headers-redraw-get-view-window))) (let ((viewwin (mu4e~headers-redraw-get-view-window)))
(when (window-live-p viewwin) (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." to ensure we don't disturb other windows."
(interactive) (interactive)
(unless (eq major-mode 'mu4e-headers-mode) (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) (mu4e-mark-handle-when-leaving)
(let ((curbuf (current-buffer)) (curwin (selected-window)) (let ((curbuf (current-buffer)) (curwin (selected-window))
(headers-visible)) (headers-visible))

View File

@ -142,7 +142,7 @@ clicked."
"Toggle sending mail mode, either queued or direct." "Toggle sending mail mode, either queued or direct."
(interactive) (interactive)
(unless (file-directory-p smtpmail-queue-dir) (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)) (setq smtpmail-queue-mail (not smtpmail-queue-mail))
(message (message
(concat "Outgoing mail will now be " (concat "Outgoing mail will now be "

View File

@ -101,7 +101,7 @@ The following marks are available, and the corresponding props:
`deferred' n mark this message for *something* (decided later) `deferred' n mark this message for *something* (decided later)
`unmark' n unmark this message" `unmark' n unmark this message"
(interactive) (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 ;; 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 ;; target (the target folder) the other ones get a pseudo "target", as
;; info for the user. ;; info for the user.
@ -116,10 +116,12 @@ The following marks are available, and the corresponding props:
(unflag '("-" . "unflag")) (unflag '("-" . "unflag"))
(deferred '("*" . "deferred")) (deferred '("*" . "deferred"))
(unmark '(" " . nil)) (unmark '(" " . nil))
(otherwise (error "Invalid mark %S" mark)))) (otherwise (mu4e-error "Invalid mark %S" mark))))
(markkar (car markcell)) (markkar (car markcell))
(target (cdr 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 (save-excursion
(when (mu4e~headers-mark docid markkar) (when (mu4e~headers-mark docid markkar)
;; update the hash -- remove everything current, and if add the new stuff, ;; 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 the region, for moving to maildir TARGET. If target is not
provided, function asks for it." provided, function asks for it."
(interactive) (interactive)
(unless (mu4e~headers-docid-at-point) (mu4e-field-at-point :docid) ;; will raise an error if there is none
(error "No message at point."))
(let* ((target (or target (mu4e-ask-maildir "Move message to: "))) (let* ((target (or target (mu4e-ask-maildir "Move message to: ")))
(target (if (string= (substring target 0 1) "/") (target (if (string= (substring target 0 1) "/")
target 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")) (unflag (mu4e~proc-move docid nil "-F-N"))
(trash (trash
(unless mu4e-trash-folder (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")) (mu4e~proc-move docid mu4e-trash-folder "+T-N"))
(delete (mu4e~proc-remove docid)) (delete (mu4e~proc-remove docid))
(otherwise (error "Unrecognized mark %S" mark))))) (otherwise (mu4e-error "Unrecognized mark %S" mark)))))
mu4e~mark-map)) mu4e~mark-map))
(mu4e-mark-unmark-all) (mu4e-mark-unmark-all)
(message nil)))) (message nil))))
@ -271,7 +272,7 @@ If NO-CONFIRMATION is non-nil, don't ask user for confirmation."
"Unmark all marked messages." "Unmark all marked messages."
(interactive) (interactive)
(when (or (null mu4e~mark-map) (zerop (hash-table-count mu4e~mark-map))) (when (or (null mu4e~mark-map) (zerop (hash-table-count mu4e~mark-map)))
(error "Nothing is marked")) (mu4e-error "Nothing is marked"))
(maphash (maphash
(lambda (docid val) (lambda (docid val)
(save-excursion (save-excursion

View File

@ -58,7 +58,7 @@ the length (in hex).")
(defun mu4e~proc-start () (defun mu4e~proc-start ()
"Start the mu server process." "Start the mu server process."
(unless (file-executable-p mu4e-mu-binary) (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 (let* ((process-connection-type nil) ;; use a pipe
(args '("server")) (args '("server"))
(args (append args (when mu4e-mu-home (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 or (:error ) sexp, which are handled my `mu4e-update-func' and
`mu4e-error-func', respectively." `mu4e-error-func', respectively."
(unless (or maildir flags) (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)) (let* ((idparam (mu4e--docid-msgid-param docid-or-msgid))
(flagstr (flagstr
(when flags (when flags
@ -409,9 +409,9 @@ for type `new'.
The result will be delivered to the function registered as The result will be delivered to the function registered as
`mu4e-compose-func'." `mu4e-compose-func'."
(unless (member type '(forward reply edit new)) (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)) (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" (mu4e~proc-send-command "compose type:%s docid:%d"
(symbol-name type) docid)) (symbol-name type) docid))
@ -437,7 +437,7 @@ mean:
(temp (temp
(format "action:temp docid:%d index:%d what:%s param:\"%s\"" (format "action:temp docid:%d index:%d what:%s param:\"%s\""
docid partidx what param)) docid partidx what param))
(otherwise (error "Unsupported action %S" action)))))) (otherwise (mu4e-error "Unsupported action %S" action))))))
(mu4e~proc-send-command cmd))) (mu4e~proc-send-command cmd)))

View File

@ -54,7 +54,7 @@ e-mail message (if there is any."
"Offer to create DIR if it does not exist yet. Return t if the "Offer to create DIR if it does not exist yet. Return t if the
dir already existed, or has been created, nil otherwise." dir already existed, or has been created, nil otherwise."
(if (and (file-exists-p dir) (not (file-directory-p dir))) (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 (cond
((file-directory-p dir) t) ((file-directory-p dir) t)
((yes-or-no-p (mu4e-format "%s does not exist yes. Create now?" dir)) ((yes-or-no-p (mu4e-format "%s does not exist yes. Create now?" dir))
@ -63,7 +63,9 @@ dir already existed, or has been created, nil otherwise."
(defun mu4e-format (frm &rest args) (defun mu4e-format (frm &rest args)
"Create [mu4e]-prefixed string based on format FRM and 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) (defun mu4e-message (frm &rest args)
"Like `message', but prefixed with mu4e. If we're waiting for "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) (unless (waiting-for-user-input-p)
(message "%s" (apply 'mu4e-format frm args)))) (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) (defun mu4e~read-char-choice (prompt choices)
"Compatiblity wrapper for `read-char-choice', which is emacs-24 "Compatiblity wrapper for `read-char-choice', which is emacs-24
only." only."
@ -110,7 +117,7 @@ Function will return the cdr of the list element."
(lambda (option) (lambda (option)
;; try to detect old-style options, and warn ;; try to detect old-style options, and warn
(when (characterp (car-safe (cdr-safe option))) (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"))) "see the manual")))
(let* ((kar (substring (car option) 0 1)) (let* ((kar (substring (car option) 0 1))
(val (cdr option))) (val (cdr option)))
@ -128,7 +135,7 @@ Function will return the cdr of the list element."
(find-if (find-if
(lambda (option) (eq response (string-to-char (car option)))) (lambda (option) (eq response (string-to-char (car option))))
options))) options)))
(unless chosen (error "%S not found" response)) (unless chosen (mu4e-error "%S not found" response))
(cdr chosen))) (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 name. If the special shortcut 'o' (for _o_ther) is used, or if
`mu4e-maildir-shortcuts is not defined, let user choose from all `mu4e-maildir-shortcuts is not defined, let user choose from all
maildirs under `mu4e-maildir." 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))) (let ((prompt (mu4e-format "%s" prompt)))
(if (not mu4e-maildir-shortcuts) (if (not mu4e-maildir-shortcuts)
(ido-completing-read prompt (ido-completing-read prompt
@ -201,7 +208,7 @@ maildirs under `mu4e-maildir."
(ido-completing-read prompt (mu4e-get-maildirs mu4e-maildir)) (ido-completing-read prompt (mu4e-get-maildirs mu4e-maildir))
(or (car-safe (or (car-safe
(find-if (lambda (item) (= kar (cdr item))) mu4e-maildir-shortcuts)) (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) (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." provided, function asks for it."
(interactive) (interactive)
(unless (mu4e~headers-docid-at-point) (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: "))) (let* ((target (or target (mu4e-ask-maildir "Move message to: ")))
(target (if (string= (substring target 0 1) "/") (target (if (string= (substring target 0 1) "/")
target target
@ -238,7 +245,7 @@ provided, function asks for it."
(defun mu4e-ask-bookmark (prompt &optional kar) (defun mu4e-ask-bookmark (prompt &optional kar)
"Ask the user for a bookmark (using PROMPT) as defined in "Ask the user for a bookmark (using PROMPT) as defined in
`mu4e-bookmarks', then return the corresponding query." `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)) (let* ((prompt (mu4e-format "%s" prompt))
(bmarks (bmarks
(mapconcat (mapconcat
@ -262,7 +269,7 @@ KAR, or raise an error if none is found."
mu4e-bookmarks))) mu4e-bookmarks)))
(if chosen-bm (if chosen-bm
(nth 0 chosen-bm) (nth 0 chosen-bm)
(error "Invalid shortcut '%c'" kar)))) (mu4e-error "Invalid shortcut '%c'" kar))))
;;; converting flags->string and vice-versa ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; converting flags->string and vice-versa ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -451,7 +458,7 @@ there is no message at point."
((eq major-mode 'mu4e-view-mode) ((eq major-mode 'mu4e-view-mode)
mu4e~view-msg)))) mu4e~view-msg))))
(if (and (null msg) raise-err) (if (and (null msg) raise-err)
(error "No message at point") (mu4e-error "No message at point")
msg))) msg)))
(defun mu4e-field-at-point (field) (defun mu4e-field-at-point (field)
@ -536,7 +543,7 @@ and update the database afterwards, and show the progress in a
split-window." split-window."
(interactive) (interactive)
(unless mu4e-get-mail-command (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 ;; delete any old update buffer
(when (buffer-live-p mu4e~update-buffer-name) (when (buffer-live-p mu4e~update-buffer-name)
(with-current-buffer 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 () (defun mu4e~check-requirements ()
"Check for the settings required for running mu4e." "Check for the settings required for running mu4e."
(unless (and mu4e-mu-binary (file-executable-p mu4e-mu-binary)) (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.")) binary."))
(unless mu4e-maildir (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.")) Maildir directory."))
;; expand mu4e-maildir, mu4e-attachment-dir ;; expand mu4e-maildir, mu4e-attachment-dir
(setq (setq
mu4e-maildir (expand-file-name mu4e-maildir) mu4e-maildir (expand-file-name mu4e-maildir)
mu4e-attachment-dir (expand-file-name mu4e-attachment-dir)) mu4e-attachment-dir (expand-file-name mu4e-attachment-dir))
(unless (mu4e-create-maildir-maybe mu4e-maildir) (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 (dolist (var '( mu4e-sent-folder
mu4e-drafts-folder mu4e-drafts-folder
mu4e-trash-folder)) mu4e-trash-folder))
(unless (and (boundp var) (symbol-value var)) (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))) (let* ((dir (symbol-value var)) (path (concat mu4e-maildir dir)))
(unless (string= (substring dir 0 1) "/") (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) (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) (defun mu4e~start (&optional func)
@ -617,14 +624,14 @@ FUNC (if non-nil) afterwards."
;; explicit version checks are a bit questionable, ;; explicit version checks are a bit questionable,
;; better to check for specific features ;; better to check for specific features
(unless (>= emacs-major-version 23) (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 ;; set up the 'pong' handler func
(lexical-let ((func func)) (lexical-let ((func func))
(setq mu4e-pong-func (setq mu4e-pong-func
(lambda (version doccount) (lambda (version doccount)
(unless (string= version mu4e-mu-version) (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)) version mu4e-mu-version))
(when func (funcall func)) (when func (funcall func))
(when (and mu4e-update-interval (null mu4e-update-timer)) (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 function is asynchronous, returns (almost) immediately, and all the
processing takes part in the background, unless buf is non-nil." processing takes part in the background, unless buf is non-nil."
(unless mu4e-get-mail-command (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) (let* ((process-connection-type t)
(proc (start-process-shell-command (proc (start-process-shell-command
mu4e-update-mail-name buf mu4e-get-mail-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) (from-server 'font-lock-type-face)
(to-server 'font-lock-function-name-face) (to-server 'font-lock-function-name-face)
(misc 'font-lock-variable-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))) (msg (propertize (apply 'format frm args) 'face msg-face)))
(goto-char (point-max)) (goto-char (point-max))
(insert tstamp (insert tstamp
(case type (case type
(from-server " <- ") (from-server " <- ")
(to-server " -> ") (to-server " -> ")
(error " !! ")
(otherwise " ")) (otherwise " "))
msg "\n") msg "\n")
@ -763,7 +772,7 @@ mu4e logs some of its internal workings to a log-buffer. See
(interactive) (interactive)
(let ((buf (get-buffer mu4e~log-buffer-name))) (let ((buf (get-buffer mu4e~log-buffer-name)))
(unless (buffer-live-p buf) (unless (buffer-live-p buf)
(error "No debug log available")) (mu4e-error "No debug log available"))
(switch-to-buffer buf))) (switch-to-buffer buf)))
@ -794,9 +803,9 @@ This includes expanding e.g. 3-5 into 3,4,5. If the letter
#'(lambda (x) #'(lambda (x)
(cond (cond
((> x n) ((> x n)
(error "Attachment %d bigger than maximum (%d)" x n)) (mu4e-error "Attachment %d bigger than maximum (%d)" x n))
((< x 1) ((< x 1)
(error "Attachment number must be greater than 0 (%d)" x)))) (mu4e-error "Attachment number must be greater than 0 (%d)" x))))
list))) list)))

View File

@ -337,17 +337,9 @@ headers)."
:group 'mu4e-faces) :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 (defconst mu4e-header-info
'( (:attachments . '( (:attachments .
( :name "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 self-explanatory. A special one is `:from-or-to', which is equal to
`:from' unless `:from' matches `mu4e-user-mail-address-regexp', in `:from' unless `:from' matches `mu4e-user-mail-address-regexp', in
which case it will be equal to `:to'.") which case it will be equal to `:to'.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; run-time vars used in multiple places ;; run-time vars used in multiple places
@ -441,7 +431,7 @@ mu4e starts.")
;; from the server ;; from the server
(defun mu4e~default-handler (&rest args) (defun mu4e~default-handler (&rest args)
"*internal* Dummy handler function." "*internal* Dummy handler function."
(error "Not handled: %S" args)) (mu4e-error "Not handled: %S" args))
(defvar mu4e-error-func 'mu4e~default-handler (defvar mu4e-error-func 'mu4e~default-handler
"A function called for each error returned from the server "A function called for each error returned from the server

View File

@ -193,7 +193,7 @@ plist."
(if sizestr (mu4e~view-construct-header field sizestr)))) (if sizestr (mu4e~view-construct-header field sizestr))))
;; attachments ;; attachments
(:attachments (mu4e~view-construct-attachments msg)) (:attachments (mu4e~view-construct-attachments msg))
(t (error "Unsupported field: %S" field))))) (t (mu4e-error "Unsupported field: %S" field)))))
mu4e-view-fields "") mu4e-view-fields "")
"\n" "\n"
(mu4e-body-text msg))) (mu4e-body-text msg)))
@ -668,12 +668,12 @@ number them so they can be opened using `mu4e-view-go-to-url'."
current message." current message."
`(progn `(progn
(unless '(buffer-live-p mu4e~view-headers-buffer) (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))) (let* ((docid (mu4e-field-at-point :docid)))
(with-current-buffer mu4e~view-headers-buffer (with-current-buffer mu4e~view-headers-buffer
(if (and docid (mu4e~headers-goto-docid docid)) (if (and docid (mu4e~headers-goto-docid docid))
,@body ,@body
(error "cannot find corresponding message in headers (mu4e-error "cannot find corresponding message in headers
buffer.")))))) buffer."))))))
(defun mu4e-view-headers-next(&optional n) (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 attachment numbers, as per `mu4e-split-ranges-to-numbers', and
return the corresponding string." return the corresponding string."
(let* ((count (hash-table-count mu4e~view-attach-map)) (def)) (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 (not multi)
(if (= count 1) (if (= count 1)
(read-number (mu4e-format "%s: " prompt) 1) (read-number (mu4e-format "%s: " prompt) 1)
@ -799,7 +799,7 @@ number ATTNUM."
message-at-point if nil) to disk." message-at-point if nil) to disk."
(interactive) (interactive)
(unless mu4e-attachment-dir (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))) (let* ((msg (or msg (mu4e-message-at-point)))
(attnum (or attnum (attnum (or attnum
(mu4e~view-get-attach-num "Attachment to save" msg))) (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 ;; 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... ;; sense to edit the temp buffer; use C-x C-q if you insist...
(setq buffer-read-only t)) (setq buffer-read-only t))
(t (error "Unsupported action %S" what)))) (t (mu4e-error "Unsupported action %S" what))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; marking ;;; marking
@ -1015,7 +1015,7 @@ user that unmarking only works in the header list."
"Go to a numbered url." "Go to a numbered url."
(interactive "n[mu4e] Visit url with number: ") (interactive "n[mu4e] Visit url with number: ")
(let ((url (gethash num mu4e~view-link-map))) (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)))) (funcall (mu4e~view-browse-url-func url))))
(defconst mu4e~view-raw-buffer-name "*mu4e-raw-view*" (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)) (let ((path (mu4e-field-at-point :path))
(buf (get-buffer-create mu4e~view-raw-buffer-name))) (buf (get-buffer-create mu4e~view-raw-buffer-name)))
(unless (and path (file-readable-p path)) (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 (with-current-buffer buf
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(erase-buffer) (erase-buffer)
@ -1048,7 +1048,7 @@ the results."
ensure we don't disturb other windows." ensure we don't disturb other windows."
(interactive) (interactive)
(unless (eq major-mode 'mu4e-view-mode) (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)) (let ((curbuf (current-buffer)) (curwin (selected-window))
(headers-win)) (headers-win))
(walk-windows (walk-windows

View File

@ -196,7 +196,7 @@ mode."
(add-hook 'post-command-hook 'org~mu4e-mime-switch-headers-or-body t t) (add-hook 'post-command-hook 'org~mu4e-mime-switch-headers-or-body t t)
(let ((func (lookup-key (current-local-map) keyseq))) (let ((func (lookup-key (current-local-map) keyseq)))
(unless (functionp func) (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) (add-hook 'message-send-hook 'org~mu4e-mime-convert-to-html-maybe t t)
(funcall func))) (funcall func)))
@ -219,7 +219,7 @@ or org-mode (when in the body),"
(org-mode) (org-mode)
(add-hook 'before-save-hook (add-hook 'before-save-hook
(lambda () (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) (org~mu4e-mime-decorate-headers)
(local-set-key (kbd "M-m") (local-set-key (kbd "M-m")
(lambda (key) (lambda (key)
@ -242,9 +242,9 @@ or org-mode (when in the body),"
body using org-mode." body using org-mode."
(interactive) (interactive)
(unless (member major-mode '(org-mode mu4e-compose-mode)) (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") (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 ;; we can check if we're already in mu4e-compose-mode by checking
;; if the post-command-hook is set; hackish... ;; if the post-command-hook is set; hackish...
(if (not (member 'org~mu4e-mime-switch-headers-or-body post-command-hook)) (if (not (member 'org~mu4e-mime-switch-headers-or-body post-command-hook))