Get the mail system working again.

Wrapping code in `use-package` expressions instead of `noweb`
references, allows me to execute sections, resulting in
easier-to-maintain code.
This commit is contained in:
Howard Abrams 2024-09-28 08:35:56 -07:00
parent 71168110e0
commit ffe662ced0

View file

@ -97,7 +97,9 @@ Next, we need some basic configuration settings and some global keybindings:
:map notmuch-tree-mode-map :map notmuch-tree-mode-map
("C" . notmuch-mua-new-mail))) ("C" . notmuch-mua-new-mail)))
#+end_src #+end_src
And some leader-based keybindings: And some leader-based keybindings:
#+begin_src emacs-lisp :noweb yes #+begin_src emacs-lisp :noweb yes
(use-package notmuch (use-package notmuch
:config :config
@ -105,19 +107,17 @@ And some leader-based keybindings:
"a n" '("new mail" . notmuch-retrieve-messages) "a n" '("new mail" . notmuch-retrieve-messages)
"a c" '("compose mail" . compose-mail)) "a c" '("compose mail" . compose-mail))
(major-mode-hydra-define notmuch-hello-mode nil (major-mode-hydra-define notmuch-hello-mode (:quit-key "q")
("Mail" ("Mail"
(("u" notmuch-retrieve-messages "new mail") (("u" notmuch-retrieve-messages "new mail")
("m" notmuch "read mail")) ("m" notmuch "read mail"))
"Messages" "Messages"
(("c" notmuch-mua-new-mail "compose") (("c" notmuch-mua-new-mail "compose")
("C" hey-notmuch-reply-later "reply-later")))) ("C" hey-notmuch-reply-later "reply-later")))))
<<hey-show-keybindings>>
<<hey-search-keybindings>>)
#+end_src #+end_src
Also, let's do some basic configuration of Emacs' mail system: Also, let's do some basic configuration of Emacs' mail system:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq mm-text-html-renderer 'shr (setq mm-text-html-renderer 'shr
mail-specify-envelope-from t mail-specify-envelope-from t
@ -138,6 +138,8 @@ Do I want to sign messages by default? Nope.
** Addresses ** Addresses
I need to incorporate an address book again, but in the meantime, searching through a history of past email works well enough. I need to incorporate an address book again, but in the meantime, searching through a history of past email works well enough.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package notmuch
:config
(setq notmuch-address-selection-function (setq notmuch-address-selection-function
(lambda (prompt collection initial-input) (lambda (prompt collection initial-input)
(completing-read prompt (completing-read prompt
@ -145,7 +147,7 @@ I need to incorporate an address book again, but in the meantime, searching thro
nil nil
t t
nil nil
'notmuch-address-history))) 'notmuch-address-history))))
#+end_src #+end_src
** Sending Messages ** Sending Messages
Do I need to set up [[https://marlam.de/msmtp/][MSMTP]]? No, as Notmuch will do that work. Do I need to set up [[https://marlam.de/msmtp/][MSMTP]]? No, as Notmuch will do that work.
@ -173,6 +175,7 @@ There are global settings:
The following section is for my /personal/ (not too general) account. The following section is for my /personal/ (not too general) account.
The file generally can have a =Pass= entry for the encrypted passcode, but to show how to connect to more than one accounts, I'm using a GPG daemon: The file generally can have a =Pass= entry for the encrypted passcode, but to show how to connect to more than one accounts, I'm using a GPG daemon:
#+begin_src conf :tangle ~/.mbsyncrc :noweb yes #+begin_src conf :tangle ~/.mbsyncrc :noweb yes
# PERSONAL ACCOUNT # PERSONAL ACCOUNT
IMAPAccount personal IMAPAccount personal
@ -439,6 +442,8 @@ To allow me to keep Vedang's and my code side-by-side in the same Emacs variable
A list of pre-defined searches act like "Folder buttons" at the top to quickly see files that match those /buckets/: A list of pre-defined searches act like "Folder buttons" at the top to quickly see files that match those /buckets/:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package notmuch
:config
(setq notmuch-saved-searches '((:name "Imbox" (setq notmuch-saved-searches '((:name "Imbox"
:query "tag:inbox AND tag:screened AND tag:unread" :query "tag:inbox AND tag:screened AND tag:unread"
:key "i" :key "i"
@ -470,7 +475,7 @@ A list of pre-defined searches act like "Folder buttons" at the top to quickly s
;; notmuch-saved-searches) ;; notmuch-saved-searches)
(:name "Old Projects" (:name "Old Projects"
:query "tag:old-project AND NOT tag:unread" :query "tag:old-project AND NOT tag:unread"
:key "X"))) :key "X"))))
#+end_src #+end_src
** Helper Functions ** Helper Functions
@ -637,20 +642,24 @@ This means:
** Bucket Keybindings ** Bucket Keybindings
A series of keybindings to quickly send messages to one of the pre-defined buckets. A series of keybindings to quickly send messages to one of the pre-defined buckets.
#+name: hey-show-keybindings #+name: hey-show-keybindings
#+begin_src emacs-lisp :tangle no #+begin_src emacs-lisp
(major-mode-hydra-define notmuch-show-mode nil (use-package notmuch
:config
(major-mode-hydra-define notmuch-show-mode (:quit-key "q")
("Messages" ("Messages"
(("c" notmuch-mua-new-mail "compose") (("c" notmuch-mua-new-mail "compose")
("C" hey-notmuch-reply-later "reply-later")))) ("C" hey-notmuch-reply-later "reply-later"))))
(define-key notmuch-show-mode-map (kbd "C") 'hey-notmuch-reply-later) (define-key notmuch-show-mode-map (kbd "C") 'hey-notmuch-reply-later))
#+end_src #+end_src
The bindings in =notmuch-search-mode= are available when looking at a list of messages: The bindings in =notmuch-search-mode= are available when looking at a list of messages:
#+name: hey-search-keybindings #+name: hey-search-keybindings
#+begin_src emacs-lisp :tangle no #+begin_src emacs-lisp
(major-mode-hydra-define notmuch-search-mode nil (use-package notmuch
:config
(major-mode-hydra-define notmuch-search-mode (:color blue :title "Notmuch")
("Mail" ("Mail"
(("r" notmuch-search-reply-to-thread "reply") (("r" notmuch-search-reply-to-thread "reply")
("R" notmuch-search-reply-to-thread-sender "reply-all") ("R" notmuch-search-reply-to-thread-sender "reply-all")
@ -667,7 +676,7 @@ The bindings in =notmuch-search-mode= are available when looking at a list of me
("p" hey-notmuch-move-sender-to-papertrail "send to papertrail") ("p" hey-notmuch-move-sender-to-papertrail "send to papertrail")
("f" hey-notmuch-move-sender-to-thefeed "send to feed") ("f" hey-notmuch-move-sender-to-thefeed "send to feed")
("C" hey-notmuch-reply-later "reply") ("C" hey-notmuch-reply-later "reply")
("c" notmuch-mua-new-mail) "compose"))) ("c" notmuch-mua-new-mail "compose"))))
;; And if I can remember the keybindings... ;; And if I can remember the keybindings...
(define-key notmuch-search-mode-map (kbd "r") 'notmuch-search-reply-to-thread) (define-key notmuch-search-mode-map (kbd "r") 'notmuch-search-reply-to-thread)
@ -683,7 +692,7 @@ The bindings in =notmuch-search-mode= are available when looking at a list of me
(define-key notmuch-search-mode-map (kbd "I") 'hey-notmuch-move-sender-to-screened) (define-key notmuch-search-mode-map (kbd "I") 'hey-notmuch-move-sender-to-screened)
(define-key notmuch-search-mode-map (kbd "P") 'hey-notmuch-move-sender-to-papertrail) (define-key notmuch-search-mode-map (kbd "P") 'hey-notmuch-move-sender-to-papertrail)
(define-key notmuch-search-mode-map (kbd "f") 'hey-notmuch-move-sender-to-thefeed) (define-key notmuch-search-mode-map (kbd "f") 'hey-notmuch-move-sender-to-thefeed)
(define-key notmuch-search-mode-map (kbd "C") 'hey-notmuch-reply-later) (define-key notmuch-search-mode-map (kbd "C") 'hey-notmuch-reply-later))
#+end_src #+end_src
** Org Integration ** Org Integration
The gods ordained that Mail and Org should dance together, so step one is composing mail with org: The gods ordained that Mail and Org should dance together, so step one is composing mail with org: