Move mailing related packages from configuration.org to init.el

This commit is contained in:
Gergely Polonkai 2025-06-03 17:45:37 +02:00
parent f1592e491a
commit ae782630e5
No known key found for this signature in database
GPG Key ID: 38F402C8471DDE93
2 changed files with 109 additions and 125 deletions

View File

@ -1,128 +1,3 @@
* Mailing
** Set up whitespace handling in mu4e buffers
Due to my programming (and maybe a bit of OCD) needs, i set trailing whitespace
to have a red background so it stands out *a lot*. However, many emails contain
a lot of trailing whitespace which makes them really hard to read in Emacs.
The below snippet creates a trailing whitespace face specific to mu4e view
buffers. The accompanying function will be added to ~mu4e-view-mode-hook~.
#+begin_src emacs-lisp
(copy-face 'trailing-whitespace 'trailing-whitespace-mu4e)
(set-face-attribute 'trailing-whitespace-mu4e nil :background 'unspecified)
(defun gpolonkai/mu4e-trailing-whitespace-fix ()
(set (make-local-variable 'face-remapping-alist)
'((trailing-whitespace trailing-whitespace-mu4e))))
#+end_src
** ~mu4e~
Now thats out of the way, lets configure mu4e itself.
#+begin_src emacs-lisp
(use-package mu4e
:after vertico
:ensure nil
:config
(require 'org-mu4e)
(setq mu4e-contexts
`( ,(make-mu4e-context
:name "polonkai.eu"
:enter-func (lambda () (mu4e-message "Entering polonkai.eu Context"))
:leave-func (lambda () (mu4e-message "Leaving polonkai.eu Context"))
:match-func (lambda (msg)
(when msg
(mu4e-message-contact-field-matches
msg
:to "gergely@polonkai.eu")))
:vars '((user-mail-address . "gergely@polonkai.eu")
(mu4e-sent-folder . "/Polonkai/[Gmail].Sent Mail")
(mu4e-drafts-folder . "/Polonkai/[Gmail].Drafts")
(mu4e-trash-folder . "/Polonkai/[Gmail].Bin")
(mu4e-refile-folder . "/Polonkai/[Gmail].Drafts")
(message-sendmail-extra-arguments . ("--account=polonkai"))))
,(make-mu4e-context
:name "Benchmark.games"
:enter-func (lambda () (mu4e-message "Entering Benchmark.games Context"))
:leave-func (lambda () (mu4e-message "Leaving Benchmark.games Context"))
:match-func (lambda (msg)
(when msg
(or
(mu4e-message-contact-field-matches
msg
:to "gergo@gt2.io")
(mu4e-message-contact-field-matches
msg
:to "gergo@benchmarked.games")
(mu4e-message-contact-field-matches
msg
:to "gergo@benchmark.games"))))
:vars '((user-mail-address . "gergely@benchmark.games")
(mu4e-sent-folder . "/GT2/[Gmail].Sent Mail")
(mu4e-drafts-folder . "/GT2/[Gmail].Drafts")
(mu4e-trash-folder . "/GT2/[Gmail].Trash")
(mu4e-refile-folder . "/GT2/[Gmail].Drafts")
(message-sendmail-extra-arguments . ("--account=gt2"))))
,(make-mu4e-context
:name "Private"
:enter-func (lambda () (mu4e-message "Entering Private Context"))
:leave-func (lambda () (mu4e-message "Leaving Private Context"))
:match-func (lambda (msg)
(when msg
(string-match-p "^/Private" (mu4e-message-field msg :maildir))))
:vars '((user-mail-address . "me@gergely.polonkai.eu")
(mu4e-sent-folder . "/Private/Sent")
(mu4e-drafts-folder . "/Private/Drafts")
(mu4e-trash-folder . "/Private/Trash")
(mu4e-refile-folder . "/Private/Drafts")
(message-sendmail-extra-arguments . ("--account=private" "--read-envelope-from")))))
org-mu4e-link-query-in-headers-mode nil)
:custom
(mu4e-context-policy 'pick-first)
(mu4e-confirm-quit nil)
(mail-user-agent 'sendmail-user-agent)
:hook
(mu4e-view-mode . gpolonkai/mu4e-trailing-whitespace-fix)
:bind
(:map gpolonkai/pers-map
("m m" . mu4e)
("m i" . mu4e~headers-jump-to-maildir)
("m c" . mu4e-compose-new)
("m s" . mu4e-headers-search)))
#+end_src
** ~sendmail~
#+begin_src emacs-lisp
(use-package sendmail
:custom
(sendmail-program "/usr/bin/msmtp")
(message-sendmail-f-is-evil t)
(message-sendmail-extra-arguments '("--read-envelope-from"))
(send-mail-function 'sendmail-send-it)
(message-send-mail-function 'message-send-mail-with-sendmail))
#+end_src
** ~org-msg~ to write messages using Org-mode
#+begin_src emacs-lisp
(use-package org-msg
:after mu4e
:defer t
:config
(org-msg-mode)
:custom
(org-msg-supported-mua '((sendmail-user-agent . "mu4e")))
(org-msg-options "html-postamble:nil H:5 num:nil ^:{} toc:nil")
(org-msg-startup "hidestars indent inlineimages")
(org-msg-greeting-fmt "\nHello,\n\n")
(org-msg-greeting-fmt-mailto nil)
(org-msg-signature "\n\nBest,\n\n,#+begin_signature\n-- *Gergely Polonkai* \\\\\n,#+end_signature"))
#+end_src
* External packages to boost coding productivity
** ~electric-operator~ to automatically add spaces around operators

109
init.el
View File

@ -1428,6 +1428,115 @@ order."
(:map dired-mode-map
("K" . dired-k)))
;; Mailing
;; Due to my programming (and maybe a bit of OCD) needs, i set trailing
;; whitespace to have a red background so it stands out *a lot*. However, many
;; emails contain a lot of trailing whitespace which makes them really hard to
;; read in Emacs.
;;
;; The below snippet creates a trailing whitespace face specific to mu4e view
;; buffers. The accompanying function will be added to ~mu4e-view-mode-hook~.
(copy-face 'trailing-whitespace 'trailing-whitespace-mu4e)
(set-face-attribute 'trailing-whitespace-mu4e nil :background 'unspecified)
(defun gpolonkai/mu4e-trailing-whitespace-fix ()
"Change `trailing-whitespace' face for mu4e buffers."
(set (make-local-variable 'face-remapping-alist)
'((trailing-whitespace trailing-whitespace-mu4e))))
(use-package mu4e
:after vertico
:ensure nil
:config
(require 'org-mu4e)
(setq mu4e-contexts
`( ,(make-mu4e-context
:name "polonkai.eu"
:enter-func (lambda () (mu4e-message "Entering polonkai.eu Context"))
:leave-func (lambda () (mu4e-message "Leaving polonkai.eu Context"))
:match-func (lambda (msg)
(when msg
(mu4e-message-contact-field-matches
msg
:to "gergely@polonkai.eu")))
:vars '((user-mail-address . "gergely@polonkai.eu")
(mu4e-sent-folder . "/Polonkai/[Gmail].Sent Mail")
(mu4e-drafts-folder . "/Polonkai/[Gmail].Drafts")
(mu4e-trash-folder . "/Polonkai/[Gmail].Bin")
(mu4e-refile-folder . "/Polonkai/[Gmail].Drafts")
(message-sendmail-extra-arguments . ("--account=polonkai"))))
,(make-mu4e-context
:name "Benchmark.games"
:enter-func (lambda () (mu4e-message "Entering Benchmark.games Context"))
:leave-func (lambda () (mu4e-message "Leaving Benchmark.games Context"))
:match-func (lambda (msg)
(when msg
(or
(mu4e-message-contact-field-matches
msg
:to "gergo@gt2.io")
(mu4e-message-contact-field-matches
msg
:to "gergo@benchmarked.games")
(mu4e-message-contact-field-matches
msg
:to "gergo@benchmark.games"))))
:vars '((user-mail-address . "gergely@benchmark.games")
(mu4e-sent-folder . "/GT2/[Gmail].Sent Mail")
(mu4e-drafts-folder . "/GT2/[Gmail].Drafts")
(mu4e-trash-folder . "/GT2/[Gmail].Trash")
(mu4e-refile-folder . "/GT2/[Gmail].Drafts")
(message-sendmail-extra-arguments . ("--account=gt2"))))
,(make-mu4e-context
:name "Private"
:enter-func (lambda () (mu4e-message "Entering Private Context"))
:leave-func (lambda () (mu4e-message "Leaving Private Context"))
:match-func (lambda (msg)
(when msg
(string-match-p "^/Private" (mu4e-message-field msg :maildir))))
:vars '((user-mail-address . "me@gergely.polonkai.eu")
(mu4e-sent-folder . "/Private/Sent")
(mu4e-drafts-folder . "/Private/Drafts")
(mu4e-trash-folder . "/Private/Trash")
(mu4e-refile-folder . "/Private/Drafts")
(message-sendmail-extra-arguments . ("--account=private" "--read-envelope-from")))))
org-mu4e-link-query-in-headers-mode nil)
:custom
(mu4e-context-policy 'pick-first)
(mu4e-confirm-quit nil)
(mail-user-agent 'sendmail-user-agent)
:hook
(mu4e-view-mode . gpolonkai/mu4e-trailing-whitespace-fix)
:bind
(:map gpolonkai/pers-map
("m m" . mu4e)
("m i" . mu4e~headers-jump-to-maildir)
("m c" . mu4e-compose-new)
("m s" . mu4e-headers-search)))
(use-package sendmail
:custom
(sendmail-program "/usr/bin/msmtp")
(message-sendmail-f-is-evil t)
(message-sendmail-extra-arguments '("--read-envelope-from"))
(send-mail-function 'sendmail-send-it)
(message-send-mail-function 'message-send-mail-with-sendmail))
(use-package org-msg
:after mu4e
:defer t
:config
(org-msg-mode)
:custom
(org-msg-supported-mua '((sendmail-user-agent . "mu4e")))
(org-msg-options "html-postamble:nil H:5 num:nil ^:{} toc:nil")
(org-msg-startup "hidestars indent inlineimages")
(org-msg-greeting-fmt "\nHello,\n\n")
(org-msg-greeting-fmt-mailto nil)
(org-msg-signature "\n\nBest,\n\n,#+begin_signature\n-- *Gergely Polonkai* \\\\\n,#+end_signature"))
;; I started moving my configuration to this Org file. Its easier to document this way.
(org-babel-load-file (expand-file-name "configuration.org" user-emacs-directory))