Fix set-email-account! & minor refactor

Mentioned by @myme
This commit is contained in:
Henrik Lissner 2018-06-16 01:12:41 +02:00
parent 1cfc146e3a
commit 9c748600a5
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -19,19 +19,20 @@ OPTIONAL:
DEFAULT-P is a boolean. If non-nil, it marks that email account as the DEFAULT-P is a boolean. If non-nil, it marks that email account as the
default/fallback account." default/fallback account."
(after! mu4e (after! mu4e
(when-let* ((address (cdr (assq 'user-mail-address letvars-vars)))) (when-let* ((address (cdr (assq 'user-mail-address letvars))))
(add-to-list 'mu4e-user-mail-address-list address)) (add-to-list 'mu4e-user-mail-address-list address))
(setq mu4e-contexts (setq mu4e-contexts
(cl-delete-if (apply-partially #'string= label) mu4e-contexts (cl-loop for context in mu4e-contexts
:key #'mu4e-context-name)) unless (string= (mu4e-context-name context) label)
collect context))
(let ((context (make-mu4e-context (let ((context (make-mu4e-context
:name label :name label
:enter-func (lambda () (mu4e-message "Switched to %s" ,label)) :enter-func (lambda () (mu4e-message "Switched to %s" label))
:leave-func (lambda () (mu4e-clear-caches)) :leave-func (lambda () (mu4e-clear-caches))
:match-func :match-func
(lambda (msg) (lambda (msg)
(when msg (when msg
(string-prefix-p (format "/%s" ,label) (string-prefix-p (format "/%s" label)
(mu4e-message-field msg :maildir)))) (mu4e-message-field msg :maildir))))
:vars letvars))) :vars letvars)))
(push context mu4e-contexts) (push context mu4e-contexts)