2011-12-13 08:07:38 +01:00
|
|
|
|
;;; mu4e.el -- part of mu4e, the mu mail user agent
|
2011-09-12 19:52:32 +02:00
|
|
|
|
;;
|
2012-03-26 20:18:26 +02:00
|
|
|
|
;; Copyright (C) 2011-2012 Dirk-Jan C. Binnema
|
2011-09-12 19:52:32 +02:00
|
|
|
|
|
|
|
|
|
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
|
|
|
|
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
|
|
|
|
;; Keywords: email
|
|
|
|
|
;; Version: 0.0
|
|
|
|
|
|
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
|
;;
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
(eval-when-compile (require 'cl))
|
|
|
|
|
|
2012-03-28 21:23:35 +02:00
|
|
|
|
(require 'mu4e-hdrs) ;; headers view
|
|
|
|
|
(require 'mu4e-view) ;; message view
|
|
|
|
|
(require 'mu4e-main) ;; main screen
|
|
|
|
|
(require 'mu4e-send) ;; editing / sending
|
|
|
|
|
(require 'mu4e-proc) ;; communication with backend
|
|
|
|
|
|
|
|
|
|
(require 'mu4e-speedbar) ;; support for speedbar
|
2011-09-12 19:52:32 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
;; mu4e-version.el is autogenerated, and defines mu4e-mu-version
|
|
|
|
|
(require 'mu4e-version)
|
2011-09-30 07:37:47 +02:00
|
|
|
|
|
2011-09-12 19:52:32 +02:00
|
|
|
|
;; Customization
|
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defgroup mu4e nil
|
|
|
|
|
"mu4e - mu for emacs"
|
2011-12-13 06:44:45 +01:00
|
|
|
|
:group 'local)
|
2011-09-12 19:52:32 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defcustom mu4e-mu-home nil
|
2011-09-12 19:52:32 +02:00
|
|
|
|
"Location of the mu homedir, or nil for the default."
|
|
|
|
|
:type 'directory
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e
|
2011-09-12 19:52:32 +02:00
|
|
|
|
:safe 'stringp)
|
|
|
|
|
|
2012-01-07 13:27:21 +01:00
|
|
|
|
(defcustom mu4e-mu-binary (executable-find "mu")
|
2011-09-12 19:52:32 +02:00
|
|
|
|
"Name of the mu-binary to use; if it cannot be found in your
|
2011-11-27 15:23:14 +01:00
|
|
|
|
PATH, you can specify the full path."
|
|
|
|
|
:type 'file
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e
|
2011-11-27 15:23:14 +01:00
|
|
|
|
:safe 'stringp)
|
|
|
|
|
|
2012-01-07 13:27:21 +01:00
|
|
|
|
(defcustom mu4e-maildir (expand-file-name "~/Maildir")
|
2012-03-14 20:35:29 +01:00
|
|
|
|
"Your Maildir directory; by default, mu4e assumes
|
|
|
|
|
~/Maildir."
|
2011-09-12 19:52:32 +02:00
|
|
|
|
:type 'directory
|
|
|
|
|
:safe 'stringp
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e)
|
2011-09-12 19:52:32 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defcustom mu4e-get-mail-command nil
|
2011-09-18 13:39:36 +02:00
|
|
|
|
"Shell command to run to retrieve new mail; e.g. 'offlineimap' or
|
|
|
|
|
'fetchmail'."
|
|
|
|
|
:type 'string
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e
|
2011-09-18 13:39:36 +02:00
|
|
|
|
:safe 'stringp)
|
|
|
|
|
|
2012-02-28 21:34:22 +01:00
|
|
|
|
(defcustom mu4e-update-interval nil
|
|
|
|
|
"Number of seconds between automatic calls to retrieve mail and
|
|
|
|
|
update the database. If nil, don't update automatically. Note,
|
|
|
|
|
changes in `mu4e-update-interval' only take effect after restarting
|
|
|
|
|
mu4d."
|
|
|
|
|
:type 'integer
|
|
|
|
|
:group 'mu4e
|
|
|
|
|
:safe 'integerp)
|
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defcustom mu4e-attachment-dir (expand-file-name "~/")
|
2011-09-19 23:20:59 +02:00
|
|
|
|
"Default directory for saving attachments."
|
|
|
|
|
:type 'string
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e
|
2011-09-19 23:20:59 +02:00
|
|
|
|
:safe 'stringp)
|
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defvar mu4e-user-mail-address-regexp "$^"
|
2011-11-09 07:35:24 +01:00
|
|
|
|
"Regular expression matching the user's mail address(es). This is
|
|
|
|
|
used to distinguish ourselves from others, e.g. when replying and
|
|
|
|
|
in :from-or-to headers. By default, match nothing.")
|
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defvar mu4e-date-format-long "%c"
|
2011-11-09 07:35:24 +01:00
|
|
|
|
"Date format to use in the message view, in the format of
|
|
|
|
|
`format-time-string'.")
|
2011-09-30 07:37:47 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defvar mu4e-search-results-limit 500
|
2011-12-07 07:18:47 +01:00
|
|
|
|
"Maximum number of search results (or -1 for unlimited). Since
|
|
|
|
|
limiting search results speeds up searches significantly, it's
|
|
|
|
|
useful to limit this. Note, to ignore the limit, use a prefix
|
|
|
|
|
argument (C-u) before invoking the search.")
|
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defvar mu4e-debug nil
|
|
|
|
|
"When set to non-nil, log debug information to the *mu4e-log* buffer.")
|
2011-09-18 13:39:36 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defvar mu4e-bookmarks
|
2011-12-07 07:18:47 +01:00
|
|
|
|
'( ("flag:unread AND NOT flag:trashed" "Unread messages" ?u)
|
|
|
|
|
("date:today..now" "Today's messages" ?t)
|
|
|
|
|
("date:7d..now" "Last 7 days" ?w)
|
|
|
|
|
("mime:image/*" "Messages with images" ?p))
|
2011-12-03 13:22:30 +01:00
|
|
|
|
"A list of pre-defined queries; these will show up in the main
|
|
|
|
|
screen. Each of the list elements is a three-element list of the
|
|
|
|
|
form (QUERY DESCRIPTION KEY), where QUERY is a string with a mu
|
|
|
|
|
query, DESCRIPTION is a short description of the query (this will
|
|
|
|
|
show up in the UI), and KEY is a shortcut key for the query.")
|
|
|
|
|
|
|
|
|
|
|
2012-03-13 07:28:25 +01:00
|
|
|
|
;; Sending
|
|
|
|
|
(defgroup mu4e-sending nil
|
|
|
|
|
"E-mail-sending related settings for mu4e.")
|
|
|
|
|
|
|
|
|
|
(defcustom mu4e-sent-messages-behavior 'sent
|
|
|
|
|
"Determines what mu4e does with sent messages - this is a symbol
|
|
|
|
|
which can be either:
|
|
|
|
|
'sent --> move the sent message to the Sent-folder (`mu4e-sent-folder')
|
|
|
|
|
'trash --> move the sent message to the Trash-folder (`mu4e-trash-folder')
|
|
|
|
|
'delete --> delete the sent message.
|
|
|
|
|
Note, when using GMail/IMAP, you should set this to either 'trash
|
|
|
|
|
or 'delete, since GMail already takes care of keeping copies in the
|
|
|
|
|
sent folder."
|
|
|
|
|
:type 'symbol
|
|
|
|
|
:safe 'symbolp
|
|
|
|
|
:group 'mu4e-sending)
|
|
|
|
|
|
2011-09-12 19:52:32 +02:00
|
|
|
|
;; Folders
|
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defgroup mu4e-folders nil
|
2012-04-01 11:31:23 +02:00
|
|
|
|
"Special folders."
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e)
|
2011-09-12 19:52:32 +02:00
|
|
|
|
|
2012-01-07 13:27:21 +01:00
|
|
|
|
(defcustom mu4e-sent-folder "/sent"
|
2011-12-13 08:07:38 +01:00
|
|
|
|
"Your folder for sent messages, relative to `mu4e-maildir',
|
2011-09-20 22:59:20 +02:00
|
|
|
|
e.g. \"/Sent Items\"."
|
2011-09-12 19:52:32 +02:00
|
|
|
|
:type 'string
|
|
|
|
|
:safe 'stringp
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-folders)
|
2011-09-12 19:52:32 +02:00
|
|
|
|
|
2012-01-07 13:27:21 +01:00
|
|
|
|
(defcustom mu4e-drafts-folder "/drafts"
|
2011-12-13 08:07:38 +01:00
|
|
|
|
"Your folder for draft messages, relative to `mu4e-maildir',
|
2011-09-20 22:59:20 +02:00
|
|
|
|
e.g. \"/drafts\""
|
2011-09-12 19:52:32 +02:00
|
|
|
|
:type 'string
|
|
|
|
|
:safe 'stringp
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-folders)
|
2011-09-12 19:52:32 +02:00
|
|
|
|
|
2012-01-07 13:27:21 +01:00
|
|
|
|
(defcustom mu4e-trash-folder "/trash"
|
2011-12-13 08:07:38 +01:00
|
|
|
|
"Your folder for trashed messages, relative to `mu4e-maildir',
|
2011-09-20 22:59:20 +02:00
|
|
|
|
e.g. \"/trash\"."
|
2011-09-12 19:52:32 +02:00
|
|
|
|
:type 'string
|
|
|
|
|
:safe 'stringp
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-folders)
|
2011-09-12 19:52:32 +02:00
|
|
|
|
|
2011-09-18 13:39:36 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defcustom mu4e-maildir-shortcuts nil
|
2011-11-05 11:29:07 +01:00
|
|
|
|
"A list of maildir shortcuts to enable quickly going to the
|
|
|
|
|
particular for, or quickly moving messages towards them (i.e.,
|
|
|
|
|
archiving or refiling). The list contains elements of the form
|
|
|
|
|
(maildir . shortcut), where MAILDIR is a maildir (such as
|
2011-11-05 09:26:24 +01:00
|
|
|
|
\"/archive/\"), and shortcut a single shortcut character. With
|
|
|
|
|
this, in the header buffer and view buffer you can execute
|
2011-12-13 08:07:38 +01:00
|
|
|
|
`mu4e-mark-for-move-quick' (or 'm', by default) or
|
2011-12-19 21:13:12 +01:00
|
|
|
|
`mu4e-jump-to-maildir' (or 'j', by default), followed by the
|
2011-11-05 11:29:07 +01:00
|
|
|
|
designated shortcut character for the maildir.")
|
2011-11-05 09:26:24 +01:00
|
|
|
|
|
2011-09-20 22:59:20 +02:00
|
|
|
|
;; the headers view
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defgroup mu4e-headers nil
|
2011-09-20 22:59:20 +02:00
|
|
|
|
"Settings for the headers view."
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e)
|
2011-09-18 13:39:36 +02:00
|
|
|
|
|
2011-09-30 07:37:47 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defcustom mu4e-headers-fields
|
2012-02-28 21:34:22 +01:00
|
|
|
|
'( (:date . 25)
|
|
|
|
|
(:flags . 6)
|
|
|
|
|
(:from . 22)
|
|
|
|
|
(:subject . nil))
|
2011-09-20 22:59:20 +02:00
|
|
|
|
"A list of header fields to show in the headers buffer, and their
|
|
|
|
|
respective widths in characters. A width of `nil' means
|
|
|
|
|
'unrestricted', and this is best reserved fo the rightmost (last)
|
2012-02-28 21:34:22 +01:00
|
|
|
|
field. For the complete list of available headers, see
|
|
|
|
|
`mu4e-header-names'"
|
|
|
|
|
:type (list 'symbol)
|
|
|
|
|
:group 'mu4e-headers)
|
2011-11-09 07:35:24 +01:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defcustom mu4e-headers-date-format "%x %X"
|
2011-11-09 07:35:24 +01:00
|
|
|
|
"Date format to use in the headers view, in the format of
|
|
|
|
|
`format-time-string'."
|
|
|
|
|
:type 'string
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-headers)
|
2011-11-09 07:35:24 +01:00
|
|
|
|
|
2012-02-27 22:41:11 +01:00
|
|
|
|
(defcustom mu4e-headers-leave-behavior 'ask
|
2012-02-28 21:34:22 +01:00
|
|
|
|
"What to do when user leaves the headers view (e.g. quits,
|
|
|
|
|
refreshes or does a new search). Value is one of the following
|
|
|
|
|
symbols:
|
|
|
|
|
- ask (ask the user whether to ignore the marks)
|
|
|
|
|
- apply (automatically apply the marks before doing anything else)
|
|
|
|
|
- ignore (automatically ignore the marks without asking)."
|
2012-02-27 22:41:11 +01:00
|
|
|
|
:type 'symbol
|
|
|
|
|
:group 'mu4e-headers)
|
|
|
|
|
|
2011-09-18 13:39:36 +02:00
|
|
|
|
;; the message view
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defgroup mu4e-view nil
|
2011-09-20 22:59:20 +02:00
|
|
|
|
"Settings for the message view."
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e)
|
2011-09-18 13:39:36 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defcustom mu4e-view-fields
|
2012-04-02 19:00:15 +02:00
|
|
|
|
'(:from :to :cc :subject :flags :date :maildir :attachments)
|
2011-11-05 09:26:24 +01:00
|
|
|
|
"Header fields to display in the message view buffer. For the
|
2011-12-13 08:07:38 +01:00
|
|
|
|
complete list of available headers, see `mu4e-header-names'."
|
2011-09-18 13:39:36 +02:00
|
|
|
|
:type (list 'symbol)
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-view)
|
2011-09-18 13:39:36 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defcustom mu4e-view-date-format "%c"
|
2011-11-09 07:35:24 +01:00
|
|
|
|
"Date format to use in the message view, in the format of
|
|
|
|
|
`format-time-string'."
|
|
|
|
|
:type 'string
|
2011-12-19 08:06:47 +01:00
|
|
|
|
:group 'mu4e-view)
|
|
|
|
|
|
2012-02-14 20:22:02 +01:00
|
|
|
|
(defcustom mu4e-view-prefer-html nil
|
|
|
|
|
"Whether to base the body display on the HTML-version of the
|
|
|
|
|
e-mail message (if there is any."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'mu4e-view)
|
|
|
|
|
|
2011-12-19 08:06:47 +01:00
|
|
|
|
(defcustom mu4e-html2text-command nil
|
|
|
|
|
"Shel command that converts HTML from stdin into plain text on
|
|
|
|
|
stdout. If this is not defined, the emacs `html2text' tool will be
|
2012-02-14 20:22:02 +01:00
|
|
|
|
used when faced with html-only message. If you use htmltext, it's
|
|
|
|
|
recommended you use \"html2text -utf8 -width 72\"."
|
2011-12-19 08:06:47 +01:00
|
|
|
|
:type 'string
|
|
|
|
|
:group 'mu4e-view
|
|
|
|
|
:safe 'stringp)
|
|
|
|
|
|
2012-04-01 11:31:23 +02:00
|
|
|
|
|
|
|
|
|
(defcustom mu4e-view-wrap-lines nil
|
|
|
|
|
"Whether to automatically wrap lines in the body of messages when
|
|
|
|
|
viewing them. Note that wrapping does not work well with all
|
|
|
|
|
messages, but you can always toggle between wrapped/unwrapped
|
|
|
|
|
display with `mu4e-view-toggle-wrap-lines (default keybinding: <w>)."
|
|
|
|
|
:group 'mu4e-view)
|
|
|
|
|
|
|
|
|
|
(defcustom mu4e-view-wrap-lines nil
|
|
|
|
|
"Whether to automatically wrap lines in the body of messages when
|
|
|
|
|
viewing them. Note that wrapping does not work well with all
|
|
|
|
|
messages, but you can always toggle between wrapped/unwrapped
|
|
|
|
|
display with `mu4e-view-toggle-wrap-lines (default keybinding: <w>)."
|
|
|
|
|
:group 'mu4e-view)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defcustom mu4e-view-hide-cited nil
|
|
|
|
|
"Whether to automatically hide cited parts of messages (as
|
|
|
|
|
determined by the presence of '> ' at the beginning of the
|
|
|
|
|
line). Note that you can always toggle between hidden/unhidden
|
|
|
|
|
display with `mu4e-view-toggle-hide-cited (default keybinding:
|
|
|
|
|
<w>)."
|
|
|
|
|
:group 'mu4e-view)
|
|
|
|
|
|
|
|
|
|
|
2011-09-18 13:39:36 +02:00
|
|
|
|
;; Composing / Sending messages
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defgroup mu4e-compose nil
|
2011-09-18 13:39:36 +02:00
|
|
|
|
"Customizations for composing/sending messages."
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e)
|
2011-09-18 13:39:36 +02:00
|
|
|
|
|
2011-12-20 20:41:31 +01:00
|
|
|
|
(defcustom mu4e-send-citation-prefix "> "
|
2011-09-18 13:39:36 +02:00
|
|
|
|
"String to prefix cited message parts with."
|
|
|
|
|
:type 'string
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-compose)
|
2011-09-18 13:39:36 +02:00
|
|
|
|
|
2011-12-20 20:41:31 +01:00
|
|
|
|
(defcustom mu4e-send-reply-prefix "Re: "
|
2011-09-18 13:39:36 +02:00
|
|
|
|
"String to prefix the subject of replied messages with."
|
|
|
|
|
:type 'string
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-compose)
|
2011-09-18 13:39:36 +02:00
|
|
|
|
|
2011-12-20 20:41:31 +01:00
|
|
|
|
(defcustom mu4e-send-forward-prefix "Fwd: "
|
2011-09-18 13:39:36 +02:00
|
|
|
|
"String to prefix the subject of forwarded messages with."
|
|
|
|
|
:type 'string
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-compose)
|
2011-09-18 13:39:36 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defcustom mu4e-user-agent nil
|
2011-09-18 13:39:36 +02:00
|
|
|
|
"The user-agent string; leave at `nil' for the default."
|
|
|
|
|
:type 'string
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-compose)
|
2011-09-18 13:39:36 +02:00
|
|
|
|
|
* make it configurable what to do with sent messages (part 2), and document it:
By default, @t{mu4e} puts a copy of any messages you sent in the folder you
set for @code{mu4e-sent-folder}. In some case, this may not be what you want -
for example, when using GMail+@abbr{IMAP} (but @emph{not} with
GMail+@abbr{POP3}), this interferes with GMail's handling of the sent messages
folder, and you may end up with duplicate messages. For this, since @t{mu4e}
0.9.8.3, there is the variable @code{mu4e-sent-messages-behavior}, which takes
a symbol. The default is @code{'sent} which, as stated causes the message to
be copied to your sent-messages folder. Other possible values are
@code{'trash} (so the sent message is copied to the trash-folder
(@code{mu4e-trash-folder}), and @code{'delete} to simply discard the message
altogether.
2012-03-13 19:13:30 +01:00
|
|
|
|
(defcustom mu4e-sent-messages-behavior 'sent
|
|
|
|
|
"Determines what mu4e does with sent messages - this is a symbol
|
|
|
|
|
which can be either:
|
|
|
|
|
'sent --> move the sent message to the Sent-folder (`mu4e-sent-folder')
|
|
|
|
|
'trash --> move the sent message to the Trash-folder (`mu4e-trash-folder')
|
|
|
|
|
'delete --> delete the sent message.
|
|
|
|
|
Note, when using GMail/IMAP, you should set this to either 'trash
|
|
|
|
|
or 'delete, since GMail already takes care of keeping copies in the
|
|
|
|
|
sent folder."
|
|
|
|
|
:type 'symbol
|
|
|
|
|
:safe 'symbolp
|
|
|
|
|
:group 'mu4e-compose)
|
|
|
|
|
|
|
|
|
|
|
2011-09-12 19:52:32 +02:00
|
|
|
|
;; Faces
|
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defgroup mu4e-faces nil
|
2012-04-01 11:31:23 +02:00
|
|
|
|
"Type faces (fonts) used in mu4e."
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e
|
2011-09-12 19:52:32 +02:00
|
|
|
|
:group 'faces)
|
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defface mu4e-unread-face
|
2011-09-12 19:52:32 +02:00
|
|
|
|
'((t :inherit font-lock-keyword-face :bold t))
|
2012-04-01 11:31:23 +02:00
|
|
|
|
"Face for an unread message header."
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-faces)
|
2011-09-12 19:52:32 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defface mu4e-moved-face
|
2011-09-18 13:39:36 +02:00
|
|
|
|
'((t :inherit font-lock-comment-face :slant italic))
|
2012-04-01 11:31:23 +02:00
|
|
|
|
"Face for a message header that has been moved to some
|
2011-09-18 13:39:36 +02:00
|
|
|
|
folder (it's still visible in the search results, since we cannot
|
|
|
|
|
be sure it no longer matches)."
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-faces)
|
2011-09-18 13:39:36 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defface mu4e-trashed-face
|
2011-10-23 23:20:32 +02:00
|
|
|
|
'((t :inherit font-lock-comment-face :strike-through t))
|
2011-09-18 13:39:36 +02:00
|
|
|
|
"Face for an message header in the trash folder."
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-faces)
|
2011-09-12 19:52:32 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defface mu4e-draft-face
|
2011-10-23 23:20:32 +02:00
|
|
|
|
'((t :inherit font-lock-string-face))
|
|
|
|
|
"Face for a draft message header (i.e., a message with the draft
|
|
|
|
|
flag set)."
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-faces)
|
2011-10-23 23:20:32 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defface mu4e-header-face
|
2011-09-12 19:52:32 +02:00
|
|
|
|
'((t :inherit default))
|
2012-04-01 11:31:23 +02:00
|
|
|
|
"Face for a header without any special flags."
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-faces)
|
2011-09-18 13:39:36 +02:00
|
|
|
|
|
2012-04-01 11:31:23 +02:00
|
|
|
|
(defface mu4e-header-title-face
|
2012-04-02 00:00:21 +02:00
|
|
|
|
'((t :inherit font-lock-type-face))
|
2012-04-01 11:31:23 +02:00
|
|
|
|
"Face for a header title in the headers view."
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-faces)
|
2011-09-18 13:39:36 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defface mu4e-view-header-key-face
|
2012-02-08 21:18:34 +01:00
|
|
|
|
'((t :inherit font-lock-builtin-face :bold t))
|
2012-04-01 11:31:23 +02:00
|
|
|
|
"Face for a header title (such as \"Subject\") in the message
|
|
|
|
|
view."
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-faces)
|
2011-09-18 13:39:36 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defface mu4e-view-header-value-face
|
2011-09-18 13:39:36 +02:00
|
|
|
|
'((t :inherit font-lock-doc-face))
|
2012-04-01 11:31:23 +02:00
|
|
|
|
"Face for a header value (such as \"Re: Hello!\") in the message
|
|
|
|
|
view."
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-faces)
|
2011-09-12 19:52:32 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defface mu4e-view-link-face
|
2011-09-20 22:59:20 +02:00
|
|
|
|
'((t :inherit font-lock-type-face :underline t))
|
|
|
|
|
"Face for showing URLs and attachments in the message view."
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-faces)
|
2011-09-20 22:59:20 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defface mu4e-highlight-face
|
2011-12-03 13:22:30 +01:00
|
|
|
|
'((t :inherit font-lock-pseudo-keyword-face :bold t))
|
|
|
|
|
"Face for highlighting things."
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-faces)
|
2011-12-03 13:22:30 +01:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defface mu4e-view-url-number-face
|
2011-09-20 22:59:20 +02:00
|
|
|
|
'((t :inherit font-lock-reference-face :bold t))
|
|
|
|
|
"Face for the number tags for URLs."
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-faces)
|
2011-09-20 22:59:20 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defface mu4e-view-attach-number-face
|
2011-10-04 07:12:47 +02:00
|
|
|
|
'((t :inherit font-lock-variable-name-face :bold t))
|
2011-09-20 22:59:20 +02:00
|
|
|
|
"Face for the number tags for attachments."
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-faces)
|
2011-09-12 19:52:32 +02:00
|
|
|
|
|
2012-02-08 21:18:34 +01:00
|
|
|
|
(defface mu4e-cited-1-face
|
|
|
|
|
'((t :inherit font-lock-builtin-face :bold nil :italic t))
|
|
|
|
|
"Face for cited message parts (level 1)."
|
|
|
|
|
:group 'mu4e-faces)
|
|
|
|
|
|
|
|
|
|
(defface mu4e-cited-2-face
|
|
|
|
|
'((t :inherit font-lock-type-face :bold nil :italic t))
|
|
|
|
|
"Face for cited message parts (level 2)."
|
|
|
|
|
:group 'mu4e-faces)
|
|
|
|
|
|
|
|
|
|
(defface mu4e-cited-3-face
|
|
|
|
|
'((t :inherit font-lock-variable-name-face :bold nil :italic t))
|
|
|
|
|
"Face for cited message parts (level 3)."
|
|
|
|
|
:group 'mu4e-faces)
|
|
|
|
|
|
|
|
|
|
(defface mu4e-cited-4-face
|
|
|
|
|
'((t :inherit font-lock-pseudo-keyword-face :bold nil :italic t))
|
|
|
|
|
"Face for cited message parts (level 4)."
|
|
|
|
|
:group 'mu4e-faces)
|
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defface mu4e-view-footer-face
|
2011-09-20 22:59:20 +02:00
|
|
|
|
'((t :inherit font-lock-comment-face))
|
|
|
|
|
"Face for message footers (signatures)."
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-faces)
|
2011-09-12 19:52:32 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defface mu4e-hdrs-marks-face
|
2011-10-04 07:12:47 +02:00
|
|
|
|
'((t :inherit font-lock-preprocessor-face))
|
|
|
|
|
"Face for the mark in the headers list."
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-faces)
|
2011-10-04 07:12:47 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defface mu4e-system-face
|
2011-10-25 07:43:24 +02:00
|
|
|
|
'((t :inherit font-lock-comment-face :slant italic))
|
|
|
|
|
"Face for system message (such as the footers for message
|
|
|
|
|
headers)."
|
2011-12-13 08:07:38 +01:00
|
|
|
|
:group 'mu4e-faces)
|
2011-10-25 07:43:24 +02:00
|
|
|
|
|
2011-09-18 13:39:36 +02:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2011-11-05 09:26:24 +01:00
|
|
|
|
;; internal variables / constants
|
2011-09-18 13:39:36 +02:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defconst mu4e-header-names
|
2011-11-05 09:26:24 +01:00
|
|
|
|
'( (:attachments . "Attach")
|
|
|
|
|
(:bcc . "Bcc")
|
|
|
|
|
(:cc . "Cc")
|
|
|
|
|
(:date . "Date")
|
2012-01-22 09:19:28 +01:00
|
|
|
|
(:flags . "Flgs")
|
2011-11-05 09:26:24 +01:00
|
|
|
|
(:from . "From")
|
|
|
|
|
(:from-or-to . "From/To")
|
|
|
|
|
(:maildir . "Maildir")
|
|
|
|
|
(:path . "Path")
|
|
|
|
|
(:subject . "Subject")
|
|
|
|
|
(:to . "To"))
|
|
|
|
|
"A alist of all possible header fields; this is used in the UI (the
|
|
|
|
|
column headers in the header 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 ,
|
|
|
|
|
in which case it will be equal to `:to'.)")
|
|
|
|
|
|
2011-12-29 00:25:17 +01:00
|
|
|
|
|
2012-04-01 11:31:23 +02:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2012-01-07 13:27:21 +01:00
|
|
|
|
(defun mu4e-create-maildir-maybe (dir)
|
|
|
|
|
"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))
|
|
|
|
|
(cond
|
|
|
|
|
((file-directory-p dir) t)
|
|
|
|
|
((yes-or-no-p (format "%s does not exist yes. Create now?" dir))
|
|
|
|
|
(mu4e-proc-mkdir dir))
|
2012-02-04 01:01:10 +01:00
|
|
|
|
(t nil)))
|
2012-01-07 13:27:21 +01:00
|
|
|
|
|
|
|
|
|
(defun mu4e-check-requirements ()
|
|
|
|
|
"Check for the settings required for running mu4e."
|
2012-03-26 20:18:26 +02:00
|
|
|
|
(unless (and mu4e-mu-binary (file-executable-p mu4e-mu-binary))
|
|
|
|
|
(error "Please set `mu4e-mu-binary' to the full path to the mu
|
|
|
|
|
binary."))
|
2012-01-07 13:27:21 +01:00
|
|
|
|
(unless mu4e-maildir
|
|
|
|
|
(error "Please set `mu4e-maildir' to the full path to your
|
|
|
|
|
Maildir directory."))
|
2012-03-14 20:35:29 +01:00
|
|
|
|
;; expand mu4e-maildir, mu4e-attachment-dir
|
|
|
|
|
(setq
|
|
|
|
|
mu4e-maildir (expand-file-name mu4e-maildir)
|
|
|
|
|
mu4e-attachment-dir (expand-file-name mu4e-attachment-dir))
|
2012-01-07 13:27:21 +01:00
|
|
|
|
(unless (mu4e-create-maildir-maybe mu4e-maildir)
|
|
|
|
|
(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))
|
|
|
|
|
(let* ((dir (symbol-value var)) (path (concat mu4e-maildir dir)))
|
|
|
|
|
(unless (string= (substring dir 0 1) "/")
|
2012-02-05 06:39:41 +01:00
|
|
|
|
(error "%S must start with a '/'" dir))
|
2012-01-07 13:27:21 +01:00
|
|
|
|
(unless (mu4e-create-maildir-maybe path)
|
|
|
|
|
(error "%s (%S) does not exist" path var)))))
|
|
|
|
|
|
2012-02-28 21:34:22 +01:00
|
|
|
|
(defvar mu4e-update-timer nil
|
|
|
|
|
"*internal* The mu4e update timer.")
|
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defun mu4e ()
|
2012-04-01 11:31:23 +02:00
|
|
|
|
"Start mu4e. We do this by sending a 'ping' to the mu server
|
2011-12-13 06:44:45 +01:00
|
|
|
|
process, and start the main view if the 'pong' we receive from the
|
|
|
|
|
server has the expected values."
|
|
|
|
|
(interactive)
|
2011-12-15 20:47:30 +01:00
|
|
|
|
(if (buffer-live-p (get-buffer mu4e-main-buffer-name))
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(switch-to-buffer mu4e-main-buffer-name)
|
2012-01-07 13:27:21 +01:00
|
|
|
|
(mu4e-check-requirements)
|
2011-12-15 20:47:30 +01:00
|
|
|
|
;; explicit version checks are a bit questionable,
|
|
|
|
|
;; better to check for specific features
|
|
|
|
|
(if (< emacs-major-version 23)
|
|
|
|
|
(error "Emacs >= 23.x is required for mu4e")
|
2011-12-17 10:33:31 +01:00
|
|
|
|
(progn
|
2011-12-15 20:47:30 +01:00
|
|
|
|
(setq mu4e-proc-pong-func
|
|
|
|
|
(lambda (version doccount)
|
|
|
|
|
(unless (string= version mu4e-mu-version)
|
|
|
|
|
(error "mu server has version %s, but we need %s"
|
|
|
|
|
version mu4e-mu-version))
|
|
|
|
|
(mu4e-main-view)
|
2012-02-28 21:34:22 +01:00
|
|
|
|
(when mu4e-update-interval
|
|
|
|
|
(setq mu4e-update-timer
|
|
|
|
|
(run-at-time
|
|
|
|
|
0 mu4e-update-interval
|
|
|
|
|
'mu4e-update-mail)))
|
2011-12-15 20:47:30 +01:00
|
|
|
|
(message "Started mu4e with %d message%s in store"
|
|
|
|
|
doccount (if (= doccount 1) "" "s"))))
|
|
|
|
|
(mu4e-proc-ping)))))
|
2011-11-05 09:26:24 +01:00
|
|
|
|
|
2012-02-28 21:34:22 +01:00
|
|
|
|
(defun mu4e-quit()
|
2012-04-01 11:31:23 +02:00
|
|
|
|
"Quit the mu4e session."
|
2012-02-28 21:34:22 +01:00
|
|
|
|
(interactive)
|
|
|
|
|
(when (y-or-n-p "Are you sure you want to quit? ")
|
|
|
|
|
(message nil)
|
|
|
|
|
(when mu4e-update-timer
|
|
|
|
|
(cancel-timer mu4e-update-timer))
|
|
|
|
|
(mu4e-kill-proc)
|
|
|
|
|
(kill-buffer)))
|
|
|
|
|
|
|
|
|
|
|
2011-12-19 21:13:12 +01:00
|
|
|
|
(defun mu4e-get-maildirs (parentdir)
|
|
|
|
|
"List the maildirs under PARENTDIR." ;; TODO: recursive?
|
|
|
|
|
(let* ((files (directory-files parentdir))
|
|
|
|
|
(maildirs ;;
|
|
|
|
|
(remove-if
|
|
|
|
|
(lambda (file)
|
|
|
|
|
(let ((path (concat parentdir "/" file)))
|
|
|
|
|
(cond
|
|
|
|
|
((string-match "^\\.\\{1,2\\}$" file) t) ;; remove '..' and '.'
|
|
|
|
|
((not (file-directory-p path)) t) ;; remove non-dirs
|
|
|
|
|
((not ;; remove non-maildirs
|
|
|
|
|
(and (file-directory-p (concat path "/cur"))
|
|
|
|
|
(file-directory-p (concat path "/new"))
|
|
|
|
|
(file-directory-p (concat path "/tmp")))) t)
|
|
|
|
|
(t nil) ;; otherwise, it's probably maildir
|
|
|
|
|
)))
|
|
|
|
|
files)))
|
|
|
|
|
(map 'list (lambda(dir) (concat "/" dir)) maildirs)))
|
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defun mu4e-ask-maildir (prompt)
|
2011-12-03 13:22:30 +01:00
|
|
|
|
"Ask the user for a shortcut (using PROMPT) as defined in
|
2011-12-13 08:07:38 +01:00
|
|
|
|
`mu4e-maildir-shortcuts', then return the corresponding folder
|
2011-11-05 11:29:07 +01:00
|
|
|
|
name. If the special shortcut 'o' (for _o_ther) is used, or if
|
2011-12-13 08:07:38 +01:00
|
|
|
|
`mu4e-maildir-shortcuts is not defined, let user choose from all
|
|
|
|
|
maildirs under `mu4e-maildir."
|
|
|
|
|
(unless mu4e-maildir (error "`mu4e-maildir' is not defined"))
|
|
|
|
|
(if (not mu4e-maildir-shortcuts)
|
2011-12-19 21:13:12 +01:00
|
|
|
|
(ido-completing-read prompt (mu4e-get-maildirs mu4e-maildir))
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(let* ((mlist (append mu4e-maildir-shortcuts '(("ther" . ?o))))
|
2011-11-05 11:29:07 +01:00
|
|
|
|
(fnames
|
|
|
|
|
(mapconcat
|
|
|
|
|
(lambda (item)
|
|
|
|
|
(concat
|
|
|
|
|
"["
|
2012-02-14 20:22:02 +01:00
|
|
|
|
(propertize (make-string 1 (cdr item))
|
|
|
|
|
'face 'mu4e-view-link-face)
|
2011-11-05 11:29:07 +01:00
|
|
|
|
"]"
|
|
|
|
|
(car item)))
|
|
|
|
|
mlist ", "))
|
|
|
|
|
(kar (read-char (concat prompt fnames))))
|
2011-11-09 07:35:24 +01:00
|
|
|
|
(if (= kar ?o) ;; user chose 'other'?
|
2011-12-19 21:13:12 +01:00
|
|
|
|
(ido-completing-read prompt (mu4e-get-maildirs mu4e-maildir))
|
2011-11-09 07:55:39 +01:00
|
|
|
|
(or
|
2011-12-19 21:13:12 +01:00
|
|
|
|
(car-safe (find-if
|
|
|
|
|
(lambda (item)
|
|
|
|
|
(= kar (cdr item)))
|
|
|
|
|
mu4e-maildir-shortcuts))
|
2011-11-09 07:55:39 +01:00
|
|
|
|
(error "Invalid shortcut '%c'" kar))))))
|
2011-11-20 00:18:12 +01:00
|
|
|
|
|
2011-11-05 09:26:24 +01:00
|
|
|
|
|
2011-12-29 00:25:17 +01:00
|
|
|
|
(defun mu4e-ask-bookmark (prompt &optional kar)
|
2011-12-03 13:22:30 +01:00
|
|
|
|
"Ask the user for a bookmark (using PROMPT) as defined in
|
2011-12-13 08:07:38 +01:00
|
|
|
|
`mu4e-bookmarks', then return the corresponding query."
|
|
|
|
|
(unless mu4e-bookmarks (error "`mu4e-bookmarks' is not defined"))
|
2011-12-03 13:22:30 +01:00
|
|
|
|
(let* ((bmarks
|
|
|
|
|
(mapconcat
|
|
|
|
|
(lambda (bm)
|
|
|
|
|
(let ((query (nth 0 bm)) (title (nth 1 bm)) (key (nth 2 bm)))
|
|
|
|
|
(concat
|
2012-02-14 20:22:02 +01:00
|
|
|
|
"[" (propertize (make-string 1 key)
|
|
|
|
|
'face 'mu4e-view-link-face)
|
|
|
|
|
"]"
|
2011-12-13 08:07:38 +01:00
|
|
|
|
title))) mu4e-bookmarks ", "))
|
2011-12-29 00:25:17 +01:00
|
|
|
|
(kar (read-char (concat prompt bmarks))))
|
|
|
|
|
(mu4e-get-bookmark-query kar)))
|
|
|
|
|
|
|
|
|
|
(defun mu4e-get-bookmark-query (kar)
|
|
|
|
|
"Get the corresponding bookmarked query for shortcut character
|
|
|
|
|
KAR, or raise an error if none is found."
|
|
|
|
|
(let ((chosen-bm
|
|
|
|
|
(find-if
|
|
|
|
|
(lambda (bm)
|
|
|
|
|
(= kar (nth 2 bm)))
|
|
|
|
|
mu4e-bookmarks)))
|
|
|
|
|
(if chosen-bm
|
|
|
|
|
(nth 0 chosen-bm)
|
|
|
|
|
(error "Invalid shortcut '%c'" kar))))
|
2011-12-03 13:22:30 +01:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defun mu4e-new-buffer (bufname)
|
2011-11-05 09:26:24 +01:00
|
|
|
|
"Return a new buffer BUFNAME; if such already exists, kill the
|
|
|
|
|
old one first."
|
|
|
|
|
(when (get-buffer bufname)
|
|
|
|
|
(progn
|
|
|
|
|
(message (format "Killing %s" bufname))
|
|
|
|
|
(kill-buffer bufname)))
|
|
|
|
|
(get-buffer-create bufname))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; converting flags->string and vice-versa ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defun mu4e-flags-to-string (flags)
|
|
|
|
|
"Remove duplicates and sort the output of `mu4e-flags-to-string-raw'."
|
2011-11-05 09:26:24 +01:00
|
|
|
|
(concat
|
2011-12-14 08:13:10 +01:00
|
|
|
|
(sort (remove-duplicates
|
|
|
|
|
(append (mu4e-flags-to-string-raw flags) nil)) '>)))
|
2011-11-05 09:26:24 +01:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defun mu4e-flags-to-string-raw (flags)
|
2011-11-05 09:26:24 +01:00
|
|
|
|
"Convert a list of flags into a string as seen in Maildir
|
|
|
|
|
message files; flags are symbols draft, flagged, new, passed,
|
|
|
|
|
replied, seen, trashed and the string is the concatenation of the
|
|
|
|
|
uppercased first letters of these flags, as per [1]. Other flags
|
|
|
|
|
than the ones listed here are ignored.
|
2011-12-13 08:07:38 +01:00
|
|
|
|
Also see `mu4e-flags-to-string'.
|
2011-11-05 09:26:24 +01:00
|
|
|
|
\[1\]: http://cr.yp.to/proto/maildir.html"
|
|
|
|
|
(when flags
|
|
|
|
|
(let ((kar (case (car flags)
|
|
|
|
|
('draft ?D)
|
|
|
|
|
('flagged ?F)
|
|
|
|
|
('new ?N)
|
|
|
|
|
('passed ?P)
|
|
|
|
|
('replied ?R)
|
|
|
|
|
('seen ?S)
|
|
|
|
|
('trashed ?T)
|
|
|
|
|
('attach ?a)
|
|
|
|
|
('encrypted ?x)
|
|
|
|
|
('signed ?s)
|
|
|
|
|
('unread ?u))))
|
|
|
|
|
(concat (and kar (string kar))
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(mu4e-flags-to-string-raw (cdr flags))))))
|
2011-11-05 09:26:24 +01:00
|
|
|
|
|
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defun mu4e-string-to-flags (str)
|
|
|
|
|
"Remove duplicates from the output of `mu4e-string-to-flags-1'"
|
|
|
|
|
(remove-duplicates (mu4e-string-to-flags-1 str)))
|
2011-11-05 09:26:24 +01:00
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defun mu4e-string-to-flags-1 (str)
|
2011-11-05 09:26:24 +01:00
|
|
|
|
"Convert a string with message flags as seen in Maildir
|
|
|
|
|
messages into a list of flags in; flags are symbols draft,
|
|
|
|
|
flagged, new, passed, replied, seen, trashed and the string is
|
|
|
|
|
the concatenation of the uppercased first letters of these flags,
|
|
|
|
|
as per [1]. Other letters than the ones listed here are ignored.
|
|
|
|
|
Also see `mu/flags-to-string'.
|
|
|
|
|
\[1\]: http://cr.yp.to/proto/maildir.html"
|
|
|
|
|
(when (/= 0 (length str))
|
|
|
|
|
(let ((flag
|
|
|
|
|
(case (string-to-char str)
|
|
|
|
|
(?D 'draft)
|
|
|
|
|
(?F 'flagged)
|
|
|
|
|
(?P 'passed)
|
|
|
|
|
(?R 'replied)
|
|
|
|
|
(?S 'seen)
|
|
|
|
|
(?T 'trashed))))
|
|
|
|
|
(append (when flag (list flag))
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(mu4e-string-to-flags-1 (substring str 1))))))
|
2011-11-20 00:18:12 +01:00
|
|
|
|
|
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(defun mu4e-display-size (size)
|
2011-11-20 00:18:12 +01:00
|
|
|
|
"Get a string representation of SIZE (in bytes)."
|
|
|
|
|
(cond
|
|
|
|
|
((>= size 1000000) (format "%2.1fM" (/ size 1000000.0)))
|
|
|
|
|
((and (>= size 1000) (< size 1000000))
|
|
|
|
|
(format "%2.1fK" (/ size 1000.0)))
|
|
|
|
|
((< size 1000) (format "%d" size))
|
2012-02-14 20:22:02 +01:00
|
|
|
|
(t (propertize "?" 'face 'mu4e-system-face))))
|
2011-11-20 00:18:12 +01:00
|
|
|
|
|
2011-12-19 22:54:08 +01:00
|
|
|
|
|
2012-03-10 15:41:10 +01:00
|
|
|
|
(defun mu4e-body-text (msg)
|
2011-12-19 22:54:08 +01:00
|
|
|
|
"Get the body in text form for this message, which is either :body-txt,
|
|
|
|
|
or if not available, :body-html converted to text. By default, it
|
|
|
|
|
uses the emacs built-in `html2text'. Alternatively, if
|
2012-02-14 20:22:02 +01:00
|
|
|
|
`mu4e-html2text-command' is non-nil, it will use that. Normally,
|
|
|
|
|
function prefers the text part, but this can be changed by setting
|
|
|
|
|
`mu4e-view-prefer-html'."
|
2011-12-20 20:41:31 +01:00
|
|
|
|
(let* ((txt (plist-get msg :body-txt))
|
|
|
|
|
(html (plist-get msg :body-html))
|
2012-02-14 20:22:02 +01:00
|
|
|
|
(body))
|
|
|
|
|
;; is there an appropriate text body?
|
|
|
|
|
(when (and txt
|
|
|
|
|
(not (and mu4e-view-prefer-html html))
|
|
|
|
|
(> (* 10 (length txt))
|
|
|
|
|
(if html (length html) 0))) ;; real text part?
|
|
|
|
|
(setq body txt))
|
|
|
|
|
;; no body yet? try html
|
* make it configurable what to do with sent messages (part 2), and document it:
By default, @t{mu4e} puts a copy of any messages you sent in the folder you
set for @code{mu4e-sent-folder}. In some case, this may not be what you want -
for example, when using GMail+@abbr{IMAP} (but @emph{not} with
GMail+@abbr{POP3}), this interferes with GMail's handling of the sent messages
folder, and you may end up with duplicate messages. For this, since @t{mu4e}
0.9.8.3, there is the variable @code{mu4e-sent-messages-behavior}, which takes
a symbol. The default is @code{'sent} which, as stated causes the message to
be copied to your sent-messages folder. Other possible values are
@code{'trash} (so the sent message is copied to the trash-folder
(@code{mu4e-trash-folder}), and @code{'delete} to simply discard the message
altogether.
2012-03-13 19:13:30 +01:00
|
|
|
|
(unless body
|
2012-02-14 20:22:02 +01:00
|
|
|
|
(when html
|
* make it configurable what to do with sent messages (part 2), and document it:
By default, @t{mu4e} puts a copy of any messages you sent in the folder you
set for @code{mu4e-sent-folder}. In some case, this may not be what you want -
for example, when using GMail+@abbr{IMAP} (but @emph{not} with
GMail+@abbr{POP3}), this interferes with GMail's handling of the sent messages
folder, and you may end up with duplicate messages. For this, since @t{mu4e}
0.9.8.3, there is the variable @code{mu4e-sent-messages-behavior}, which takes
a symbol. The default is @code{'sent} which, as stated causes the message to
be copied to your sent-messages folder. Other possible values are
@code{'trash} (so the sent message is copied to the trash-folder
(@code{mu4e-trash-folder}), and @code{'delete} to simply discard the message
altogether.
2012-03-13 19:13:30 +01:00
|
|
|
|
(setq body
|
2012-02-14 20:22:02 +01:00
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert html)
|
|
|
|
|
;; if defined, use the external tool
|
* make it configurable what to do with sent messages (part 2), and document it:
By default, @t{mu4e} puts a copy of any messages you sent in the folder you
set for @code{mu4e-sent-folder}. In some case, this may not be what you want -
for example, when using GMail+@abbr{IMAP} (but @emph{not} with
GMail+@abbr{POP3}), this interferes with GMail's handling of the sent messages
folder, and you may end up with duplicate messages. For this, since @t{mu4e}
0.9.8.3, there is the variable @code{mu4e-sent-messages-behavior}, which takes
a symbol. The default is @code{'sent} which, as stated causes the message to
be copied to your sent-messages folder. Other possible values are
@code{'trash} (so the sent message is copied to the trash-folder
(@code{mu4e-trash-folder}), and @code{'delete} to simply discard the message
altogether.
2012-03-13 19:13:30 +01:00
|
|
|
|
(if mu4e-html2text-command
|
2012-02-14 20:22:02 +01:00
|
|
|
|
(shell-command-on-region (point-min) (point-max)
|
|
|
|
|
mu4e-html2text-command nil t)
|
|
|
|
|
;; otherwise...
|
|
|
|
|
(html2text))
|
|
|
|
|
(buffer-string)))))
|
|
|
|
|
;; still no body?
|
|
|
|
|
(unless body
|
2012-03-10 11:44:20 +01:00
|
|
|
|
(setq body ""))
|
2011-12-20 20:41:31 +01:00
|
|
|
|
;; and finally, remove some crap from the remaining string.
|
2012-02-06 18:48:56 +01:00
|
|
|
|
(replace-regexp-in-string "[
]" " " body nil nil nil)))
|
2011-12-20 20:41:31 +01:00
|
|
|
|
|
2012-02-28 21:34:22 +01:00
|
|
|
|
(defconst mu4e-update-mail-name "*mu4e-update-mail*"
|
|
|
|
|
"*internal* Name of the process to update mail")
|
2012-02-27 20:48:07 +01:00
|
|
|
|
|
2012-02-28 21:34:22 +01:00
|
|
|
|
(defun mu4e-update-mail (&optional buf)
|
|
|
|
|
"Update mail (retrieve using `mu4e-get-mail-command' and update
|
|
|
|
|
the database afterwards), with output going to BUF if not nil, or
|
|
|
|
|
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."
|
2012-02-27 20:48:07 +01:00
|
|
|
|
(unless mu4e-get-mail-command
|
|
|
|
|
(error "`mu4e-get-mail-command' is not defined"))
|
2012-02-28 21:34:22 +01:00
|
|
|
|
(let* ((process-connection-type t)
|
|
|
|
|
(proc (start-process-shell-command
|
|
|
|
|
mu4e-update-mail-name buf mu4e-get-mail-command)))
|
|
|
|
|
(message "Retrieving mail...")
|
2012-02-27 20:48:07 +01:00
|
|
|
|
(set-process-sentinel proc
|
|
|
|
|
(lambda (proc msg)
|
2012-02-28 21:34:22 +01:00
|
|
|
|
(message nil)
|
|
|
|
|
(mu4e-proc-index mu4e-maildir)
|
2012-02-27 20:48:07 +01:00
|
|
|
|
(let ((buf (process-buffer proc)))
|
2012-02-28 21:34:22 +01:00
|
|
|
|
(when (buffer-live-p buf)
|
|
|
|
|
(kill-buffer buf)))))
|
|
|
|
|
(set-process-query-on-exit-flag proc t)))
|
2012-02-27 20:48:07 +01:00
|
|
|
|
|
2012-02-14 19:25:13 +01:00
|
|
|
|
|
|
|
|
|
(defun mu4e-display-manual ()
|
|
|
|
|
"Display the mu4e manual page for the current mode, or go to the
|
|
|
|
|
top level if there is none."
|
|
|
|
|
(interactive)
|
|
|
|
|
(info (case major-mode
|
|
|
|
|
('mu4e-main-mode "(mu4e)Main view")
|
|
|
|
|
('mu4e-hdrs-mode "(mu4e)Headers view")
|
|
|
|
|
('mu4e-view-mode "(mu4e)Message view")
|
|
|
|
|
(t "mu4e"))))
|
|
|
|
|
|
2011-11-05 09:26:24 +01:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
2011-12-13 08:07:38 +01:00
|
|
|
|
(provide 'mu4e)
|