Replace :email with set-email-account! autodef
This commit is contained in:
parent
8b739fb3b0
commit
8ca88aba9e
2 changed files with 46 additions and 38 deletions
|
@ -1,5 +1,51 @@
|
||||||
;;; app/email/autoload/email.el -*- lexical-binding: t; -*-
|
;;; app/email/autoload/email.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
;;;###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
|
||||||
|
(when-let* ((address (cdr (assq 'user-mail-address letvars-vars))))
|
||||||
|
(add-to-list 'mu4e-user-mail-address-list address))
|
||||||
|
(setq mu4e-contexts
|
||||||
|
(cl-delete-if (apply-partially #'string= label) mu4e-contexts
|
||||||
|
:key #'mu4e-context-name))
|
||||||
|
(let ((context (make-mu4e-context
|
||||||
|
:name label
|
||||||
|
:enter-func (lambda () (mu4e-message "Switched to %s" ,label))
|
||||||
|
:leave-func (lambda () (mu4e-clear-caches))
|
||||||
|
:match-func
|
||||||
|
(lambda (msg)
|
||||||
|
(when msg
|
||||||
|
(string-prefix-p (format "/%s" ,label)
|
||||||
|
(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))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defvar +email-workspace-name "*mu4e*"
|
(defvar +email-workspace-name "*mu4e*"
|
||||||
"TODO")
|
"TODO")
|
||||||
|
|
||||||
|
|
|
@ -7,44 +7,6 @@
|
||||||
(defvar +email-backend 'mbsync
|
(defvar +email-backend 'mbsync
|
||||||
"Which backend to use. Can either be offlineimap, mbsync or nil (manual).")
|
"Which backend to use. Can either be offlineimap, mbsync or nil (manual).")
|
||||||
|
|
||||||
(def-setting! :email (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
|
|
||||||
(let ((account-vars ,letvars))
|
|
||||||
(when-let* ((address (cdr (assq 'user-mail-address account-vars))))
|
|
||||||
(cl-pushnew address mu4e-user-mail-address-list :test #'equal))
|
|
||||||
(setq mu4e-contexts
|
|
||||||
(cl-delete-if (lambda (c) (string= (mu4e-context-name c) ,label))
|
|
||||||
mu4e-contexts))
|
|
||||||
(let ((context (make-mu4e-context
|
|
||||||
:name ,label
|
|
||||||
:enter-func (lambda () (mu4e-message "Switched to %s" ,label))
|
|
||||||
:leave-func (lambda () (mu4e-clear-caches))
|
|
||||||
:match-func
|
|
||||||
(lambda (msg)
|
|
||||||
(when msg
|
|
||||||
(string-prefix-p (format "/%s" ,label)
|
|
||||||
(mu4e-message-field msg :maildir))))
|
|
||||||
:vars ,letvars)))
|
|
||||||
(push context mu4e-contexts)
|
|
||||||
,(if default-p `(setq-default mu4e-context-current context))
|
|
||||||
context))))
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Plugins
|
;; Plugins
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue