1 ;;; mu-bbdb.el --- registration feature of mu-cite using BBDB
3 ;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc.
5 ;; Author: Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
6 ;; Maintainer: Katsumi Yamaoka <yamaoka@jpl.org>
7 ;; Keywords: BBDB, citation, mail, news
9 ;; This file is part of MU (Message Utilities).
11 ;; This program is free software; you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation; either version 2, or (at
14 ;; your option) any later version.
16 ;; This program is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program; see the file COPYING. If not, write to
23 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
29 ;; 1. bytecompile this file and copy it to the apropriate directory.
30 ;; 2. put the following lines to your ~/.emacs:
31 ;; (add-hook 'mu-cite-load-hook
42 (defvar mu-bbdb-load-hook nil
43 "*List of functions called after mu-bbdb is loaded.")
45 (defvar mu-bbdb-history nil)
48 ;;; @ prefix and registration using BBDB
51 (defun mu-cite/get-bbdb-prefix-method ()
52 (or (mu-cite/get-bbdb-attr (mu-cite-get-value 'address))
56 (defun mu-cite/get-bbdb-attr (addr)
57 "Extract attribute information from BBDB."
58 (let ((record (bbdb-search-simple nil addr)))
60 (bbdb-record-getprop record 'attribution))
63 (defun mu-cite/set-bbdb-attr (attr addr)
64 "Add attribute information to BBDB."
65 (let* ((bbdb-notice-hook nil)
66 (record (bbdb-annotate-message-sender
68 (bbdb-invoke-hook-for-value
69 bbdb/mail-auto-create-p)
73 (bbdb-record-putprop record 'attribution attr)
74 (bbdb-change-record record nil))
77 (defun mu-cite/get-bbdb-prefix-register-method ()
78 (let ((addr (mu-cite-get-value 'address)))
79 (or (mu-cite/get-bbdb-attr addr)
81 (read-string "Citation name? "
82 (or (mu-cite-get-value 'x-attribution)
83 (mu-cite-get-value 'full-name))
86 (if (and (not (string-equal return ""))
87 (y-or-n-p (format "Register \"%s\"? " return)))
88 (mu-cite/set-bbdb-attr return addr)
92 (defun mu-cite/get-bbdb-prefix-register-verbose-method ()
93 (let* ((addr (mu-cite-get-value 'address))
94 (attr (mu-cite/get-bbdb-attr addr))
95 (return (read-string "Citation name? "
97 (mu-cite-get-value 'x-attribution)
98 (mu-cite-get-value 'full-name))
101 (if (and (not (string-equal return ""))
102 (not (string-equal return attr))
103 (y-or-n-p (format "Register \"%s\"? " return))
105 (mu-cite/set-bbdb-attr return addr)
109 (or (assoc 'bbdb-prefix mu-cite/default-methods-alist)
110 (setq mu-cite/default-methods-alist
111 (append mu-cite/default-methods-alist
114 (function mu-cite/get-bbdb-prefix-method))
115 (cons 'bbdb-prefix-register
116 (function mu-cite/get-bbdb-prefix-register-method))
117 (cons 'bbdb-prefix-register-verbose
119 mu-cite/get-bbdb-prefix-register-verbose-method))
128 (run-hooks 'mu-bbdb-load-hook)
130 ;;; mu-bbdb.el ends here