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.
31 (defvar mu-bbdb-history nil)
37 (defun mu-bbdb-get-attr (addr)
38 "Extract attribute information from BBDB."
39 (let ((record (bbdb-search-simple nil addr)))
41 (bbdb-record-getprop record 'attribution))))
43 (defun mu-bbdb-set-attr (attr addr)
44 "Add attribute information to BBDB."
45 (let* ((bbdb-notice-hook nil)
46 (record (bbdb-annotate-message-sender
48 (bbdb-invoke-hook-for-value
49 bbdb/mail-auto-create-p)
53 (bbdb-record-putprop record 'attribution attr)
54 (bbdb-change-record record nil)
62 (defun mu-bbdb-get-prefix-method ()
63 "A mu-cite method to return a prefix from BBDB or \">\".
64 If an `attribution' value is found in BBDB, the value is returned.
65 Otherwise \">\" is returned.
67 Notice that please use (mu-cite-get-value 'bbdb-prefix)
68 instead of call the function directly."
69 (or (mu-bbdb-get-attr (mu-cite-get-value 'address))
73 (defun mu-bbdb-get-prefix-register-method ()
74 "A mu-cite method to return a prefix from BBDB or register it.
75 If an `attribution' value is found in BBDB, the value is returned.
76 Otherwise the function requests a prefix from a user. The prefix will
77 be registered to BBDB if the user wants it.
79 Notice that please use (mu-cite-get-value 'bbdb-prefix-register)
80 instead of call the function directly."
81 (let ((addr (mu-cite-get-value 'address)))
82 (or (mu-bbdb-get-attr addr)
84 (read-string "Citation name? "
85 (or (mu-cite-get-value 'x-attribution)
86 (mu-cite-get-value 'full-name))
88 (if (and (not (string-equal return ""))
89 (y-or-n-p (format "Register \"%s\"? " return)))
90 (mu-bbdb-set-attr return addr))
94 (defun mu-bbdb-get-prefix-register-verbose-method ()
95 "A mu-cite method to return a prefix using BBDB.
97 In this method, a user must specify a prefix unconditionally. If an
98 `attribution' value is found in BBDB, the value is used as a initial
99 value to input the prefix. The prefix will be registered to BBDB if
102 Notice that please use (mu-cite-get-value 'bbdb-prefix-register-verbose)
103 instead of call the function directly."
104 (let* ((addr (mu-cite-get-value 'address))
105 (attr (mu-bbdb-get-attr addr))
106 (return (read-string "Citation name? "
108 (mu-cite-get-value 'x-attribution)
109 (mu-cite-get-value 'full-name))
111 (if (and (not (string-equal return ""))
112 (not (string-equal return attr))
113 (y-or-n-p (format "Register \"%s\"? " return)))
114 (mu-bbdb-set-attr return addr))
123 (run-hooks 'mu-bbdb-load-hook)
125 ;;; mu-bbdb.el ends here