[mew-int 3050] Re: Automatic case set & bbdb
Michael Steiner <[email protected]> Thu, 01 Mar 2012 17:35:20 -0500 (EST)
| Newsgroups | gmane.mail.mew.general |
|---|---|
| Message-ID | <[email protected]> |
>>>>> On Thu, 01 Mar 2012 16:14:25 -0500 (EST), Michael Steiner <[email protected]> said: MS> I have several accounts which i use with mew. It would be nice if MS> selecting the correct case would be as automatic as possible. I know MS> about mew-case-guess-alist but unless i'm overlooking something MS> trivial, it essentially has to be based on the To: and Cc: fields of MS> the new mail and hence more or less requires enumeration of ids if MS> there are no trivial rules based on domains. Hence that doesn't seem MS> that scalable. However, to some extent i have the information MS> already in form of tags in a BBDB db which is linked to mew. MS> MS> => MS> MS> Did anybody of you already implement some automatic case guessing MS> based on bbdb fields (maybe based on some bbdb-complete-name-hooks MS> trickery?) or alike and/or has a good idea how this could be MS> accomplished? Never mind. After digging a bit around in the code i came up with following approach .... (add-hook 'bbdb-complete-name-hooks '((lambda () (if (mew-draft-or-header-p) (let* ((rec (if (boundp 'match-recs) (car match-recs) rec)) (keywords (if rec (cdr (assoc 'keyword (bbdb-record-raw-notes rec))) "")) (email (if (boundp 'this-addr) this-addr ""))) ;(message (concat "k:" keywords " e:" email)) (cond ; .... ; rules which set case based on email and keywords ... ; .... ... it is a bit kludgy as it relies on undocumented parameters in bbdb-complete-name-hooks and to set the case i also had to unelegantly define ... (defun mew-draft-set-case-non-interactive (new-case) (let ((old-case (mew-tinfo-get-case))) (mew-tinfo-set-case new-case) (mew-tinfo-set-use-flowed (mew-use-format-flowed new-case)) (mew-draft-mode-name (mew-tinfo-get-hdr-file)) (mew-draft-replace-fields old-case) (mew-highlight-header) (unless (mew-tinfo-get-hdr-file) (mew-draft-header-keymap)))) ... which is non-interactive version of mew-draft-set-case as i couldn't find an existing clean function to call for setting the case non-interactively. So more or less i'm happy for now but any hints for more elegant approaches are still welcome :-) -michael-