Created
April 8, 2017 10:53
-
-
Save yuchangyuan/c21f1e411a2965a5a0e6ef92c92de59d to your computer and use it in GitHub Desktop.
gnus from field auto completion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar my-smtp-list | |
'(("aa@bb" "AA BB") | |
("cc@dd" "西西滴滴") | |
("ee@ff" "EeFf")) | |
"A list of smtp account.") | |
(defun my-complete-sender () | |
"Complete email sender, from `my-smtp-list'." | |
(interactive) | |
(let* ((lst (mapcar | |
(lambda (x) | |
(with-temp-buffer | |
(let ((user-mail-address (car x)) | |
(user-full-name (cadr x))) | |
(mail-insert-from-field) | |
(goto-char (point-min)) | |
(delete-char (length "From: ")) | |
(end-of-line) | |
(delete-char 1) | |
(buffer-string)))) | |
my-smtp-list)) | |
(sender (ido-completing-read "sender: " lst)) | |
(epos (point)) | |
(bpos (save-excursion | |
(re-search-backward "\\(\\`\\|[\n:,]\\)[ \t]*") | |
(goto-char (match-end 0)) | |
(point)))) | |
(delete-region bpos epos) | |
(insert sender))) | |
(setq message-completion-alist | |
`(("^\\(Reply-To\\|From\\|Mail-Followup-To\\|Mail-Copies-To\\):" | |
. my-complete-sender) . | |
,message-completion-alist)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment