2 ;;; mu-register.el --- `register' function for mu-cite.
4 ;;; Copyright (C) 1995 MINOURA Makoto
6 ;;; Author: MINOURA Makoto <minoura@leo.bekkoame.or.jp>
7 ;;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; Created: 1995/12/27 by MINOURA Makoto <minoura@leo.bekkoame.or.jp>
10 ;;; $Id: mu-register.el,v 1.3 1996-01-15 19:24:19 morioka Exp $
12 ;;; This file is part of tl (Tiny Library).
14 ;;; This program is free software; you can redistribute it and/or
15 ;;; modify it under the terms of the GNU General Public License as
16 ;;; published by the Free Software Foundation; either version 2, or
17 ;;; (at your option) any later version.
19 ;;; This program is distributed in the hope that it will be useful,
20 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 ;;; General Public License for more details.
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with This program. If not, write to the Free Software
26 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
31 ;;; 1. bytecompile this file and copy it to the apropriate directory.
32 ;;; 2. put the following lines to your .emacs.
33 ;;; (add-hook 'mu-cite-load-hook
36 ;;; (require 'mu-register))))
37 ;;; 3. you can use the keyword `registered' in your
38 ;;; mu-cite/top-form and mu-cite/prefix-form, for example:
39 ;;; (setq mu-cite/prefix-format (list 'registered "> "))
42 ;;; Wed Dec 27 14:28:17 1995 MINOURA Makoto <minoura@leo.bekkoame.or.jp>
52 (defvar mu-register/registration-file
53 (expand-file-name "~/.mu-register")
54 "*The name of the user environment file for mu-register.")
56 (defvar mu-register/citation-name-alist nil)
57 (load mu-register/registration-file t t t)
59 (defvar mu-register/minibuffer-history nil)
65 ;; get citation-name from From field
66 (defsubst mu-register/get-citation-name (from)
67 (cdr (assoc from mu-register/citation-name-alist)))
69 ;; register citation-name
70 (defun mu-register/add-citation-name (name from)
71 (let* ((elt (assoc from mu-register/citation-name-alist)))
73 (setq mu-register/citation-name-alist
74 (delq elt mu-register/citation-name-alist)))
75 (setq elt (cons from name))
76 (setq mu-register/citation-name-alist
78 mu-register/citation-name-alist))
79 (mu-register/save-to-file)
83 (defun mu-register/citation-name ()
85 (rfc822/address-string
86 (car (rfc822/parse-address
87 (rfc822/lexical-analyze
88 (mu-cite/get-value 'from))))))
89 (fullname (mu-cite/get-value 'full-name))
91 (mu-register/get-citation-name from))
94 (setq return1 fullname))
96 (read-string "Citation name? "
98 'mu-register/minibuffer-history))
99 (if (not (string-equal return return1))
101 (cursor-in-echo-area t))
103 (message (format "Register \"%s\" (y/n)? " return))
104 (setq ans (read-event))
105 (if (not (or (eq ans ?y)
110 (mu-register/add-citation-name return from))))
114 (defun mu-register/save-to-file ()
115 (let* ((filename mu-register/registration-file)
116 (buffer (get-buffer-create " *mu-register*")))
119 (setq buffer-file-name filename)
121 (insert ";; generated automatically by mu-register.\n")
122 (insert "(setq mu-register/citation-name-alist\n\
125 (insert (prin1-to-string mu-register/citation-name-alist))
128 (kill-buffer buffer)))
135 (set-alist 'mu-cite/default-methods-alist
137 (function mu-register/citation-name))
143 (provide 'mu-register)
145 ;;; mu-register.el ends here