* mu4e: replace `mu4e-user-mail-address-regexp' and `mu4e-my-mail-addresses' with `mu4e-user-mail-address-list'

This commit is contained in:
djcb 2012-10-19 16:01:55 +03:00
parent f0be196209
commit 6ccbd45b85
6 changed files with 59 additions and 36 deletions

View File

@ -319,12 +319,12 @@ display may be different)."
being the From: prefix, the cdr element the To: prefix.") being the From: prefix, the cdr element the To: prefix.")
(defsubst mu4e~headers-from-or-to (msg) (defsubst mu4e~headers-from-or-to (msg)
"When the from address for message MSG matches "When the from address for message MSG is one of the the user's addresses,
`mu4e-user-mail-address-regexp', show the To address; otherwise (as per `mu4e-user-mail-address-list'), show the To address;
show the from address; prefixed with the appropriate otherwise ; show the from address; prefixed with the appropriate
`mu4e-headers-from-or-to-prefix'." `mu4e-headers-from-or-to-prefix'."
(let ((addr (cdr-safe (car-safe (mu4e-message-field msg :from))))) (let ((addr (cdr-safe (car-safe (mu4e-message-field msg :from)))))
(if (and addr (string-match mu4e-user-mail-address-regexp addr)) (if (mu4e-user-mail-address-p addr)
(concat (cdr mu4e-headers-from-or-to-prefix) (concat (cdr mu4e-headers-from-or-to-prefix)
(mu4e~headers-contact-str (mu4e-message-field msg :to))) (mu4e~headers-contact-str (mu4e-message-field msg :to)))
(concat (car mu4e-headers-from-or-to-prefix) (concat (car mu4e-headers-from-or-to-prefix)

View File

@ -376,8 +376,8 @@ or (:error ) sexp, which are handled my `mu4e-update-func' and
(defun mu4e~proc-index (path my-addresses) (defun mu4e~proc-index (path my-addresses)
"Update the message database for filesystem PATH, which should "Update the message database for filesystem PATH, which should
point to some maildir directory structure. MY-ADDRESSES is a point to some maildir directory structure. MY-ADDRESSES is a list
list of my email addresses (see e.g. `mu4e-my-email-addresses')." of 'my' email addresses (see `mu4e-user-mail-address-list')."
(let ((addrs (let ((addrs
(when my-addresses (when my-addresses
(mapconcat 'identity my-addresses ",")))) (mapconcat 'identity my-addresses ","))))

View File

@ -62,6 +62,14 @@ hour and minute fields will be nil if not given."
(string-to-number (match-string 2 s)) (string-to-number (match-string 2 s))
nil nil nil) nil nil nil)
(mu4e-error "Not a standard mu4e time string: %s" s))) (mu4e-error "Not a standard mu4e time string: %s" s)))
(defun mu4e-user-mail-address-p (addr)
"If ADDR is one of user's e-mail addresses (as per
`mu4e-user-mail-address-list') return t, otherwise return nil."
(when (and addr mu4e-user-mail-address-list
(find addr mu4e-user-mail-address-list :test 'string=))
t))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -627,7 +635,6 @@ FUNC (if non-nil) afterwards."
(apply 'encode-time (apply 'encode-time
(mu4e-parse-time-string mu4e-compose-complete-only-after))))))))) (mu4e-parse-time-string mu4e-compose-complete-only-after)))))))))
(defun mu4e~stop () (defun mu4e~stop ()
"Stop the mu4e session." "Stop the mu4e session."
(when mu4e~update-timer (when mu4e~update-timer
@ -705,7 +712,7 @@ password."
;; there may be an error, give the user up to 5 seconds to check ;; there may be an error, give the user up to 5 seconds to check
(when maybe-error (when maybe-error
(sit-for 5)) (sit-for 5))
(mu4e~proc-index mu4e-maildir mu4e-my-email-addresses) (mu4e~proc-index mu4e-maildir mu4e-user-mail-address-list)
(when (buffer-live-p buf) (when (buffer-live-p buf)
(kill-buffer buf))))) (kill-buffer buf)))))
(process-put proc 'x-interactive interactive) (process-put proc 'x-interactive interactive)

View File

@ -81,25 +81,41 @@ the arguments may be `nil'."
:group 'mu4e :group 'mu4e
:safe 'stringp) :safe 'stringp)
(defcustom mu4e-user-mail-address-regexp "$^" ;; (defcustom mu4e-user-mail-address-regexp "$^"
"Regular expression matching the user's mail address(es). This is ;; "Regular expression matching the user's mail address(es). This is
used to distinguish ourselves from others, e.g. when replying and ;; used to distinguish ourselves from others, e.g. when replying and
in :from-or-to headers. By default, match nothing." ;; in :from-or-to headers. By default, match nothing."
:type 'regexp ;; :type 'regexp
:group 'mu4e ;; :group 'mu4e
:safe 'stringp) ;; :safe 'stringp)
;; (defcustom mu4e-my-email-addresses `(,user-mail-address)
;; "List of e-mail addresses to consider 'my email addresses',
;; ie. addresses whose presence in an email imply that it is a
;; personal message. This is used when indexing messages."
;; :type '(repeat (string :tag "Address"))
;; :group 'mu4e)
(defcustom mu4e-user-mail-address-list `(,user-mail-address)
"List of e-mail addresses to consider 'my email addresses',
ie. addresses whose presence in an email imply that it is a
personal message. This is used when indexing messages."
:type '(repeat (string :tag "Address"))
:group 'mu4e)
;; don't use the older vars anymore
(make-obsolete-variable 'mu4e-user-mail-address-regexp
'mu4e-user-mail-address-list "0.9.9.x")
(make-obsolete-variable 'mu4e-my-email-addresses
'mu4e-user-mail-address-list "0.9.9.x")
(defcustom mu4e-use-fancy-chars nil (defcustom mu4e-use-fancy-chars nil
"Whether to use fancy (non-ascii) characters." "Whether to use fancy (non-ascii) characters."
:type 'boolean :type 'boolean
:group 'mu4e) :group 'mu4e)
(defcustom mu4e-my-email-addresses `(,user-mail-address)
"List of e-mail addresses to consider 'my email addresses',
ie. addresses whose presence in an email imply that it is a
personal message. This is used when indexing messages."
:type '(repeat (string :tag "Address"))
:group 'mu4e)
(defvar mu4e-date-format-long "%c" (defvar mu4e-date-format-long "%c"
"Date format to use in the message view, in the format of "Date format to use in the message view, in the format of

View File

@ -167,7 +167,7 @@ plist."
(:from-or-to (:from-or-to
(let* ((from (mu4e-message-field msg :from)) (let* ((from (mu4e-message-field msg :from))
(from (and from (cdar from)))) (from (and from (cdar from))))
(if (and from (string-match mu4e-user-mail-address-regexp from)) (if (mu4e-user-mail-address-p from)
(mu4e~view-construct-contacts-header msg :to) (mu4e~view-construct-contacts-header msg :to)
(mu4e~view-construct-contacts-header msg :from)))) (mu4e~view-construct-contacts-header msg :from))))
;; date ;; date

View File

@ -10,7 +10,7 @@
@documentencoding UTF-8 @documentencoding UTF-8
@c %**end of header @c %**end of header
@include version.texi @include ../texi/version.texi
@copying @copying
Copyright @copyright{} 2012 Dirk-Jan C. Binnema Copyright @copyright{} 2012 Dirk-Jan C. Binnema
@ -27,7 +27,7 @@ Documentation License.''
@titlepage @titlepage
@title @t{mu4e} - an e-mail client for emacs @title @t{mu4e} - an e-mail client for emacs
@subtitle{version @value{mu4e-version}} @subtitle{version @value{mu-version}}
@author Dirk-Jan C. Binnema @author Dirk-Jan C. Binnema
@c The following two commands start the copyright page. @c The following two commands start the copyright page.
@ -721,8 +721,8 @@ compact way to convey the most important information: it shows @t{From:}
it shows @t{To:} (prefixed by @t{To}@footnote{You can customize this by it shows @t{To:} (prefixed by @t{To}@footnote{You can customize this by
changing the variable @code{mu4e-headers-from-or-to-prefix} (a cons cell)}, as changing the variable @code{mu4e-headers-from-or-to-prefix} (a cons cell)}, as
in the example above). To determine whether a message was sent by you, in the example above). To determine whether a message was sent by you,
@t{mu4e} uses the variable @code{mu4e-user-mail-address-regexp}, a regular @t{mu4e} uses the variable @code{mu4e-user-mail-address-list}, a list of
expression matching all your e-mail addresses. your e-mail addresses.
@item The letters in the 'Flags' field correspond to the following: D=@emph{draft}, @item The letters in the 'Flags' field correspond to the following: D=@emph{draft},
F=@emph{flagged} (i.e., 'starred'), N=@emph{new}, P=@emph{passed} (i.e., F=@emph{flagged} (i.e., 'starred'), N=@emph{new}, P=@emph{passed} (i.e.,
forwarded), R=@emph{replied}, S=@emph{seen}, T=@emph{trashed}, forwarded), R=@emph{replied}, S=@emph{seen}, T=@emph{trashed},
@ -1296,9 +1296,10 @@ this:
only consider addresses that were seen in @emph{personal} messages -- that is, only consider addresses that were seen in @emph{personal} messages -- that is,
messages in which one of my e-mail addresses was seen in one of the address messages in which one of my e-mail addresses was seen in one of the address
fields. This is to exclude mailing list posts. You can define what is fields. This is to exclude mailing list posts. You can define what is
considered 'my e-mail address' using @code{mu4e-my-email-addresses}, a list considered 'my e-mail address' using @code{mu4e-user-mail-address-list}, a
of e-mail address (defaults to @code{user-mail-address}, and when indexing list of e-mail address (defaults to @code{user-mail-address}, and when
from the command line, the @t{--my-address} parameter for @t{mu index}. indexing from the command line, the @t{--my-address} parameter for @t{mu
index}.
@item @code{mu4e-compose-complete-only-after} - only consider e-mail @item @code{mu4e-compose-complete-only-after} - only consider e-mail
addresses last seen after some date. Parameter is a string, parseable by addresses last seen after some date. Parameter is a string, parseable by
@code{org-parse-time-string}. This excludes old e-mail addresses. The default @code{org-parse-time-string}. This excludes old e-mail addresses. The default
@ -1854,7 +1855,7 @@ message. An example should clarify this:
"mu-discuss@@googlegroups.com") "mu-discuss@@googlegroups.com")
"/mu") "/mu")
;; messages sent directly to me go to /archive ;; messages sent directly to me go to /archive
;; also `mu4e-user-mail-address-regexp' can be used ;; also `mu4e-user-mail-address-p' can be used
((mu4e-message-contact-field-matches msg :to "me@@example.com") ((mu4e-message-contact-field-matches msg :to "me@@example.com")
"/private") "/private")
;; messages with football or soccer in the subject go to /football ;; messages with football or soccer in the subject go to /football
@ -2168,6 +2169,8 @@ shortcuts (@code{mu4e-maildir-shortcuts}), or the full set of available
maildirs. maildirs.
@item @code{mu4e-running-p}: return @code{t} if the @t{mu4e} process is @item @code{mu4e-running-p}: return @code{t} if the @t{mu4e} process is
running, @code{nil} otherwise. running, @code{nil} otherwise.
@item @code{(mu4e-user-mail-address-p addr)}: return @code{t} if @var{addr} is
one of the user's e-mail addresses (as per @code{mu4e-user-mail-address-list}).
@item @code{mu4e-log} logs to the @t{mu4e} debugging log if it is enabled; @item @code{mu4e-log} logs to the @t{mu4e} debugging log if it is enabled;
see @code{mu4e-toggle-logging}. see @code{mu4e-toggle-logging}.
@item @code{mu4e-message}, @code{mu4e-warning}, @code{mu4e-error} are the @item @code{mu4e-message}, @code{mu4e-warning}, @code{mu4e-error} are the
@ -2517,11 +2520,8 @@ customize.
("/work" . ?w) ("/work" . ?w)
("/sent" . ?s))) ("/sent" . ?s)))
;; a regular expression that matches all email addresses used by ;; a list of user's e-mail addresses
;; the user; this allows us to correctly determine if user (setq mu4e-user-mail-address-list '("foo@@bar.com" "cuux@@example.com")
;; is the sender / direct recipient of some message
(setq mu4e-user-mail-address-regexp
"foo@@bar\.com\\|cuux@@example\.com")
;; when you want to use some external command for text->html ;; when you want to use some external command for text->html
;; conversion, e.g. the 'html2text' program ;; conversion, e.g. the 'html2text' program
@ -3127,6 +3127,6 @@ lines. @t{mu} itself keeps a log as well, you can find this it in
@node GNU Free Documentation License @node GNU Free Documentation License
@appendix GNU Free Documentation License @appendix GNU Free Documentation License
@include fdl.texi @include ../texi/fdl.texi
@bye @bye