1 ;;; mu-bbdb.el --- `attribution' function for mu-cite with BBDB.
3 ;; Copyright (C) 1996 Shuhei KOBAYASHI
5 ;; Author: Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
6 ;; Version: $Id: mu-bbdb.el,v 1.1.1.1 1998-01-14 06:27:58 steve Exp $
8 ;; This file is part of tl (Tiny Library).
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
15 ;; This program is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with this program; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
28 ;; 1. bytecompile this file and copy it to the apropriate directory.
29 ;; 2. put the following lines to your ~/.emacs:
31 ;; (call-after-loaded 'mu-cite
41 (if (module-installed-p 'bbdb)
44 (defvar mu-bbdb-load-hook nil
45 "*List of functions called after mu-bbdb is loaded.")
47 ;;; @@ prefix and registration using BBDB
50 (defun mu-cite/get-bbdb-prefix-method ()
51 (or (mu-cite/get-bbdb-attr (mu-cite/get-value 'address))
55 (defun mu-cite/get-bbdb-attr (addr)
56 "Extract attribute information from BBDB."
57 (let ((record (bbdb-search-simple nil addr)))
59 (bbdb-record-getprop record 'attribution))
62 (defun mu-cite/set-bbdb-attr (attr addr)
63 "Add attribute information to BBDB."
64 (let* ((bbdb-notice-hook nil)
65 (record (bbdb-annotate-message-sender
67 (bbdb-invoke-hook-for-value
68 bbdb/mail-auto-create-p)
72 (bbdb-record-putprop record 'attribution attr)
73 (bbdb-change-record record nil))
76 (defun mu-cite/get-bbdb-prefix-register-method ()
77 (let ((addr (mu-cite/get-value 'address)))
78 (or (mu-cite/get-bbdb-attr addr)
80 (read-string "Citation name? "
81 (or (mu-cite/get-value 'x-attribution)
82 (mu-cite/get-value 'full-name))
83 'mu-cite/minibuffer-history)
85 (if (and (not (string-equal return ""))
86 (y-or-n-p (format "Register \"%s\"? " return)))
87 (mu-cite/set-bbdb-attr return addr)
91 (defun mu-cite/get-bbdb-prefix-register-verbose-method ()
92 (let* ((addr (mu-cite/get-value 'address))
93 (attr (mu-cite/get-bbdb-attr addr))
94 (return (read-string "Citation name? "
96 (mu-cite/get-value 'x-attribution)
97 (mu-cite/get-value 'full-name))
98 'mu-cite/minibuffer-history))
100 (if (and (not (string-equal return ""))
101 (not (string-equal return attr))
102 (y-or-n-p (format "Register \"%s\"? " return))
104 (mu-cite/set-bbdb-attr return addr)
108 (or (assoc 'bbdb-prefix mu-cite/default-methods-alist)
109 (setq mu-cite/default-methods-alist
110 (append mu-cite/default-methods-alist
113 (function mu-cite/get-bbdb-prefix-method))
114 (cons 'bbdb-prefix-register
115 (function mu-cite/get-bbdb-prefix-register-method))
116 (cons 'bbdb-prefix-register-verbose
118 mu-cite/get-bbdb-prefix-register-verbose-method))
127 (run-hooks 'mu-bbdb-load-hook)
129 ;;; mu-bbdb.el ends here