2017-06-08 11:47:56 +02:00
|
|
|
;;; app/email/autoload/email.el -*- lexical-binding: t; -*-
|
2017-04-19 13:18:03 -04:00
|
|
|
|
2018-06-15 17:37:58 +02:00
|
|
|
;;;###autodef
|
|
|
|
(defun set-email-account! (label letvars &optional default-p)
|
|
|
|
"Registers an email address for mu4e. The LABEL is a string. LETVARS are a
|
|
|
|
list of cons cells (VARIABLE . VALUE) -- you may want to modify:
|
|
|
|
|
|
|
|
+ `user-full-name' (this or the global `user-full-name' is required)
|
|
|
|
+ `user-mail-address' (required)
|
|
|
|
+ `smtpmail-smtp-user' (required for sending mail from Emacs)
|
|
|
|
|
|
|
|
OPTIONAL:
|
|
|
|
+ `mu4e-sent-folder'
|
|
|
|
+ `mu4e-drafts-folder'
|
|
|
|
+ `mu4e-trash-folder'
|
|
|
|
+ `mu4e-refile-folder'
|
|
|
|
+ `mu4e-compose-signature'
|
|
|
|
|
|
|
|
DEFAULT-P is a boolean. If non-nil, it marks that email account as the
|
|
|
|
default/fallback account."
|
|
|
|
(after! mu4e
|
2018-06-16 01:12:41 +02:00
|
|
|
(when-let* ((address (cdr (assq 'user-mail-address letvars))))
|
2018-06-15 17:37:58 +02:00
|
|
|
(add-to-list 'mu4e-user-mail-address-list address))
|
|
|
|
(setq mu4e-contexts
|
2018-06-16 01:12:41 +02:00
|
|
|
(cl-loop for context in mu4e-contexts
|
|
|
|
unless (string= (mu4e-context-name context) label)
|
|
|
|
collect context))
|
2018-06-15 17:37:58 +02:00
|
|
|
(let ((context (make-mu4e-context
|
|
|
|
:name label
|
2018-06-16 01:12:41 +02:00
|
|
|
:enter-func (lambda () (mu4e-message "Switched to %s" label))
|
2018-06-15 17:37:58 +02:00
|
|
|
:leave-func (lambda () (mu4e-clear-caches))
|
|
|
|
:match-func
|
|
|
|
(lambda (msg)
|
|
|
|
(when msg
|
2018-06-16 01:12:41 +02:00
|
|
|
(string-prefix-p (format "/%s" label)
|
2018-06-15 17:37:58 +02:00
|
|
|
(mu4e-message-field msg :maildir))))
|
|
|
|
:vars letvars)))
|
|
|
|
(push context mu4e-contexts)
|
|
|
|
(when default-p
|
|
|
|
(setq-default mu4e-context-current context))
|
|
|
|
context)))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(def-setting! :email (label letvars &optional default-p)
|
|
|
|
:obsolete set-email-account!
|
|
|
|
`(set-email-acount! ,label ,letvars ,default-p))
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-18 03:09:39 -05:00
|
|
|
(defvar +email-workspace-name "*mu4e*"
|
|
|
|
"TODO")
|
|
|
|
|
|
|
|
(add-hook 'mu4e-main-mode-hook #'+email|init)
|
|
|
|
|
2017-04-19 13:18:03 -04:00
|
|
|
;;;###autoload
|
|
|
|
(defun =email ()
|
|
|
|
"Start email client."
|
|
|
|
(interactive)
|
2018-02-24 20:26:35 -05:00
|
|
|
(require 'mu4e)
|
2018-02-18 03:09:39 -05:00
|
|
|
(+workspace-switch +email-workspace-name t)
|
|
|
|
(mu4e~start 'mu4e~main-view)
|
|
|
|
;; (save-selected-window
|
|
|
|
;; (prolusion-mail-show))
|
|
|
|
)
|
2017-04-19 13:18:03 -04:00
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +email/compose ()
|
|
|
|
"Compose a new email."
|
|
|
|
(interactive)
|
|
|
|
;; TODO Interactively select email account
|
2017-06-08 11:47:56 +02:00
|
|
|
(call-interactively #'mu4e-compose-new))
|
2017-04-19 13:18:03 -04:00
|
|
|
|
2018-02-18 03:09:39 -05:00
|
|
|
|
|
|
|
;;
|
|
|
|
;; Hooks
|
|
|
|
;;
|
|
|
|
|
|
|
|
(defun +email|init ()
|
|
|
|
(add-hook 'kill-buffer-hook #'+email|kill-mu4e nil t))
|
|
|
|
|
|
|
|
(defun +email|kill-mu4e ()
|
|
|
|
;; (prolusion-mail-hide)
|
|
|
|
(when (+workspace-exists-p +email-workspace-name)
|
|
|
|
(+workspace/delete +email-workspace-name)))
|
|
|
|
|