From e29d17c7644b596da269d3de9bd1fe4368ef415d Mon Sep 17 00:00:00 2001 From: benj Date: Fri, 27 Mar 2026 14:53:47 +0800 Subject: update mu4e to send from Name --- init.el | 47 +++++++---------------------------------------- 1 file changed, 7 insertions(+), 40 deletions(-) (limited to 'init.el') diff --git a/init.el b/init.el index 89f796f..852fb58 100644 --- a/init.el +++ b/init.el @@ -329,36 +329,6 @@ :init (marginalia-mode)) -(use-package message - :after smtpmail-multi - :init - (defun get-mail-accounts () - (let* ((entries (auth-source-pass-parse-entry "emacs/mail-accounts")) - (accounts (if (null entries) nil (seq-filter (lambda (pair) (not (equal (car pair) 'secret))) entries)))) - (if (null accounts) - (message "No mail accounts were found in the password-store. Cannot send mail") - (mapcar (lambda (pair) - (let ((key (intern (car pair))) - (value ((lambda (account) - (let ((store (auth-source-pass-parse-entry account))) - `(,(assoc-default "user" store) - ,(assoc-default "host" store) - ,(string-to-number (assoc-default "port" store)) - ,(assoc-default "user" store) - ,(intern (assoc-default "type" store)) - nil nil nil - ))) - (cdr pair)))) - (cons key value))) - accounts)))) - - (setq send-mail-function 'smtpmail-multi-send-it - mail-accounts (get-mail-accounts) - primary-account (nth 0 (car mail-accounts)) - smtpmail-multi-accounts mail-accounts - smtpmail-multi-default-account primary-account - user-mail-address (nth 3 (cdr (assoc primary-account smtpmail-multi-accounts))) - smtpmail-multi-associations (mapcar (lambda (pair) `(,(car (cdr pair)) ,(car pair))) mail-accounts))) (use-package multiple-cursors :ensure t @@ -378,15 +348,14 @@ :ensure nil :bind (("C-c M" . mu4e) ("C-x m" . mu4e-compose-new)) - :init - (let ((first-account (car (directory-files "~/.mail" nil "^[^.]")))) - (when first-account - (setq mu4e-sent-folder (concat "/" first-account "/Sent") - mu4e-drafts-folder (concat "/" first-account "/Drafts") - mu4e-trash-folder (concat "/" first-account "/Trash") - mu4e-refile-folder (concat "/" first-account "/Archive")))) :hook (mu4e-compose-mode . (lambda () (use-hard-newlines -1))) :config + (defun my/email-to-display-name (email) + "Derive a display name from EMAIL, e.g. jane.doe@x.com -> Jane Doe." + (mapconcat #'capitalize + (split-string (car (split-string email "@")) "[._-]") + " ")) + (setq mu4e-compose-format-flowed t) (setq message-citation-line-function 'message-insert-formatted-citation-line) (setq message-citation-line-format "On %a, %d %b %Y at %R, %f wrote:\n") @@ -441,7 +410,7 @@ :vars (append `((user-mail-address . ,account) - (user-full-name . ,(user-full-name))) + (user-full-name . ,(my/email-to-display-name account))) (mapcar (lambda (pair) (cons (car pair) (concat "/" account "/" (cdr pair)))) @@ -645,8 +614,6 @@ (use-package rustic :ensure t) -(use-package smtpmail-multi - :ensure t) (use-package treemacs :ensure t -- cgit v1.2.3