summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2023-03-15 09:46:54 +0100
committerRicardo Wurmus <rekado@elephly.net>2023-03-15 09:46:54 +0100
commit43f07324c6bbf7a563fb22ddeff5c137d19eeb72 (patch)
tree3efed5dbe845ef56792640804634e295366aa691
parent46b801f8f56ac85d6cab2fd66213153191624906 (diff)
Transform mu4e config to use use-package.
-rw-r--r--init.org354
1 files changed, 184 insertions, 170 deletions
diff --git a/init.org b/init.org
index 77e2d9a..0163848 100644
--- a/init.org
+++ b/init.org
@@ -890,48 +890,7 @@ TODO: the parentheses adjustments should happen only when I’m in programming m
TODO: this is a big blob of email configuration. Document this properly!
-#+BEGIN_SRC elisp
-(require 'mu4e)
-(require 'org-mu4e)
-(require 'mu4e-contrib)
-
-(setq shr-color-visible-luminance-min 30)
-
-(setq mu4e-get-mail-command "/home/rekado/.guix-home/profile/bin/mbsync -c /home/rekado/.config/mbsync.conf -a"
- mu4e-compose-signature-auto-include t
- mu4e-compose-dont-reply-to-self t
- mu4e-update-interval nil
- mu4e-headers-include-related t)
-
-(setq mu4e-use-fancy-chars t)
-(setq mu4e-headers-seen-mark '("" . ""))
-(setq mu4e-headers-unread-mark '("u" . "✉"))
-
-;; Don't update list of emails automatically. I update the list
-;; manually with "g".
-(setq mu4e-headers-auto-update nil)
-
-;; Rename files when moving. This is NEEDED when using mbsync or else
-;; there is a problem of duplicate UIDs!
-(setq mu4e-change-filenames-when-moving t)
-
-(setq mu4e-view-show-addresses t)
-(setq mu4e-hide-index-messages t)
-(setq mu4e-html2text-command 'mu4e-shr2text)
-(setq mu4e-view-show-images t)
-
-;; use imagemagick, if available
-(when (fboundp 'imagemagick-register-types)
- (imagemagick-register-types))
-
-(setq mu4e-attachment-dir "~/Downloads")
-
-;; pretty quotes!
-(add-hook 'message-mode-hook
- (lambda ()
- (require 'typo)
- (typo-mode 1)))
-
+#+begin_src elisp
(defun my/set-mu4e-bookmarks (maildir)
(let ((guix "(list:guix-devel.gnu.org OR list:bug-guix.gnu.org OR list:help-guix.gnu.org OR list:guix-sysadmin.gnu.org OR list:guix-security.gnu.org OR list:guix-patches.gnu.org OR list:guix-commits.gnu.org)")
(guile "(list:guile-user.gnu.org OR list:guile-devel.gnu.org OR list:bug-guile.gnu.org)")
@@ -973,143 +932,198 @@ TODO: this is a big blob of email configuration. Document this properly!
"Unread list messages" ?m)
(list (concat "maildir:\"/" maildir "/INBOX\" flag:flagged")
"Flagged" ?f)))))
+#+end_src
-; set up email sending with msmtp
-(setq mail-user-agent 'mu4e-user-agent)
-(setq mail-specify-envelope-from t)
-(setq mail-envelope-from 'header)
-
-(setq message-kill-buffer-on-exit t)
-(setq message-sendmail-envelope-from 'header)
-(setq message-send-mail-function 'message-send-mail-with-sendmail)
-
-;;use msmtp instead of sendmail
-(setq sendmail-program "~/.guix-home/profile/bin/msmtp")
-
-;; Crypto
-(setq mml-secure-openpgp-encrypt-to-self t)
-(setq mml-secure-openpgp-sign-with-sender t)
-
-(add-hook 'mu4e-compose-mode-hook
- (defun my/maybe-reply-encrypted ()
- "Encrypt automatically if parent message was also encrypted."
- (let ((msg mu4e-compose-parent-message))
- (when (and msg
- (or (member 'encrypted (mu4e-message-field msg :flags))
- (string-match "-----BEGIN PGP MESSAGE-----$"
- (mu4e-message-field msg :body-txt))))
- (mml-secure-message-sign-encrypt)))))
-
- (add-hook 'mu4e-compose-mode-hook
- (defun my/mu4e-add-headers ()
- "Add some personal headers."
- (save-excursion
- (message-add-header "X-URL: https://elephly.net\n")
- (message-add-header "X-PGP-Key: https://elephly.net/rekado.pubkey\n")
- (message-add-header "X-PGP-Fingerprint: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC"))))
-
-;; Don't open a new window to show the results of signature validation
-(setq epa-popup-info-window nil)
-
-(require 'mu4e-actions)
-(add-to-list 'mu4e-view-actions
- '("git am" . mu4e-action-git-apply-mbox))
-(add-to-list 'mu4e-headers-actions
- '("git am" . mu4e-action-git-apply-mbox))
-(add-to-list 'mu4e-view-actions
- '("retag message" . mu4e-action-retag-message) t)
-;; Don't ask for a 'context' upon opening mu4e
-(setq mu4e-context-policy 'pick-first)
-;; Don't ask to quit
-(setq mu4e-confirm-quit nil)
-#+END_SRC
+#+begin_src elisp
+(defun my/maybe-reply-encrypted ()
+ "Encrypt automatically if parent message was also encrypted."
+ (let ((msg mu4e-compose-parent-message))
+ (when (and msg
+ (or (member 'encrypted (mu4e-message-field msg :flags))
+ (string-match "-----BEGIN PGP MESSAGE-----$"
+ (mu4e-message-field msg :body-txt))))
+ (mml-secure-message-sign-encrypt))))
+#+end_src
-I read and write email in different contexts. This is my context for private email:
+#+begin_src elisp
+(defun my/mu4e-add-headers ()
+ "Add some personal headers."
+ (save-excursion
+ (message-add-header "X-URL: https://elephly.net\n")
+ (message-add-header "X-PGP-Key: https://elephly.net/rekado.pubkey\n")
+ (message-add-header "X-PGP-Fingerprint: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC")))
+#+end_src
-#+BEGIN_SRC elisp
-(setq my/mu4e-context-private
- (make-mu4e-context
- :name "Private"
- :enter-func
- (lambda ()
- (mu4e-message "Switch to the Private context")
- (my/set-mu4e-bookmarks "private"))
- :match-func
- (lambda (msg)
- (when msg
- (or (mu4e-message-contact-field-matches
- msg :to (rot13 "erxnqb@ryrcuyl.arg"))
- (mu4e-message-contact-field-matches
- msg :from (rot13 "erxnqb@ryrcuyl.arg"))
- ;; Additional check if this is a mailing list email.
- (and (mu4e-message-field msg :mailing-list)
- (zerop (call-process "grep" nil nil nil
- "-E" "^Delivered-To: .*elephly.net"
- (mu4e-message-field msg :path)))))))
- :vars
- `((user-mail-address . ,(rot13 "erxnqb@ryrcuyl.arg"))
- (user-full-name . ,(rot13 "Evpneqb Jhezhf"))
- (mu4e-sent-folder . "/private/Sent")
- (mu4e-trash-folder . "/private/Trash")
- (mu4e-refile-folder . "/private/Archives")
- (mu4e-drafts-folder . "/private/Drafts")
- (mu4e-compose-signature . "Ricardo"))))
-#+END_SRC
+#+begin_src elisp
+(use-package mu4e
+ :bind
+ ("<f12>" . mu4e)
+ :after (epa message)
+ :config
+ (setq my/mu4e-context-private
+ (make-mu4e-context
+ :name "Private"
+ :enter-func
+ (lambda ()
+ (mu4e-message "Switch to the Private context")
+ (my/set-mu4e-bookmarks "private"))
+ :match-func
+ (lambda (msg)
+ (when msg
+ (or (mu4e-message-contact-field-matches
+ msg :to (rot13 "erxnqb@ryrcuyl.arg"))
+ (mu4e-message-contact-field-matches
+ msg :from (rot13 "erxnqb@ryrcuyl.arg"))
+ ;; Additional check if this is a mailing list email.
+ (and (mu4e-message-field msg :mailing-list)
+ (zerop (call-process "grep" nil nil nil
+ "-E" "^Delivered-To: .*elephly.net"
+ (mu4e-message-field msg :path)))))))
+ :vars
+ `((user-mail-address . ,(rot13 "erxnqb@ryrcuyl.arg"))
+ (user-full-name . ,(rot13 "Evpneqb Jhezhf"))
+ (mu4e-sent-folder . "/private/Sent")
+ (mu4e-trash-folder . "/private/Trash")
+ (mu4e-refile-folder . "/private/Archives")
+ (mu4e-drafts-folder . "/private/Drafts")
+ (mu4e-compose-signature . "Ricardo"))))
+ (setq my/mu4e-context-work
+ (make-mu4e-context
+ :name "Work"
+ :enter-func
+ (lambda ()
+ (mu4e-message "Switch to the Work context")
+ (my/set-mu4e-bookmarks "mdc-personal"))
+ :match-func
+ (lambda (msg)
+ (when msg
+ (or (mu4e-message-contact-field-matches
+ msg :to (rot13 "evpneqb.jhezhf@zqp-oreyva.qr"))
+ (mu4e-message-contact-field-matches
+ msg :from (rot13 "evpneqb.jhezhf@zqp-oreyva.qr"))
+ ;; Additional check if this is a mailing list email.
+ (and (mu4e-message-field msg :mailing-list)
+ (zerop (call-process "grep" nil nil nil
+ "-E" "^Received: from .*mdc-berlin.de"
+ (mu4e-message-field msg :path)))))))
+ :vars
+ `((user-mail-address . ,(rot13 "evpneqb.jhezhf@zqp-oreyva.qr"))
+ (user-full-name . ,(rot13 "Evpneqb Jhezhf"))
+ (mu4e-sent-folder . "/mdc-personal/Sent Items")
+ (mu4e-trash-folder . "/mdc-personal/Deleted Items")
+ (mu4e-refile-folder . "/mdc-personal/Archive")
+ (mu4e-drafts-folder . "/mdc-personal/Drafts")
+ (mu4e-compose-signature
+ . ,(rot13 (concat "Evpneqb Jhezhf\n\n"
+ "Flfgrz nqzvavfgengbe\n"
+ "OVZFO - Fpvragvsvp Ovbvasbezngvpf Cyngsbez\n"
+ "Znk Qryoehrpx Pragre sbe Zbyrphyne Zrqvpvar\n\n"
+
+ "rznvy: evpneqb.jhezhf@zqp-oreyva.qr\n"
+ (concat "gry: +49 30 9406 "
+ (number-to-string (+ (* 1 2 2 3 4 5 6)
+ (expt 2 8)
+ 100)))))))))
+ (setq mu4e-contexts
+ (list my/mu4e-context-private
+ my/mu4e-context-work))
+ (setq mu4e-get-mail-command
+ "/home/rekado/.guix-home/profile/bin/mbsync -c /home/rekado/.config/mbsync.conf -a")
+ ;; Rename files when moving. This is NEEDED when using mbsync or
+ ;; else there is a problem of duplicate UIDs!
+ (setq mu4e-change-filenames-when-moving t)
+
+ (setq mu4e-attachment-dir "~/Downloads")
+ (setq mu4e-completing-read-function 'completing-read)
+ (setq mu4e-compose-dont-reply-to-self t)
+ (setq mu4e-compose-signature-auto-include t)
+ ;; Don't update list of emails automatically. I update the list
+ ;; manually with "g".
+ (setq mu4e-headers-auto-update nil)
+ (setq mu4e-headers-include-related t)
+ (setq mu4e-headers-seen-mark '("" . ""))
+ (setq mu4e-headers-unread-mark '("u" . "✉"))
+ (setq mu4e-hide-index-messages t)
+ (setq mu4e-html2text-command 'mu4e-shr2text)
+ (setq mu4e-update-interval nil)
+ (setq mu4e-use-fancy-chars t)
+ (setq mu4e-view-show-addresses t)
+ (setq mu4e-view-show-images t)
+
+ ;; Don't ask to quit
+ (setq mu4e-confirm-quit nil)
+ ;; Don't ask for a 'context' upon opening mu4e
+ (setq mu4e-context-policy 'pick-first)
+
+ ;; set up email sending with msmtp
+ (setq mail-user-agent 'mu4e-user-agent)
+ (setq mail-specify-envelope-from t)
+ (setq mail-envelope-from 'header)
+
+ ;; use msmtp instead of sendmail
+ (setq sendmail-program "~/.guix-home/profile/bin/msmtp")
+
+ ;; Crypto
+ (setq mml-secure-openpgp-encrypt-to-self t)
+ (setq mml-secure-openpgp-sign-with-sender t)
+
+ ;; Don't open a new window to show the results of signature validation
+ (setq epa-popup-info-window nil)
+
+ (setq shr-color-visible-luminance-min 40)
+ ;; use imagemagick, if available
+ (when (fboundp 'imagemagick-register-types)
+ (imagemagick-register-types))
-And here’s the context for work email:
+ :hook
+ ((mu4e-compose-mode
+ . #'my/mu4e-add-headers)
+ (mu4e-compose-mode
+ . #'my/maybe-reply-encrypted)))
+#+end_src
-#+BEGIN_SRC elisp
-(setq my/mu4e-context-work
- (make-mu4e-context
- :name "Work"
- :enter-func
- (lambda ()
- (mu4e-message "Switch to the Work context")
- (my/set-mu4e-bookmarks "mdc-personal"))
- :match-func
- (lambda (msg)
- (when msg
- (or (mu4e-message-contact-field-matches
- msg :to (rot13 "evpneqb.jhezhf@zqp-oreyva.qr"))
- (mu4e-message-contact-field-matches
- msg :from (rot13 "evpneqb.jhezhf@zqp-oreyva.qr"))
- ;; Additional check if this is a mailing list email.
- (and (mu4e-message-field msg :mailing-list)
- (zerop (call-process "grep" nil nil nil
- "-E" "^Received: from .*mdc-berlin.de"
- (mu4e-message-field msg :path)))))))
- :vars
- `((user-mail-address . ,(rot13 "evpneqb.jhezhf@zqp-oreyva.qr"))
- (user-full-name . ,(rot13 "Evpneqb Jhezhf"))
- (mu4e-sent-folder . "/mdc-personal/Sent Items")
- (mu4e-trash-folder . "/mdc-personal/Deleted Items")
- (mu4e-refile-folder . "/mdc-personal/Archive")
- (mu4e-drafts-folder . "/mdc-personal/Drafts")
- (mu4e-compose-signature . ,(rot13 (concat "Evpneqb Jhezhf\n\n"
-"Flfgrz nqzvavfgengbe\n"
-"OVZFO - Fpvragvsvp Ovbvasbezngvpf Cyngsbez\n"
-"Znk Qryoehrpx Pragre sbe Zbyrphyne Zrqvpvar\n\n"
-
-"rznvy: evpneqb.jhezhf@zqp-oreyva.qr\n"
-(concat "gry: +49 30 9406 " (number-to-string (+ (* 1 2 2 3 4 5 6) (expt 2 8) 100)))))))))
-#+END_SRC
+Enable buttons to reply to icalendar invitations:
-When I’m using the workstation in the office, all I want is the work context.
+#+begin_src elisp
+(use-package mu4e-icalendar
+ :after mu4e
+ :init
+ (mu4e-icalendar-setup))
+#+end_src
-#+BEGIN_SRC elisp
-(setq mu4e-contexts
- (if (string= (system-name) (rot13 "ovzfo-flf02.zqp-oreyva.arg"))
- (list my/mu4e-context-work)
- (list my/mu4e-context-private
- my/mu4e-context-work)))
-#+END_SRC
+Integrate mu4e with Org mode.
+
+#+begin_src elisp
+(use-package org-mu4e
+ :after (org-mode mu4e))
+#+end_src
-Load all of this email configuration code only when I start =mu4e=.
+#+begin_src elisp
+(use-package mu4e-actions
+ :after mu4e
+ :init
+ (add-to-list 'mu4e-view-actions
+ '("git am" . mu4e-action-git-apply-mbox))
+ (add-to-list 'mu4e-headers-actions
+ '("git am" . mu4e-action-git-apply-mbox))
+ (add-to-list 'mu4e-view-actions
+ '("retag message" . mu4e-action-retag-message) t))
+#+end_src
-#+BEGIN_SRC elisp
-(require 'mu4e)
-(global-set-key (kbd "<f12>") 'mu4e)
-#+END_SRC
+#+begin_src elisp
+(use-package message
+ :custom
+ (message-kill-buffer-on-exit t)
+ (message-sendmail-envelope-from 'header)
+ (message-send-mail-function 'message-send-mail-with-sendmail))
+
+;; TODO: move this elsewhere
+(use-package typo
+ :hook
+ ((message-mode
+ org-mode
+ erc-mode) . typo-mode))
+#+end_src
* TODO More stuff