dotfiles/emacs-lisp/email.org
main 59cec25c12
mu4e: set the context to a default value
Signed-off-by: main <magic_rb@redalder.org>
2021-11-09 12:03:28 +01:00

1.9 KiB

Email

Email is a complicated beast, I decided to use mu4e and mbsync.

smtpmail

  (require 'smtpmail)

  (with-eval-after-load 'smtpmail
    (setq smtpmail-debug-info        t
          message-send-mail-function 'smtpmail-send-it
          smtpmail-stream-type       'starttls))

mu4e

  (let*
      ((mu-path
        (file-name-directory (directory-file-name (file-name-directory (executable-find "mu")))))
       (mu-load-path (concat mu-path "share/emacs/site-lisp/mu4e/")))
    (add-to-list 'load-path mu-load-path))
  (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       "mbsync -a"
           mu4e-update-interval        300
           message-kill-buffer-on-exit t)

    (with-eval-after-load 'evil
      (define-key evil-leader-map "u" 'mu4e))

    (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 (getenv "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))))

mu4e-alert

  (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))