Richard Riley <[email protected]> writes:
> Also, the next extension to this great addition would be to set the
> fields based on the "to" address when creating an email. i.e when I
> complete the "to:" field in a new email the
> DE-bbdb-match-field-recipient, or similar, is called to enable the
> initialisation of the other fields based on posting style.
>
> Is this possible?
Actually, I did a small hack for this some time ago. It's not pretty,
but it works. You would have to adapt it to your needs, though.
--8<---------------cut here---------------start------------->8---
;Automatically set From-Adress according to gnus-private in BBDB
(defun DE-message-change-from (newfrom)
(save-excursion
(message-position-on-field "from")
(beginning-of-line)
(delete-region (point) (progn (end-of-line) (point)))
(insert "From: ") (insert newfrom)))
(defun DE-message-completion ()
(bbdb-complete-name)
(DE-message-change-from-with-bbdb))
(defun DE-message-change-from-with-bbdb ()
(interactive)
(save-excursion
(let ((who (message-fetch-field "to")))
(when who
(let ((rec (bbdb-search-simple nil (cadr
(gnus-extract-address-components who)))))
(when rec
(let ((gpriv (bbdb-get-field rec 'gnus-private))
(autocc (bbdb-get-field rec 'auto-cc)))
(if (string-match "work" gpriv)
(DE-message-change-from "David <da...@work>")
(DE-message-change-from "David <da...@private>"))
(when (> (length autocc) 0)
(message-add-header (concat "Cc: " autocc))))))))))
--8<---------------cut here---------------end--------------->8---
This function checks for the 'gnus-private field, string-matches it
against "work" and changes the From-header accordingly. It also checks
the field 'auto-cc and includes all addresses it finds there in a Cc
header (it should delete them again for following completions, but I
never got around to do that since I use that feature rarely).
You then have to use this completion function for the header fields
where it makes sense:
--8<---------------cut here---------------start------------->8---
(setq message-completion-alist
'(
("^\\(Newsgroups\\|Followup-To\\|Posted-To\\|Gcc\\):" .
message-expand-group)
("^\\(Resent-\\)?\\(To\\|B?Cc\\):" . DE-message-completion)
("^\\(Reply-To\\|From\\|Mail-Followup-To\\|Mail-Copies-To\\):" .
message-expand-name)
("^\\(Disposition-Notification-To\\|Return-Receipt-To\\):" .
message-expand-name)
))
--8<---------------cut here---------------end--------------->8---
-David
_______________________________________________
info-gnus-english mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/info-gnus-english