mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
Mu4e: try to be pick a good account to send from
This commit is contained in:
@ -287,6 +287,26 @@ is tomorrow. With two prefixes, select the deadline."
|
||||
:v "u" #'mu4e-headers-mark-for-unmark
|
||||
:vn "l" #'mu4e-msg-to-agenda))
|
||||
|
||||
;;----------------
|
||||
;; Sending mail
|
||||
;;----------------
|
||||
|
||||
(defun my-mu4e-set-account ()
|
||||
"Set the account for composing a message. If a 'To' header is present,
|
||||
and correspands to an email account, this account will be selected.
|
||||
Otherwise, the user is prompted for the accound they wish to use."
|
||||
(unless (and mu4e-compose-parent-message
|
||||
(let ((to (cdr (car (mu4e-message-field mu4e-compose-parent-message :to))))
|
||||
(from (cdr (car (mu4e-message-field mu4e-compose-parent-message :from)))))
|
||||
(if (member to (plist-get mu4e~server-props :personal-addresses))
|
||||
(setq user-mail-address to)
|
||||
(if (member from (plist-get mu4e~server-props :personal-addresses))
|
||||
(setq user-mail-address from)
|
||||
nil))))
|
||||
(ivy-read "Account: " (plist-get mu4e~server-props :personal-addresses) :action (lambda (candidate) (setq user-mail-address candidate)))))
|
||||
|
||||
(add-hook 'mu4e-compose-pre-hook 'my-mu4e-set-account)
|
||||
|
||||
;;----------------
|
||||
;; Prettifying mu4e:main
|
||||
;;----------------
|
||||
|
Reference in New Issue
Block a user