X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=mu-bbdb.el;h=4efa3cdfc5ee4341d1034e55b083fc1605429ec9;hb=5ada87c38664e4f6eb23bec1304488c7e1e0c5fe;hp=af5877cced607ddf7930b609ef659f51a6c14ffe;hpb=70e00eaa120cb46b364bc594df4b90514a497992;p=elisp%2Fmu-cite.git diff --git a/mu-bbdb.el b/mu-bbdb.el index af5877c..4efa3cd 100644 --- a/mu-bbdb.el +++ b/mu-bbdb.el @@ -1,11 +1,12 @@ -;;; mu-bbdb.el --- `attribution' function for mu-cite with BBDB. +;;; mu-bbdb.el --- registration feature of mu-cite using BBDB -;; Copyright (C) 1996 Shuhei KOBAYASHI +;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc. -;; Author: Shuhei KOBAYASHI -;; Version: $Id: mu-bbdb.el,v 3.2 1996/11/22 08:44:27 shuhei-k Exp $ +;; Author: Shuhei KOBAYASHI +;; Maintainer: Katsumi Yamaoka +;; Keywords: BBDB, citation, mail, news -;; This file is part of tl (Tiny Library). +;; This file is part of MU (Message Utilities). ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as @@ -22,109 +23,101 @@ ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. -;;; Commentary: - -;; - How to use -;; 1. bytecompile this file and copy it to the apropriate directory. -;; 2. put the following lines to your ~/.emacs: -;; (require 'tl-misc) -;; (call-after-loaded 'mu-cite -;; (function -;; (lambda () -;; (require 'mu-bbdb) -;; ))) - - ;;; Code: (require 'mu-cite) -(if (not (fboundp 'eval-when)) - (require 'bbdb) - (eval-when (compile) - (ignore-errors - (require 'bbdb))) - (eval-when (load eval) - (require 'bbdb)) - ) - -(defvar mu-bbdb-load-hook nil - "*List of functions called after mu-bbdb is loaded.") - -;;; @@ prefix and registration using BBDB -;;; +(require 'bbdb) -(defun mu-cite/get-bbdb-prefix-method () - (or (mu-cite/get-bbdb-attr (mu-cite/get-value 'address)) - ">") - ) +(defvar mu-bbdb-history nil) + + +;;; @ BBDB interface +;;; -(defun mu-cite/get-bbdb-attr (addr) +(defun mu-bbdb-get-attr (addr) "Extract attribute information from BBDB." (let ((record (bbdb-search-simple nil addr))) - (and record - (bbdb-record-getprop record 'attribution)) - )) + (if record + (bbdb-record-getprop record 'attribution)))) -(defun mu-cite/set-bbdb-attr (attr addr) +(defun mu-bbdb-set-attr (attr addr) "Add attribute information to BBDB." (let* ((bbdb-notice-hook nil) - (record (bbdb-annotate-message-sender - addr t - (bbdb-invoke-hook-for-value - bbdb/mail-auto-create-p) + (record (bbdb-annotate-message-sender + addr t + (bbdb-invoke-hook-for-value + bbdb/mail-auto-create-p) t))) (if record - (progn - (bbdb-record-putprop record 'attribution attr) - (bbdb-change-record record nil)) - ))) - -(defun mu-cite/get-bbdb-prefix-register-method () - (let ((addr (mu-cite/get-value 'address))) - (or (mu-cite/get-bbdb-attr addr) - (let ((return - (read-string "Citation name? " - (or (mu-cite/get-value 'x-attribution) - (mu-cite/get-value 'full-name)) - 'mu-cite/minibuffer-history) - )) + (progn + (bbdb-record-putprop record 'attribution attr) + (bbdb-change-record record nil))))) + + +;;; @ methods +;;; + +;;;###autoload +(defun mu-bbdb-get-prefix-method () + "A mu-cite method to return a prefix from BBDB or \">\". +If an `attribution' value is found in BBDB, the value is returned. +Otherwise \">\" is returned. + +Notice that please use (mu-cite-get-value 'bbdb-prefix) +instead of call the function directly." + (or (mu-bbdb-get-attr (mu-cite-get-value 'address)) + ">")) + +;;;###autoload +(defun mu-bbdb-get-prefix-register-method () + "A mu-cite method to return a prefix from BBDB or register it. +If an `attribution' value is found in BBDB, the value is returned. +Otherwise the function requests a prefix from a user. The prefix will +be registered to BBDB if the user wants it. + +Notice that please use (mu-cite-get-value 'bbdb-prefix-register) +instead of call the function directly." + (let ((addr (mu-cite-get-value 'address))) + (or (mu-bbdb-get-attr addr) + (let* ((minibuffer-allow-text-properties nil) + (return + (mu-cite-remove-text-properties + (read-string "Citation name? " + (or (mu-cite-get-value 'x-attribution) + (mu-cite-get-value 'full-name)) + 'mu-bbdb-history)))) (if (and (not (string-equal return "")) - (y-or-n-p (format "Register \"%s\"? " return))) - (mu-cite/set-bbdb-attr return addr) - ) + (y-or-n-p (format "Register \"%s\"? " return))) + (mu-bbdb-set-attr return addr)) return)))) -(defun mu-cite/get-bbdb-prefix-register-verbose-method () - (let* ((addr (mu-cite/get-value 'address)) - (attr (mu-cite/get-bbdb-attr addr)) - (return (read-string "Citation name? " - (or attr - (mu-cite/get-value 'x-attribution) - (mu-cite/get-value 'full-name)) - 'mu-cite/minibuffer-history)) - ) +;;;###autoload +(defun mu-bbdb-get-prefix-register-verbose-method () + "A mu-cite method to return a prefix using BBDB. + +In this method, a user must specify a prefix unconditionally. If an +`attribution' value is found in BBDB, the value is used as a initial +value to input the prefix. The prefix will be registered to BBDB if +the user wants it. + +Notice that please use (mu-cite-get-value 'bbdb-prefix-register-verbose) +instead of call the function directly." + (let* ((addr (mu-cite-get-value 'address)) + (attr (mu-bbdb-get-attr addr)) + (minibuffer-allow-text-properties nil) + (return (mu-cite-remove-text-properties + (read-string "Citation name? " + (or attr + (mu-cite-get-value 'x-attribution) + (mu-cite-get-value 'full-name)) + 'mu-bbdb-history)))) (if (and (not (string-equal return "")) - (not (string-equal return attr)) - (y-or-n-p (format "Register \"%s\"? " return)) - ) - (mu-cite/set-bbdb-attr return addr) - ) + (not (string-equal return attr)) + (y-or-n-p (format "Register \"%s\"? " return))) + (mu-bbdb-set-attr return addr)) return)) -(or (assoc 'bbdb-prefix mu-cite/default-methods-alist) - (setq mu-cite/default-methods-alist - (append mu-cite/default-methods-alist - (list - (cons 'bbdb-prefix - (function mu-cite/get-bbdb-prefix-method)) - (cons 'bbdb-prefix-register - (function mu-cite/get-bbdb-prefix-register-method)) - (cons 'bbdb-prefix-register-verbose - (function - mu-cite/get-bbdb-prefix-register-verbose-method)) - )))) - - + ;;; @ end ;;;