Created
August 29, 2022 13:13
-
-
Save jiacai2050/67bec14cdc990402c0f6492a402b504b to your computer and use it in GitHub Desktop.
Emacs mu4e config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Mail start | |
(use-package mu4e | |
:ensure nil | |
:if (executable-find "mu") | |
:commands (mu4e) | |
:bind (:map mu4e-view-mode-map | |
("f" . mu4e~headers-jump-to-maildir) | |
("9" . scroll-down-command) | |
("0" . scroll-up-command) | |
("&" . my/open-url-in-external) | |
("<M-return>" . my/open-url-in-new-buffer) | |
("<s-return>" . my/open-url-in-background) | |
("h" . mu4e~headers-jump-to-maildir) | |
:map mu4e-main-mode-map | |
("g" . mu4e-update-mail-and-index) | |
:map mu4e-headers-mode-map | |
("<backspace>" . scroll-down-command) | |
("j" . mu4e-headers-next) | |
("k" . mu4e-headers-prev) | |
("h" . mu4e~headers-jump-to-maildir) | |
("r" . mu4e-headers-mark-for-read) | |
("!" . mu4e-headers-flag-all-read) | |
("f" . mu4e-headers-mark-for-flag) | |
:map mu4e-compose-mode-map | |
("C-c '" . org-mime-edit-mail-in-org-mode)) | |
:custom ((mu4e-headers-fields '((:human-date . 12) | |
(:flags . 6) | |
(:from-or-to . 22) | |
(:thread-subject . nil))) | |
(mu4e-hide-index-messages t)) | |
:init | |
(setq user-mail-address "[email protected]" | |
user-full-name "Jiacai Liu" | |
mail-user-agent 'mu4e-user-agent | |
mu4e-debug nil | |
message-send-mail-function 'smtpmail-send-it | |
;; https://emacs.stackexchange.com/a/45216/16450 | |
message-citation-line-format "\nOn %a, %b %d, %Y at %r %z, %N wrote:\n" | |
message-citation-line-function 'message-insert-formatted-citation-line | |
;; message-cite-style message-cite-style-gmail | |
mml-secure-openpgp-signers '("D3026E5C08A0BAB4") | |
;; https://github.com/djcb/mu/issues/1798 | |
mm-discouraged-alternatives '("text/html" "text/richtext")) | |
:config | |
(setenv "XAPIAN_CJK_NGRAM" "true") | |
(require 'mu4e-contrib) | |
(setq mu4e-contexts | |
(list | |
(make-mu4e-context | |
:name "ljc" | |
:match-func (lambda (msg) | |
(when msg | |
(string-prefix-p "/ljc" (mu4e-message-field msg :maildir)))) | |
:vars '((mu4e-sent-folder . "/ljc/Sent") | |
(mu4e-trash-folder . "/ljc/Trash") | |
(mu4e-refile-folder . "/ljc/Archive") | |
(mu4e-drafts-folder . "/ljc/Drafts") | |
(user-mail-address . "[email protected]") | |
(smtpmail-smtp-service . 465) | |
(smtpmail-smtp-user . "[email protected]") | |
(smtpmail-smtp-server . "smtp.yandex.com") | |
(smtpmail-stream-type . ssl))) | |
(make-mu4e-context | |
:name "yandex" | |
:match-func (lambda (msg) | |
(when msg | |
(string-prefix-p "/yandex" (mu4e-message-field msg :maildir)))) | |
:vars '((mu4e-sent-folder . "/yandex/Sent") | |
(mu4e-trash-folder . "/yandex/Trash") | |
(mu4e-refile-folder . "/yandex/Archive") | |
(mu4e-drafts-folder . "/yandex/Drafts") | |
(user-mail-address . "[email protected]") | |
(smtpmail-smtp-user . "[email protected]") | |
(smtpmail-smtp-service . 465) | |
(smtpmail-smtp-server . "smtp.yandex.com") | |
(smtpmail-stream-type . ssl)))) | |
mu4e-compose-complete-only-personal t | |
mu4e-view-show-addresses t | |
mu4e-view-show-images nil | |
mu4e-attachment-dir "~/Downloads" | |
mu4e-sent-messages-behavior 'sent | |
mu4e-context-policy 'pick-first | |
mu4e-compose-context-policy 'ask-if-none | |
mu4e-compose-dont-reply-to-self t | |
mu4e-confirm-quit nil | |
mu4e-headers-date-format "%+4Y-%m-%d" | |
mu4e-view-date-format "%a, %Y-%m-%d %T" | |
mu4e-view-html-plaintext-ratio-heuristic most-positive-fixnum | |
mu4e-update-interval (* 30 60) | |
;; get mail in external process | |
;; mu4e-get-mail-command "true" | |
mu4e-get-mail-command "gtimeout 120 offlineimap -o -q -u basic -l /tmp/mail.log >> /tmp/imap.log" | |
mu4e-compose-format-flowed t | |
mu4e-completing-read-function 'ivy-read | |
mu4e-bookmarks '((:name "All Inbox" | |
;; :query "maildir:/ljc/INBOX or maildir:/outlook/Inbox" | |
:query "maildir:/ljc/INBOX" | |
:key ?i) | |
(:name "Unread messages" | |
:query "flag:unread AND NOT flag:trashed" | |
:key ?u) | |
(:name "Today's messages" | |
:query "date:today..now" | |
:key ?t) | |
(:name "Last 7 days" | |
:query "date:7d..now" | |
:hide-unread t | |
:key ?w) | |
(:name "Flagged" | |
:query "flag:flagged" | |
:key ?f) | |
(:name "Sent" | |
;; https://github.com/djcb/mu/issues/241 | |
;; :query "maildir:\"/ljc/Sent Messages\"" | |
:query "maildir:/ljc/Sent" | |
:key ?s) | |
(:name "Emacs" | |
:query "maildir:/ljc/Emacs" | |
:key ?e) | |
(:name "Postgres" | |
:query "maildir:/ljc/pg-hackers" | |
:key ?p) | |
(:name "GitHub" | |
:query "maildir:/ljc/GitHub" | |
:key ?g))) | |
(evil-add-hjkl-bindings mu4e-view-mode-map) | |
(add-to-list 'mu4e-view-actions '("browser" . mu4e-action-view-in-browser) t) | |
(defun my/mu4e-pre-update-hook () | |
(let ((inhibit-message t)) | |
(message "Update and index mu4e at %s" (format-time-string "%D %-I:%M %p")))) | |
(defun my/mu4e-stop-update-task () | |
(interactive) | |
(when mu4e--update-timer | |
(cancel-timer mu4e--update-timer) | |
(setq mu4e--update-timer nil))) | |
(setq mu4e-update-pre-hook 'my/mu4e-pre-update-hook) | |
(require 'cl) | |
(require 'org-contacts) | |
(setq mu4e-org-contacts-file my/contacts-file) | |
(add-to-list 'mu4e-headers-actions | |
'("org-contact-add" . mu4e-action-add-org-contact) t) | |
(add-to-list 'mu4e-view-actions | |
'("org-contact-add" . mu4e-action-add-org-contact) t) | |
(add-to-list 'mu4e-view-fields :bcc)) | |
(use-package message | |
:ensure nil | |
:defer t | |
:hook (message-send . my/sign-or-encrypt-message) | |
:init | |
(defun my/sign-or-encrypt-message () | |
(let ((answer (read-from-minibuffer "Sign or encrypt?[s/e]: "))) | |
(cond | |
((string-equal answer "s") (progn | |
(message "Signing message.") | |
(mml-secure-message-sign-pgpmime))) | |
((string-equal answer "e") (progn | |
(message "Encrypt and signing message.") | |
(mml-secure-message-encrypt-pgpmime))) | |
(t (progn | |
(message "Dont signing or encrypting message.") | |
nil)))))) | |
;; Mail end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment