mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-29 11:36:16 +01:00
2393b63c87
Signed-off-by: magic_rb <magic_rb@redalder.org>
93 lines
3 KiB
Org Mode
93 lines
3 KiB
Org Mode
:PROPERTIES:
|
|
:ID: b9c06fb0-a985-4649-8133-14eeeaa708bc
|
|
:ROAM_REFS: https://jherrlin.github.io/posts/emacs-mu4e/
|
|
:END:
|
|
#+title: Email
|
|
#+filetags: emacs-load
|
|
|
|
# SPDX-FileCopyrightText: 2022 Richard Brežák <richard@brezak.sk>
|
|
#
|
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
Email is a complicated beast, I decided to use *mu4e* and *mbsync*.
|
|
|
|
* smtpmail
|
|
|
|
#+BEGIN_SRC emacs-lisp :results none
|
|
(require 'smtpmail)
|
|
|
|
(with-eval-after-load 'smtpmail
|
|
(setq smtpmail-debug-info t
|
|
message-send-mail-function 'smtpmail-send-it
|
|
smtpmail-stream-type 'starttls))
|
|
#+END_SRC
|
|
|
|
* mu4e
|
|
:PROPERTIES:
|
|
:ID: 9958efaf-51b2-4cee-bf37-c363d1c56055
|
|
:END:
|
|
|
|
#+BEGIN_SRC emacs-lisp :results none
|
|
(add-to-list 'load-path (concat user-emacs-directory "profile/share/emacs/site-lisp/mu4e"))
|
|
(require 'mu4e)
|
|
|
|
(setq auth-sources '((:source "~/.password-store/.authinfo.gpg")))
|
|
(setq auth-source-debug t)
|
|
|
|
(with-eval-after-load 'mu4e
|
|
(setq mu4e-get-mail-command "usbs=$(for dev in /sys/bus/usb/devices/* ; do [ -f ${dev}/idVendor ] && [ -f ${dev}/idProduct ] && ( env cat ${dev}/idVendor | tr -d [:space:] ; printf : ; env cat ${dev}/idProduct ); done) ; yubi=0 ; for usb in $usbs ; do [ $usb = \"1050:0407\" ] && yubi=1 ; done ; [ $yubi = 1 ] && mbsync -a || exit 1"
|
|
mu4e-update-interval 300
|
|
message-kill-buffer-on-exit t)
|
|
|
|
(defun magic_rb/eval-file (file)
|
|
"Execute FILE and return the result of the last expression."
|
|
(eval
|
|
(ignore-errors
|
|
(read-from-whole-string
|
|
(with-temp-buffer
|
|
(insert-file-contents file)
|
|
(buffer-string))))))
|
|
|
|
(setq mu4e-contexts (magic_rb/eval-file "~/.emacs.d/mu4e-contexts")
|
|
;; When Emacs is loading, mu4e will ask for which context to use. Set a default.
|
|
mu4e-context-policy 'pick-first)
|
|
(add-hook 'after-init-hook (lambda () (mu4e t))))
|
|
#+END_SRC
|
|
|
|
By default, when mu4e is asking for messages (be it unread or inbox) it'll ask for related as well, which means if you have a very long thread in your emails, say 100 message long, then that thread will eat up a 100 message spots in the 500 fetched from the mailbox, that is quite annoying. Change the behavior.
|
|
|
|
#+begin_src emacs-lisp
|
|
(setq mu4e-headers-include-related nil)
|
|
#+end_src
|
|
|
|
When in the main screen, it is undesirable to quit mu4e completely as that stops the background email fetching. Make the default behaviour to just close the buffer.
|
|
|
|
#+begin_src emacs-lisp
|
|
(bind-key "q" #'meow-quit mu4e-main-mode-map)
|
|
#+end_src
|
|
|
|
|
|
* mu4e meow
|
|
|
|
Use ~meow~ ~motion~ state in ~mu4e-view-mode~.
|
|
|
|
#+begin_src emacs-lisp
|
|
(use-package mu4e-meow
|
|
:no-require t
|
|
:after (mu4e meow)
|
|
:config
|
|
(add-to-list 'meow-mode-state-list '(mu4e-view-mode . motion)))
|
|
#+end_src
|
|
|
|
* mu4e-alert
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
(use-package mu4e-alert
|
|
:straight t
|
|
:after mu4e
|
|
:config
|
|
(mu4e-alert-set-default-style 'notifications)
|
|
(mu4e-alert-enable-mode-line-display)
|
|
(mu4e-alert-enable-notifications))
|
|
#+END_SRC
|