From 473211bdccf15f3cfd15565fbb91b96c8b8b82e0 Mon Sep 17 00:00:00 2001 From: Emmet Date: Tue, 7 Nov 2023 14:20:41 -0600 Subject: [PATCH] mu4e contexts improvements --- user/app/doom-emacs/config.el | 31 ++++++++++++++++++++++++++++++- user/app/doom-emacs/doom.org | 32 +++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/user/app/doom-emacs/config.el b/user/app/doom-emacs/config.el index 7d89242..9afe109 100644 --- a/user/app/doom-emacs/config.el +++ b/user/app/doom-emacs/config.el @@ -1223,7 +1223,36 @@ https://github.com/magit/magit/issues/460 (@cpitclaudel)." (:maildir . 30) (:from-or-to . 20) (:subject))) -(load "~/.emacs.d/mu4e-private.el") + +(defun my-make-mu4e-context (context-name address catch-address full-name organization-name signature org-roam-db) + (make-mu4e-context + :name context-name + :enter-func (lambda () (mu4e-message (concat "Entering " context-name " context")) + (org-roam-switch-db org-roam-db t) + (setq user-mail-address address) + (setq user-full-name full-name) + (setq message-user-organization organization-name) + (setq mu4e-maildir (concat "~/.mail/" address)) + (setq mu4e-drafts-folder (concat "/" user-mail-address "/Drafts")) + (setq mu4e-sent-folder (concat "/" user-mail-address "/Sent")) + (setq mu4e-trash-folder (concat "/" user-mail-address "/Trash")) + (setq mu4e-compose-signature signature) + ) + :leave-func (lambda () (mu4e-message (concat "Leaving " context-name " context"))) + ;; we match based on the contact-fields of the message + :match-func (lambda (msg) + (when msg + (mu4e-message-contact-field-matches msg + :to catch-address))))) + +(if (file-exists-p "~/.emacs.d/mu4e-private.el") (load! "~/.emacs.d/mu4e-private.el")) +;;(setq mu4e-contexts +;; `( +;; ,(my-make-mu4e-context "example1" "user@example1.com" "user@example1.com" "John Doe" "Example Company" "John Doe\nThis is my signature" "Personal.p") +;; ,(my-make-mu4e-context "example2" "user@example1.com" "user@example2.com" "Johnny" "Example Organization" "John Doe\nThis is my other signature" "Personal.p") +;; )) +;;(mu4e-context-switch t "example1") + (setq sendmail-program "~/.nix-profile/bin/msmtp" send-mail-function 'smtpmail-send-it message-sendmail-f-is-evil t diff --git a/user/app/doom-emacs/doom.org b/user/app/doom-emacs/doom.org index f7d845c..27e988c 100644 --- a/user/app/doom-emacs/doom.org +++ b/user/app/doom-emacs/doom.org @@ -1443,12 +1443,42 @@ I don't have this active right now since it's kinda weird with pgtk... (:maildir . 30) (:from-or-to . 20) (:subject))) -(load "~/.emacs.d/mu4e-private.el") + +(defun my-make-mu4e-context (context-name address catch-address full-name organization-name signature org-roam-db) + (make-mu4e-context + :name context-name + :enter-func (lambda () (mu4e-message (concat "Entering " context-name " context")) + (org-roam-switch-db org-roam-db t) + (setq user-mail-address address) + (setq user-full-name full-name) + (setq message-user-organization organization-name) + (setq mu4e-maildir (concat "~/.mail/" address)) + (setq mu4e-drafts-folder (concat "/" user-mail-address "/Drafts")) + (setq mu4e-sent-folder (concat "/" user-mail-address "/Sent")) + (setq mu4e-trash-folder (concat "/" user-mail-address "/Trash")) + (setq mu4e-compose-signature signature) + ) + :leave-func (lambda () (mu4e-message (concat "Leaving " context-name " context"))) + ;; we match based on the contact-fields of the message + :match-func (lambda (msg) + (when msg + (mu4e-message-contact-field-matches msg + :to catch-address))))) + +(if (file-exists-p "~/.emacs.d/mu4e-private.el") (load! "~/.emacs.d/mu4e-private.el")) +;;(setq mu4e-contexts +;; `( +;; ,(my-make-mu4e-context "example1" "user@example1.com" "user@example1.com" "John Doe" "Example Company" "John Doe\nThis is my signature" "Personal.p") +;; ,(my-make-mu4e-context "example2" "user@example1.com" "user@example2.com" "Johnny" "Example Organization" "John Doe\nThis is my other signature" "Personal.p") +;; )) +;;(mu4e-context-switch t "example1") + (setq sendmail-program "~/.nix-profile/bin/msmtp" send-mail-function 'smtpmail-send-it message-sendmail-f-is-evil t message-sendmail-extra-arguments '("--read-envelope-from") message-send-mail-function 'message-send-mail-with-sendmail) + #+END_SRC ** EAF EAF doesn't work on Wayland :(