Mu4e: add support for non-@gmail gmail accounts

This commit is contained in:
TEC 2020-10-13 23:36:55 +08:00
parent a8d7d61e44
commit f3daba3471
No known key found for this signature in database
GPG key ID: 779591AFDB81F06C
2 changed files with 15 additions and 4 deletions

View file

@ -127,7 +127,8 @@ sudo apt-get install maildir-utils mu4e # mu and mu4e respectivly
setting ~+org-msg-accent-color~)
+ Gmail integrations with the =+gmail= flag, which account for the different behaviour.
This is applied when using addresses which contain =@gmail.com= or have =gmail= in
the maildir name.
the maildir name. You can use ~+mu4e-gmail-addresses~ when you want an address
to be treated as such but it meets neither conditions (e.g. with Gsuite).
+ Email notifications with =mu4e-alert=, and (on Linux) a customised notification style
* Configuration

View file

@ -364,10 +364,18 @@ Must be set before org-msg is loaded to take effect.")
(when (featurep! +gmail)
(after! mu4e
(defvar +mu4e-gmail-addresses nil
"A list of email addresses which, despite not:
- having '@gmail.com' in them, or
- being in a maildir where the name includes 'gmail'
Should be treated as a gmail address.")
;; don't save message to Sent Messages, Gmail/IMAP takes care of this
(setq mu4e-sent-messages-behavior
(lambda () ;; TODO make use +mu4e-msg-gmail-p
(if (string-match-p "@gmail.com\\'" (message-sendmail-envelope-from))
(if (or (string-match-p "@gmail.com\\'" (message-sendmail-envelope-from))
(member (message-sendmail-envelope-from) +mu4e-gmail-addresses))
'delete 'sent))
;; don't need to run cleanup after indexing for gmail
@ -382,10 +390,12 @@ Must be set before org-msg is loaded to take effect.")
(string-match-p "@gmail.com"
(cond
((member (mu4e-message-field msg :to)
(plist-get mu4e~server-props :personal-addresses))
(append (mu4e-personal-addresses)
+mu4e-gmail-addresses))
(mu4e-message-field msg :to))
((member (mu4e-message-field msg :from)
(plist-get mu4e~server-props :personal-addresses))
(append (mu4e-personal-addresses)
+mu4e-gmail-addresses))
(mu4e-message-field msg :from))
(t "")))
(string-match-p "gmail" (mu4e-message-field msg :maildir))))