>>>>> Tom Tromey writes:
Tom> Here is the code I use to get supercite attributions from BBDB. The
Tom> BBDB field is called "attribution".
Tom> [ tom's code removed for brevity sake ]
I use the following modified piece of code, based on Tom's and
Tom's hook for storing the attribution (slightly changed).
I use supercite's post-hook for getting the attribution. I prefer
to keep the old attribution if any (mm, maybe that should
change).
msj
---
(setq sc-preferred-attribution-list
'("sc-lastchoice" "x-attribution" "bbdb-attribution"
"initials" "firstname" "lastname"))
(add-hook 'sc-attribs-preselect-hook 'bbdb/supercite-get-attr)
(add-hook 'sc-post-hook 'bbdb/supercite-set-attr)
(defun bbdb/supercite-set-attr ()
"Add attribute to BBDB."
(let ((from (sc-mail-field "from")))
(if (or (null from)
(string-match (bbdb-user-mail-names)
(car (cdr (mail-extract-address-components
from)))))
(setq from (or (sc-mail-field "to") from)))
(let* ((record (and from (bbdb-annotate-message-sender from t nil nil)))
(old-value (and record (bbdb-record-getprop record 'attribution))))
(or old-value
(progn (bbdb-record-putprop record 'attribution
(sc-mail-field "sc-attribution"))
(bbdb-change-record record nil))))))
(defun bbdb/supercite-get-attr ()
"Extract citing information from BBDB."
(let ((from (sc-mail-field "from")))
(if (or (null from)
(string-match (bbdb-user-mail-names)
;; mail-strip-quoted-names is too broken!
;;(mail-strip-quoted-names from)
(car (cdr (mail-extract-address-components
from)))))
;; if logged in user sent this, use recipients.
(setq from (or (sc-mail-field "to") from)))
(let* ((record (and from (bbdb-annotate-message-sender from t nil nil)))
(attr (and record (bbdb-record-getprop record 'attribution))))
(and attr
(setq sc-attributions
(cons (cons "bbdb-attribution" attr) sc-attributions))))))
--
Martin Sj\"olin | http://www.ida.liu.se/labs/iislab/people/marsj
Department of Computer Science, LiTH, S-581 83 Link\"oping, SWEDEN
phone : +46 13 28 24 10 | fax : +46 13 28 26 66 | e-mail: [EMAIL PROTECTED]