From 1904deefec3c99f35246f03774df2ed93bf0318c Mon Sep 17 00:00:00 2001
From: Chris Cochrun <chris@tfcconnection.org>
Date: Wed, 24 Feb 2021 09:18:44 -0600
Subject: [PATCH] Adding mu4e config

---
 README.org     | 101 ++++++++++++++++++++++++++++++++++++++++++++++---
 eshell/history |   1 +
 init.el        |  98 ++++++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 188 insertions(+), 12 deletions(-)

diff --git a/README.org b/README.org
index fe4aa3bc..5bf02366 100644
--- a/README.org
+++ b/README.org
@@ -17,6 +17,7 @@
   - [[#fennel][Fennel]]
   - [[#file-management][File Management]]
   - [[#org-mode][Org Mode]]
+  - [[#mu4e][MU4E]]
   - [[#calendar][Calendar]]
   - [[#magit][Magit]]
   - [[#eshell][Eshell]]
@@ -284,7 +285,7 @@ This evil-collection package includes a lot of other evil based things.
    "fb" '((find-file ~/org/bibles/) :which-key "find bible book")
    "fr" '(consult-recent-file :which-key "recent file")
    "fs" '(save-buffer :which-key "save")
-   "hf" '(helpful-function :which-key "describe-function")
+   "hf" '(helpful-callable :which-key "describe-function")
    "hv" '(helpful-variable :which-key "describe-variable")
    "hk" '(helpful-key :which-key "describe-key")
    "hi" '(info :which-key "info manual")
@@ -587,10 +588,10 @@ Part of this config includes some special capture templates for my work as a you
 
   (setq org-capture-templates
   '(("t" "Personal todo" entry
-     (file+headline +org-capture-todo-file "Inbox")
+     (file+headline "todo.org" "Inbox")
      "* TODO %^{TODO name}\nSCHEDULED: %T\n%a\n%i%?" :prepend t)
     ("n" "Personal notes" entry
-     (file+headline +org-capture-notes-file "Inbox")
+     (file+headline "notes.org" "Inbox")
      "* %u %?\n%i\n%a" :prepend t)
     ("j" "Journal" entry
      (file+olp+datetree +org-capture-journal-file)
@@ -638,9 +639,7 @@ Part of this config includes some special capture templates for my work as a you
 
 
   (setq org-agenda-files
-  '("/home/chris/org/DMPREADME.org"
-    "/home/chris/org/DMPTODO.org"
-    "/home/chris/org/inbox.org"
+  '("/home/chris/org/inbox.org"
     "/home/chris/org/notes.org"
     "/home/chris/org/repetition.org"
     "/home/chris/org/tasks.org"
@@ -980,6 +979,96 @@ If on a:
       (org-display-inline-images t t beg end)
       t)))
 #+end_src
+** MU4E
+#+begin_src emacs-lisp
+(use-package mu4e
+  :ensure nil
+  :config
+  (setq mu4e-maildir "~/Maildir"
+	user-full-name "Chris Cochrun"
+	mu4e-change-filenames-when-moving t
+	mu4e-get-mail-command "mbsync -a"
+	mu4e-update-interval (* 15 60)
+	mu4e-attachment-dir "/home/chris/Documents/PersonalImportant/attachments")
+
+  (setq mu4e-contexts
+	(list
+	 (make-mu4e-context
+	  :name "office"
+	  :match-func
+	  (lambda (msg)
+	    (when msg
+	      (string-prefix-p "/office" (mu4e-message-field msg :maildir))))
+	  :vars '((user-mail-address      . "chris@tfcconnection.org")
+		  (mu4e-sent-folder       . "/office/Sent Items/")
+		  (mu4e-drafts-folder     . "/office/Drafts")
+		  (mu4e-trash-folder      . "/office/Deleted Items")
+		  (mu4e-refile-folder     . "/office/Archive")
+		  (smtpmail-smtp-user     . "chris@tfcconnection.org")
+		  (mu4e-compose-signature . "---\nChris Cochrun")))
+	 (make-mu4e-context
+	  :name "outlook"
+	  :match-func
+	  (lambda (msg)
+	    (when msg
+	      (string-prefix-p "/outlook" (mu4e-message-field msg :maildir))))
+	  :vars '((user-mail-address      . "chris.cochrun@outlook.com")
+		  (mu4e-sent-folder       . "/outlook/Sent/")
+		  (mu4e-drafts-folder     . "/outlook/Drafts")
+		  (mu4e-trash-folder      . "/outlook/Deleted")
+		  (mu4e-refile-folder     . "/outlook/Archive")
+		  (smtpmail-smtp-user     . "chris.cochrun@outlook.com")
+		  (mu4e-compose-signature . "---\nChris Cochrun")))
+	 (make-mu4e-context
+	  :name "gmail"
+	  :match-func
+	  (lambda (msg)
+	    (when msg
+	      (string-prefix-p "/gmail" (mu4e-message-field msg :maildir))))
+	  :vars '((user-mail-address      . "ccochrun21@gmail.com")
+		  (mu4e-sent-folder       . "/gmail/[Gmail].Sent Mail/")
+		  (smtpmail-smtp-user     . "ccochrun21@gmail.com")
+		  (mu4e-compose-signature . "---\nChris Cochrun")))))
+
+  ;; Add the ability to send email for o365
+  (setq message-send-mail-function 'smtpmail-send-it
+	starttls-use-gnutls t
+	smtpmail-starttls-credentials '(("smtp.office365.com" 587 nil nil))
+	smtpmail-auth-credentials
+	'(("smtp.office365.com" 587 "chris@tfcconnection.org" nil))
+	smtpmail-default-smtp-server "smtp.office365.com"
+	smtpmail-smtp-server "smtp.office365.com"
+	smtpmail-smtp-service 587)
+
+  ;; shortcuts in the jumplist by pressing "J" in the mu4e buffer
+  (setq mu4e-maildir-shortcuts
+	'((:maildir "/office/Archive"               :key ?a)
+          (:maildir "/office/INBOX"                  :key ?i)
+          (:maildir "/outlook/INBOX"                 :key ?l)
+          (:maildir "/office/Junk Email"             :key ?j)
+          (:maildir "/office/INBOX/Website Forms"    :key ?f)
+          (:maildir "/gmail/INBOX"                   :key ?g)
+          (:maildir "/office/Sent Items"                   :key ?s)))
+
+  ;; (add-to-list mu4e-headers-actions ("org capture message" . mu4e-org-store-and-capture))
+
+  (setq mu4e-bookmarks
+	'((:name "Unread messages"
+		 :query "flag:unread AND NOT flag:trashed AND NOT maildir:\"/outlook/Junk\" AND NOT maildir:\"/office/Junk Email\" AND NOT maildir:\"/outlook/Deleted\" AND NOT maildir:\"/office/Deleted Items\""
+		 :key 117)
+          (:name "Today's messages" :query "date:today..now" :key 116)
+          (:name "Last 7 days" :query "date:7d..now" :hide-unread t :key 119)
+          (:name "Messages with images" :query "mime:image/*" :key 112)))
+
+  (setq mu4e-mu-binary "/usr/bin/mu")
+  (mu4e t)
+  :general
+  (chris/leader-keys
+    "om" 'mu4e))
+
+(use-package org-mime
+  :ensure t)
+#+end_src
 
 ** Calendar
 #+begin_src emacs-lisp
diff --git a/eshell/history b/eshell/history
index 835596fb..e3717a62 100644
--- a/eshell/history
+++ b/eshell/history
@@ -11,3 +11,4 @@ message hello
 12
 2
 ls
+cat /sys/class/power_supply/BAT2/capacity
diff --git a/init.el b/init.el
index f60e274f..5e9e4149 100644
--- a/init.el
+++ b/init.el
@@ -179,7 +179,7 @@
    "fb" '((find-file ~/org/bibles/) :which-key "find bible book")
    "fr" '(consult-recent-file :which-key "recent file")
    "fs" '(save-buffer :which-key "save")
-   "hf" '(helpful-function :which-key "describe-function")
+   "hf" '(helpful-callable :which-key "describe-function")
    "hv" '(helpful-variable :which-key "describe-variable")
    "hk" '(helpful-key :which-key "describe-key")
    "hi" '(info :which-key "info manual")
@@ -351,10 +351,10 @@ vertically."
 
   (setq org-capture-templates
   '(("t" "Personal todo" entry
-     (file+headline +org-capture-todo-file "Inbox")
+     (file+headline "todo.org" "Inbox")
      "* TODO %^{TODO name}\nSCHEDULED: %T\n%a\n%i%?" :prepend t)
     ("n" "Personal notes" entry
-     (file+headline +org-capture-notes-file "Inbox")
+     (file+headline "notes.org" "Inbox")
      "* %u %?\n%i\n%a" :prepend t)
     ("j" "Journal" entry
      (file+olp+datetree +org-capture-journal-file)
@@ -402,9 +402,7 @@ vertically."
 
 
   (setq org-agenda-files
-  '("/home/chris/org/DMPREADME.org"
-    "/home/chris/org/DMPTODO.org"
-    "/home/chris/org/inbox.org"
+  '("/home/chris/org/inbox.org"
     "/home/chris/org/notes.org"
     "/home/chris/org/repetition.org"
     "/home/chris/org/tasks.org"
@@ -711,6 +709,94 @@ If on a:
       (org-display-inline-images t t beg end)
       t)))
 
+(use-package mu4e
+  :ensure nil
+  :config
+  (setq mu4e-maildir "~/Maildir"
+	user-full-name "Chris Cochrun"
+	mu4e-change-filenames-when-moving t
+	mu4e-get-mail-command "mbsync -a"
+	mu4e-update-interval (* 15 60)
+	mu4e-attachment-dir "/home/chris/Documents/PersonalImportant/attachments")
+
+  (setq mu4e-contexts
+	(list
+	 (make-mu4e-context
+	  :name "office"
+	  :match-func
+	  (lambda (msg)
+	    (when msg
+	      (string-prefix-p "/office" (mu4e-message-field msg :maildir))))
+	  :vars '((user-mail-address      . "chris@tfcconnection.org")
+		  (mu4e-sent-folder       . "/office/Sent Items/")
+		  (mu4e-drafts-folder     . "/office/Drafts")
+		  (mu4e-trash-folder      . "/office/Deleted Items")
+		  (mu4e-refile-folder     . "/office/Archive")
+		  (smtpmail-smtp-user     . "chris@tfcconnection.org")
+		  (mu4e-compose-signature . "---\nChris Cochrun")))
+	 (make-mu4e-context
+	  :name "outlook"
+	  :match-func
+	  (lambda (msg)
+	    (when msg
+	      (string-prefix-p "/outlook" (mu4e-message-field msg :maildir))))
+	  :vars '((user-mail-address      . "chris.cochrun@outlook.com")
+		  (mu4e-sent-folder       . "/outlook/Sent/")
+		  (mu4e-drafts-folder     . "/outlook/Drafts")
+		  (mu4e-trash-folder      . "/outlook/Deleted")
+		  (mu4e-refile-folder     . "/outlook/Archive")
+		  (smtpmail-smtp-user     . "chris.cochrun@outlook.com")
+		  (mu4e-compose-signature . "---\nChris Cochrun")))
+	 (make-mu4e-context
+	  :name "gmail"
+	  :match-func
+	  (lambda (msg)
+	    (when msg
+	      (string-prefix-p "/gmail" (mu4e-message-field msg :maildir))))
+	  :vars '((user-mail-address      . "ccochrun21@gmail.com")
+		  (mu4e-sent-folder       . "/gmail/[Gmail].Sent Mail/")
+		  (smtpmail-smtp-user     . "ccochrun21@gmail.com")
+		  (mu4e-compose-signature . "---\nChris Cochrun")))))
+
+  ;; Add the ability to send email for o365
+  (setq message-send-mail-function 'smtpmail-send-it
+	starttls-use-gnutls t
+	smtpmail-starttls-credentials '(("smtp.office365.com" 587 nil nil))
+	smtpmail-auth-credentials
+	'(("smtp.office365.com" 587 "chris@tfcconnection.org" nil))
+	smtpmail-default-smtp-server "smtp.office365.com"
+	smtpmail-smtp-server "smtp.office365.com"
+	smtpmail-smtp-service 587)
+
+  ;; shortcuts in the jumplist by pressing "J" in the mu4e buffer
+  (setq mu4e-maildir-shortcuts
+	'((:maildir "/office/Archive"               :key ?a)
+          (:maildir "/office/INBOX"                  :key ?i)
+          (:maildir "/outlook/INBOX"                 :key ?l)
+          (:maildir "/office/Junk Email"             :key ?j)
+          (:maildir "/office/INBOX/Website Forms"    :key ?f)
+          (:maildir "/gmail/INBOX"                   :key ?g)
+          (:maildir "/office/Sent Items"                   :key ?s)))
+
+  ;; (add-to-list mu4e-headers-actions ("org capture message" . mu4e-org-store-and-capture))
+
+  (setq mu4e-bookmarks
+	'((:name "Unread messages"
+		 :query "flag:unread AND NOT flag:trashed AND NOT maildir:\"/outlook/Junk\" AND NOT maildir:\"/office/Junk Email\" AND NOT maildir:\"/outlook/Deleted\" AND NOT maildir:\"/office/Deleted Items\""
+		 :key 117)
+          (:name "Today's messages" :query "date:today..now" :key 116)
+          (:name "Last 7 days" :query "date:7d..now" :hide-unread t :key 119)
+          (:name "Messages with images" :query "mime:image/*" :key 112)))
+
+  (setq mu4e-mu-binary "/usr/bin/mu")
+  (mu4e t)
+  :general
+  (chris/leader-keys
+    "om" 'mu4e))
+
+(use-package org-mime
+  :ensure t)
+
 (use-package calfw
   :commands chris/calfw-calendar-open
   :config