annotate lisp/mu/mu-bbdb.el @ 74:54cc21c15cbb r20-0b32

Import from CVS: tag r20-0b32
author cvs
date Mon, 13 Aug 2007 09:04:33 +0200
parents 131b0175ea99
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1 ;;; mu-bbdb.el --- `attribution' function for mu-cite with BBDB.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
3 ;; Copyright (C) 1996 Shuhei KOBAYASHI
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
5 ;; Author: Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
6 ;; Version: $Id: mu-bbdb.el,v 1.1.1.2 1996/12/21 20:50:53 steve Exp $
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
7
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
8 ;; This file is part of tl (Tiny Library).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
9
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
10 ;; This program is free software; you can redistribute it and/or
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
11 ;; modify it under the terms of the GNU General Public License as
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
12 ;; published by the Free Software Foundation; either version 2, or (at
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
13 ;; your option) any later version.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
14
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
15 ;; This program is distributed in the hope that it will be useful, but
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
18 ;; General Public License for more details.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
19
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
21 ;; along with this program; see the file COPYING. If not, write to
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
22 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
24
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
25 ;;; Commentary:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
26
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
27 ;; - How to use
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
28 ;; 1. bytecompile this file and copy it to the apropriate directory.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
29 ;; 2. put the following lines to your ~/.emacs:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
30 ;; (require 'tl-misc)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
31 ;; (call-after-loaded 'mu-cite
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
32 ;; (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
33 ;; (lambda ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
34 ;; (require 'mu-bbdb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
35 ;; )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
36
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
37
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
38 ;;; Code:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
39
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
40 (require 'mu-cite)
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
41 (if (module-installed-p 'bbdb)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
42 (require 'bbdb))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
43
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
44 (defvar mu-bbdb-load-hook nil
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
45 "*List of functions called after mu-bbdb is loaded.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
46
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
47 ;;; @@ prefix and registration using BBDB
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
48 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
49
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
50 (defun mu-cite/get-bbdb-prefix-method ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
51 (or (mu-cite/get-bbdb-attr (mu-cite/get-value 'address))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
52 ">")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
53 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
54
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
55 (defun mu-cite/get-bbdb-attr (addr)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
56 "Extract attribute information from BBDB."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
57 (let ((record (bbdb-search-simple nil addr)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
58 (and record
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
59 (bbdb-record-getprop record 'attribution))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
60 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
61
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
62 (defun mu-cite/set-bbdb-attr (attr addr)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
63 "Add attribute information to BBDB."
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
64 (let* ((bbdb-notice-hook nil)
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
65 (record (bbdb-annotate-message-sender
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
66 addr t
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
67 (bbdb-invoke-hook-for-value
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
68 bbdb/mail-auto-create-p)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
69 t)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
70 (if record
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
71 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
72 (bbdb-record-putprop record 'attribution attr)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
73 (bbdb-change-record record nil))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
74 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
75
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
76 (defun mu-cite/get-bbdb-prefix-register-method ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
77 (let ((addr (mu-cite/get-value 'address)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
78 (or (mu-cite/get-bbdb-attr addr)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
79 (let ((return
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
80 (read-string "Citation name? "
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
81 (or (mu-cite/get-value 'x-attribution)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
82 (mu-cite/get-value 'full-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
83 'mu-cite/minibuffer-history)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
84 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
85 (if (and (not (string-equal return ""))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
86 (y-or-n-p (format "Register \"%s\"? " return)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
87 (mu-cite/set-bbdb-attr return addr)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
88 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
89 return))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
90
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
91 (defun mu-cite/get-bbdb-prefix-register-verbose-method ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
92 (let* ((addr (mu-cite/get-value 'address))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
93 (attr (mu-cite/get-bbdb-attr addr))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
94 (return (read-string "Citation name? "
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
95 (or attr
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
96 (mu-cite/get-value 'x-attribution)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
97 (mu-cite/get-value 'full-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
98 'mu-cite/minibuffer-history))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
99 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
100 (if (and (not (string-equal return ""))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
101 (not (string-equal return attr))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
102 (y-or-n-p (format "Register \"%s\"? " return))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
103 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
104 (mu-cite/set-bbdb-attr return addr)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
105 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
106 return))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
107
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
108 (or (assoc 'bbdb-prefix mu-cite/default-methods-alist)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
109 (setq mu-cite/default-methods-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
110 (append mu-cite/default-methods-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
111 (list
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
112 (cons 'bbdb-prefix
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
113 (function mu-cite/get-bbdb-prefix-method))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
114 (cons 'bbdb-prefix-register
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
115 (function mu-cite/get-bbdb-prefix-register-method))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
116 (cons 'bbdb-prefix-register-verbose
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
117 (function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
118 mu-cite/get-bbdb-prefix-register-verbose-method))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
119 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
120
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
121
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
122 ;;; @ end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
123 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
124
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
125 (provide 'mu-bbdb)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
126
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
127 (run-hooks 'mu-bbdb-load-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
128
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
129 ;;; mu-bbdb.el ends here