X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=mu-bbdb.el;h=738ae96e5bf67a1b0acf1902611f1262bb8950f7;hb=bc775a067ee492f2dd52d594805ebef30681485d;hp=a3fa25ecf98ef85742e53995844bb4a56b0e8091;hpb=de762b69983703b147eb6c186b9c33aa1a91bbe5;p=elisp%2Fmu-cite.git diff --git a/mu-bbdb.el b/mu-bbdb.el index a3fa25e..738ae96 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.3 1996/12/10 11:57:23 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,103 +23,97 @@ ;; 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 (module-installed-p 'bbdb) - (require 'bbdb)) +(require 'bbdb) -(defvar mu-bbdb-load-hook nil - "*List of functions called after mu-bbdb is loaded.") +(defvar mu-bbdb-history nil) -;;; @@ prefix and registration using BBDB -;;; -(defun mu-cite/get-bbdb-prefix-method () - (or (mu-cite/get-bbdb-attr (mu-cite/get-value 'address)) - ">") - ) +;;; @ 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 + (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 ((return (read-string "Citation name? " - (or (mu-cite/get-value 'x-attribution) - (mu-cite/get-value 'full-name)) - 'mu-cite/minibuffer-history) - )) + (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)) +;;;###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)) (return (read-string "Citation name? " (or attr - (mu-cite/get-value 'x-attribution) - (mu-cite/get-value 'full-name)) - 'mu-cite/minibuffer-history)) - ) + (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 ;;;