Mercurial > hg > xemacs-beta
comparison lisp/mu/mu-bbdb.el @ 4:b82b59fe008d r19-15b3
Import from CVS: tag r19-15b3
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:46:56 +0200 |
parents | |
children | 4b173ad71786 |
comparison
equal
deleted
inserted
replaced
3:30df88044ec6 | 4:b82b59fe008d |
---|---|
1 ;;; mu-bbdb.el --- `attribution' function for mu-cite with BBDB. | |
2 | |
3 ;; Copyright (C) 1996 Shuhei KOBAYASHI | |
4 | |
5 ;; Author: Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp> | |
6 ;; Version: $Id: mu-bbdb.el,v 1.1.1.1 1996/12/18 03:55:30 steve Exp $ | |
7 | |
8 ;; This file is part of tl (Tiny Library). | |
9 | |
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. | |
14 | |
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. | |
19 | |
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. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;; - How to use | |
28 ;; 1. bytecompile this file and copy it to the apropriate directory. | |
29 ;; 2. put the following lines to your ~/.emacs: | |
30 ;; (require 'tl-misc) | |
31 ;; (call-after-loaded 'mu-cite | |
32 ;; (function | |
33 ;; (lambda () | |
34 ;; (require 'mu-bbdb) | |
35 ;; ))) | |
36 | |
37 | |
38 ;;; Code: | |
39 | |
40 (require 'mu-cite) | |
41 (if (not (fboundp 'eval-when)) | |
42 (require 'bbdb) | |
43 (eval-when (compile) | |
44 (ignore-errors | |
45 (require 'bbdb))) | |
46 (eval-when (load eval) | |
47 (require 'bbdb)) | |
48 ) | |
49 | |
50 (defvar mu-bbdb-load-hook nil | |
51 "*List of functions called after mu-bbdb is loaded.") | |
52 | |
53 ;;; @@ prefix and registration using BBDB | |
54 ;;; | |
55 | |
56 (defun mu-cite/get-bbdb-prefix-method () | |
57 (or (mu-cite/get-bbdb-attr (mu-cite/get-value 'address)) | |
58 ">") | |
59 ) | |
60 | |
61 (defun mu-cite/get-bbdb-attr (addr) | |
62 "Extract attribute information from BBDB." | |
63 (let ((record (bbdb-search-simple nil addr))) | |
64 (and record | |
65 (bbdb-record-getprop record 'attribution)) | |
66 )) | |
67 | |
68 (defun mu-cite/set-bbdb-attr (attr addr) | |
69 "Add attribute information to BBDB." | |
70 (let* ((bbdb-notice-hook nil) | |
71 (record (bbdb-annotate-message-sender | |
72 addr t | |
73 (bbdb-invoke-hook-for-value | |
74 bbdb/mail-auto-create-p) | |
75 t))) | |
76 (if record | |
77 (progn | |
78 (bbdb-record-putprop record 'attribution attr) | |
79 (bbdb-change-record record nil)) | |
80 ))) | |
81 | |
82 (defun mu-cite/get-bbdb-prefix-register-method () | |
83 (let ((addr (mu-cite/get-value 'address))) | |
84 (or (mu-cite/get-bbdb-attr addr) | |
85 (let ((return | |
86 (read-string "Citation name? " | |
87 (or (mu-cite/get-value 'x-attribution) | |
88 (mu-cite/get-value 'full-name)) | |
89 'mu-cite/minibuffer-history) | |
90 )) | |
91 (if (and (not (string-equal return "")) | |
92 (y-or-n-p (format "Register \"%s\"? " return))) | |
93 (mu-cite/set-bbdb-attr return addr) | |
94 ) | |
95 return)))) | |
96 | |
97 (defun mu-cite/get-bbdb-prefix-register-verbose-method () | |
98 (let* ((addr (mu-cite/get-value 'address)) | |
99 (attr (mu-cite/get-bbdb-attr addr)) | |
100 (return (read-string "Citation name? " | |
101 (or attr | |
102 (mu-cite/get-value 'x-attribution) | |
103 (mu-cite/get-value 'full-name)) | |
104 'mu-cite/minibuffer-history)) | |
105 ) | |
106 (if (and (not (string-equal return "")) | |
107 (not (string-equal return attr)) | |
108 (y-or-n-p (format "Register \"%s\"? " return)) | |
109 ) | |
110 (mu-cite/set-bbdb-attr return addr) | |
111 ) | |
112 return)) | |
113 | |
114 (or (assoc 'bbdb-prefix mu-cite/default-methods-alist) | |
115 (setq mu-cite/default-methods-alist | |
116 (append mu-cite/default-methods-alist | |
117 (list | |
118 (cons 'bbdb-prefix | |
119 (function mu-cite/get-bbdb-prefix-method)) | |
120 (cons 'bbdb-prefix-register | |
121 (function mu-cite/get-bbdb-prefix-register-method)) | |
122 (cons 'bbdb-prefix-register-verbose | |
123 (function | |
124 mu-cite/get-bbdb-prefix-register-verbose-method)) | |
125 )))) | |
126 | |
127 | |
128 ;;; @ end | |
129 ;;; | |
130 | |
131 (provide 'mu-bbdb) | |
132 | |
133 (run-hooks 'mu-bbdb-load-hook) | |
134 | |
135 ;;; mu-bbdb.el ends here |