>>>>> Richard Stanton writes:
[ .... error reported in an earlier mail ... ]
RS> Really odd. The error seems now to have stopped happening, and I can
RS> now enter new attributions and have them automatically stored by BBDB
RS> (although these don't override whatever was there before - how would
RS> you do that?).
RS> Imediately before it started working, I got a message asking if I
RS> wanted to add your name to your email address (I assume it was from
RS> BBDB). After answering "yes", everything has worked fine ever since.
1. the hook below replaces the old attribution with new one if
bbdb/supercite-attr-create-p is true!
2. the crash was casued by me not checking if there is/was
a record when trying to add the attribution. Below is
revised hook for the saving of attributes into BBDB
And now a quesition of my own - basicly for the supercite
list - it is "nicer" to user "sc-consult" together with
sc-attrib-selection-list, it seems cleaner and nicer.
(setq sc-attrib-selection-list
'(("From" ((".*" . (bbdb/supercite-get-attr-new
(sc-mail-field "from")))))))
with (untested code!)
(defun bbdb/supercite-get-attr-new (from)
"Extract citing information from BBDB using sc-consult.
>From is user to look for in the BBDB datebase."
(if (or (null from)
(string-match (bbdb-user-mail-names)
(car (cdr (mail-extract-address-components from)))))
;; if logged in user sent this, use recipients.
(setq from (or (sc-mail-field "to") from)))
(if from
(let ((record (bbdb-annotate-message-sender from t nil nil)))
(bbdb-record-getprop record 'attribution))))
comments?
msj
bugfixed code below:
----------------------------------------------------------------------
(setq sc-preferred-attribution-list
'("sc-lastchoice" "x-attribution" "bbdb-attribution"
"initials" "firstname" "lastname"))
(setq bbdb/supercite-replace-attr-p t)
(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)))
(if from
(let ((record (bbdb-annotate-message-sender
from t
(bbdb-invoke-hook-for-value
bbdb/mail-auto-create-p) t)))
(if (and record
(or bbdb/supercite-replace-attr-p
(not (bbdb-record-getprop record 'attribution))))
(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]