2 ;;; mu-register.el --- `register' function for mu-cite.
4 ;;; Copyright (C) 1995 MINOURA Makoto
6 ;;; Author: MINOURA Makoto <minoura@leo.bekkoame.or.jp>
8 ;;; This file is not part of tm (Tools for MIME).
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
13 ;;; (at your option) any later version.
15 ;;; This program is distributed in the hope that it will be useful,
16 ;;; but 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. If not, write to the Free Software
22 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
27 ;;; 1. bytecompile this file and copy it to the apropriate directory.
28 ;;; 2. put the following lines to your .emacs.
29 ;;; (add-hook 'mu-cite-load-hook
32 ;;; (require 'mu-register))))
33 ;;; 3. you can use the keyword `registered' in your
34 ;;; mu-cite/top-form and mu-cite/prefix-form, for example:
35 ;;; (setq mu-cite/prefix-format (list 'registered "> "))
38 ;;; Wed Dec 27 14:28:17 1995 MINOURA Makoto <minoura@leo.bekkoame.or.jp>
45 (defvar mu-register/registration-file
46 (expand-file-name "~/.mu-register")
47 "*The name of the user environment file for mu-register.")
49 (defvar mu-register/citation-name-alist nil)
50 (load mu-register/registration-file t t t)
52 (defvar mu-register/minibuffer-history nil)
56 ;; from
\e$B$+$i0zMQL>$rF@$k
\e(B
57 (defsubst mu-register/get-citation-name (from)
58 (cdr (assoc from mu-register/citation-name-alist)))
61 ;;
\e$B0zMQL>$rEPO?$9$k
\e(B
62 (defun mu-register/add-citation-name (name from)
63 (let* ((elt (assoc from mu-register/citation-name-alist)))
65 (setq mu-register/citation-name-alist
66 (delq elt mu-register/citation-name-alist)))
67 (setq elt (cons from name))
68 (setq mu-register/citation-name-alist
70 mu-register/citation-name-alist))
71 (mu-register/save-to-file)
75 ;;
\e$B<B:]$K8F$S=P$5$l$k4X?t
\e(B
76 (defun mu-register/citation-name ()
78 (rfc822/address-string
79 (car (rfc822/parse-address
80 (rfc822/lexical-analyze
81 (mu-cite/get-value 'from))))))
82 (fullname (mu-cite/get-value 'full-name))
84 (mu-register/get-citation-name from))
87 (setq return1 fullname))
89 (read-string "Citation name? "
91 'mu-register/minibuffer-history))
92 (if (not (string-equal return return1))
94 (cursor-in-echo-area t))
96 (message (format "Register \"%s\" (y/n)? " return))
97 (setq ans (read-event))
98 (if (not (or (eq ans ?y)
103 (mu-register/add-citation-name return from))))
107 ;;
\e$B%U%!%$%k$KJ]B8
\e(B
108 (defun mu-register/save-to-file ()
109 (let* ((filename mu-register/registration-file)
110 (buffer (get-buffer-create " *mu-register*")))
113 (setq buffer-file-name filename)
115 (insert ";; generated automatically by mu-register.\n")
116 (insert "(setq mu-register/citation-name-alist\n\
119 (insert (prin1-to-string mu-register/citation-name-alist))
122 (kill-buffer buffer)))
129 (if (null (assoc 'registered mu-cite/default-methods-alist))
130 (setq mu-cite/default-methods-alist
131 (cons (cons 'registered (function mu-register/citation-name))
132 mu-cite/default-methods-alist)))
136 (provide 'mu-register)
138 ;;; mu-register.el ends here