diff --git a/+mail.el b/+mail.el index 977997f..7df3ac4 100644 --- a/+mail.el +++ b/+mail.el @@ -1,23 +1,5 @@ ;;; +mail.el -*- lexical-binding: t; -*- -(setq +mu4e-personal-addresses '("me@maxschlueter.com" - "maxsc@fsfe.org")) - -(set-email-account! "mailbox.org" - '((mu4e-sent-folder . "/mailbox.org/Sent") - (mu4e-drafts-folder . "/mailbox.org/Drafts") - (mu4e-trash-folder . "/mailbox.org/Trash") - (mu4e-refile-folder . "/mailbox.org/Archive") - (smtpmail-smtp-user . "me@maxschlueter.com") - (mu4e-maildir-shortcuts - (:maildir "/mailbox.org/Inbox" :key ?i) - (:maildir "/mailbox.org/Sent" :key ?s) - (:maildir "/mailbox.org/Drafts" :key ?d) - (:maildir "/mailbox.org/Trash" :key ?t) - (:maildir "/mailbox.org/Archive" :key ?a)) - (mu4e-compose-signature . nil)) - t) - (after! mu4e ;; Recommended msmtp config from doom module documentation (setq sendmail-program (executable-find "msmtp") @@ -25,39 +7,108 @@ message-sendmail-f-is-evil t message-sendmail-extra-arguments '("--read-envelope-from") message-send-mail-function #'message-send-mail-with-sendmail) - ;; fix https://github.com/hlissner/doom-emacs/issues/3294 - (setq mu4e-attachment-dir "~/Downloads") - ;; Sign sent email automatically - ;; (add-hook 'message-send-hook 'mml-secure-message-sign-smime) + ;; `set-email-account!' doesn't accept a custom match-func + (setq mu4e-contexts + (list (make-mu4e-context + :name "upcycling" + :enter-func + (lambda () (mu4e-message "Switched to upcycling")) + :leave-func + (lambda () (progn (setq +mu4e-personal-addresses nil) + (mu4e-clear-caches))) + :match-func + (lambda (msg) + (when msg + (mu4e-message-contact-field-matches msg + :to "upcycling@fsfe.org"))) + :vars '((user-mail-address . "upcycling@fsfe.org") + (user-full-name . "FSFE Team Upcycling Android"))) + (make-mu4e-context + :name "mailbox" + :enter-func + (lambda () (mu4e-message "Switched to mailbox")) + :leave-func + (lambda () (progn (setq +mu4e-personal-addresses nil) + (mu4e-clear-caches))) + :match-func + (lambda (msg) + (when msg + (string-prefix-p "/mailbox" + (mu4e-message-field msg :maildir) t))) + :vars '((user-mail-address . "me@maxschlueter.com") + (user-full-name . "Max Schlueter") + (+mu4e-personal-addresses ("me@maxschlueter.com") + ("maxsc@fsfe.org")) + )))) - (setq mml-secure-openpgp-encrypt-to-self t) + (setq mu4e-attachment-dir "~/Downloads" + mu4e-sent-folder "/mailbox/Sent" + mu4e-drafts-folder "/mailbox/Drafts" + mu4e-trash-folder "/mailbox/Trash" + mu4e-refile-folder "/mailbox/Archive" + mu4e-compose-signature nil + mu4e-maildir-shortcuts (list (list :maildir "/mailbox/Inbox" + :key ?i) + (list :maildir "/mailbox/Sent" + :key ?s) + (list :maildir "/mailbox/Drafts" + :key ?d) + (list :maildir "/mailbox/Trash" + :key ?t) + (list :maildir "/mailbox/Archive" + :key ?a)) + mu4e-bookmarks (list (list :name "All Inboxes" + :query "maildir:/mailbox/Inbox" + :key ?i) + (list :name "Unread messages" + :query "flag:unread AND NOT flag:trashed" + :key ?u) + (list :name "Today's messages" + :query "date:today..now" + :key ?t) + (list :name "Last 7 days" + :query "date:7d..now" + :hide-unread t + :key ?t))) ;; Render buttons to verify&decrypt messages (setq mm-decrypt-option 'always mm-verify-option 'always - gnus-buttonized-mime-types '("multipart/encrypted" "multipart/signed")) + gnus-buttonized-mime-types '("multipart/encrypted" "multipart/signed") + mml-secure-openpgp-encrypt-to-self t) - (defun max/mu4e-view-import-attachment-calendar (msg attnum) - (let* ((att (mu4e~view-get-attach msg attnum)) - (index (plist-get att :index)) - (docid (mu4e-message-field msg :docid)) - (mtype (plist-get att :mime-type)) - (fname (plist-get att :name)) - (fpath (concat (mu4e~get-attachment-dir fname mtype) "/" fname))) - (if (string= "text/calendar" mtype) - (progn (mu4e~proc-extract 'save docid index mu4e-decryption-policy fpath) - (let ((org-caldav-inbox (max/org-caldav-get-inbox))) - (org-caldav-import-ics-to-org fpath))) - (mu4e-error "Invalid mime-type for a calendar event: `%s'" mtype)))) - ;; XXX - (add-to-list 'mu4e-view-attachment-actions - '("cImport in calendar" . max/mu4e-view-import-attachment-calendar) t) - (add-to-list 'mu4e-bookmarks - (make-mu4e-bookmark - :name "All Inboxes" - :query "maildir:/mailbox.org/Inbox" - :key ?i))) + (add-to-list 'org-capture-templates `("m" "email" entry (file+headline ,(expand-file-name "newgtd/actionable.org" org-directory) "Actions") + "* NEXT Reply to [[mu4e:msgid:%:message-id][%:fromname - %:subject]] :email:\n%U\n")) + + (defun max/mu4e-org-capture () + "Invoke the email capture template for msg at point" + (interactive) + (org-capture nil "m")) + + (map! :map mu4e-headers-mode-map + :vne "l" #'max/mu4e-org-capture) + + ;; Sign sent email automatically + ;; (add-hook 'message-send-hook 'mml-secure-message-sign-smime) + + ) + +;; (defun max/mu4e-view-import-attachment-calendar (msg attnum) +;; (let* ((att (mu4e~view-get-attach msg attnum)) +;; (index (plist-get att :index)) +;; (docid (mu4e-message-field msg :docid)) +;; (mtype (plist-get att :mime-type)) +;; (fname (plist-get att :name)) +;; (fpath (concat (mu4e~get-attachment-dir fname mtype) "/" fname))) +;; (if (string= "text/calendar" mtype) +;; (progn (mu4e~proc-extract 'save docid index mu4e-decryption-policy fpath) +;; (let ((org-caldav-inbox (max/org-caldav-get-inbox))) +;; (org-caldav-import-ics-to-org fpath))) +;; (mu4e-error "Invalid mime-type for a calendar event: `%s'" mtype)))) +;; ;; XXX +;; (add-to-list 'mu4e-view-attachment-actions +;; '("cImport in calendar" . max/mu4e-view-import-attachment-calendar) t) ;; Autoload this command so that the mbsync service can update the index (autoload #'mu4e-update-index "mu4e" nil t) @@ -67,21 +118,10 @@ (interactive) (require 'mu4e) (+workspace-switch +mu4e-workspace-name t) - (mu4e~start (lambda () (mu4e-headers-search (mu4e-get-bookmark-query ?i))))) + (mu4e--start (lambda () (mu4e-headers-search (mu4e-get-bookmark-query ?i))))) (map! "" #'max/=mu4e) -(add-to-list 'org-capture-templates `("m" "email" entry (file+headline ,(expand-file-name "newgtd/actionable.org" org-directory) "Actions") - "* NEXT Reply to [[mu4e:msgid:%:message-id][%:fromname - %:subject]] :email:\n%U\n")) - -(defun max/mu4e-org-capture () - "Invoke the email capture template for msg at point" - (interactive) - (org-capture nil "m")) - -(map! :after mu4e - :map mu4e-headers-mode-map - :vne "l" #'max/mu4e-org-capture) (use-package! jl-encrypt :config