1 ;;; mu-register.el --- registration feature of mu-cite
3 ;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc.
5 ;; Author: MINOURA Makoto <minoura@netlaputa.or.jp>
6 ;; MORIOKA Tomohiko <tomo@m17n.org>
7 ;; Maintainer: Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: registration, citation, mail, news
10 ;; This file is part of MU (Message Utilities).
12 ;; This program is free software; you can redistribute it and/or
13 ;; modify it under the terms of the GNU General Public License as
14 ;; published by the Free Software Foundation; either version 2, or (at
15 ;; your option) any later version.
17 ;; This program is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 ;; Wed Dec 27 14:28:17 1995 MINOURA Makoto <minoura@leo.bekkoame.or.jp>
39 (defcustom mu-registration-file (expand-file-name "~/.mu-cite.el")
40 "The name of the user environment file for mu-cite."
44 (defcustom mu-registration-file-modes 384
45 "Mode bits of `mu-registration-file', as an integer."
49 (defcustom mu-registration-file-coding-system-for-read nil
50 "Coding system used when reading a registration file."
53 (defcustom mu-cite-allow-null-string-registration nil
54 "If non-nil, null-string citation-name is registered."
58 (defvar mu-registration-symbol 'mu-citation-name-alist
59 "*Name of the variable to register citation prefix strings.")
61 (defvar mu-registration-file-coding-system nil
62 "Coding system used when writing a current registration file.")
64 (defvar mu-citation-name-alist nil)
66 (defvar mu-register-history nil)
68 (eval-when-compile (require 'static))
70 (static-when (featurep 'xemacs)
71 (define-obsolete-variable-alias
72 'mu-cite/registration-file 'mu-registration-file)
74 (define-obsolete-variable-alias
75 'mu-cite/allow-null-string-registration
76 'mu-cite-allow-null-string-registration)
78 (define-obsolete-variable-alias
79 'mu-cite/registration-symbol 'mu-registration-symbol)
83 ;;; @ load / save registration file
86 (defun mu-cite-load-registration-file ()
87 (if (file-readable-p mu-registration-file)
89 (insert-file-contents-as-coding-system
90 mu-registration-file-coding-system-for-read
92 (setq mu-registration-file-coding-system
93 buffer-file-coding-system)
94 (let ((exp (read (current-buffer))))
95 (or (eq (car (cdr exp)) mu-registration-symbol)
96 (setcar (cdr exp) mu-registration-symbol))
99 (defun mu-cite-save-registration-file ()
101 (insert ";;; " (file-name-nondirectory mu-registration-file) "\n")
102 (insert ";;; This file is generated automatically by mu-cite "
103 mu-cite-version "\n\n")
105 (symbol-name mu-registration-symbol)
108 (function prin1-to-string)
109 mu-citation-name-alist "\n "))
112 (file-name-nondirectory mu-registration-file)
114 (write-region-as-coding-system mu-registration-file-coding-system
115 (point-min)(point-max)
116 mu-registration-file nil 'nomsg)
118 (set-file-modes mu-registration-file mu-registration-file-modes)
125 ;; get citation-name from the database
126 (defun mu-register-get-citation-name (from)
127 (cdr (assoc from mu-citation-name-alist)))
129 ;; register citation-name to the database
130 (defun mu-register-add-citation-name (name from)
131 (setq mu-citation-name-alist
132 (put-alist from name mu-citation-name-alist))
133 (mu-cite-save-registration-file))
140 (defun mu-cite-get-prefix-method ()
141 (or (mu-register-get-citation-name (mu-cite-get-value 'address))
145 (defun mu-cite-get-prefix-register-method ()
146 (let ((addr (mu-cite-get-value 'address)))
147 (or (mu-register-get-citation-name addr)
149 (read-string "Citation name? "
150 (or (mu-cite-get-value 'x-attribution)
151 (mu-cite-get-value 'full-name))
152 'mu-register-history)))
153 (when (and (or mu-cite-allow-null-string-registration
154 (not (string-equal return "")))
155 (y-or-n-p (format "Register \"%s\"? " return)))
156 (mu-register-add-citation-name return addr))
160 (defun mu-cite-get-prefix-register-verbose-method ()
161 (let* ((addr (mu-cite-get-value 'address))
162 (return1 (mu-register-get-citation-name addr))
163 (return (read-string "Citation name? "
165 (mu-cite-get-value 'x-attribution)
166 (mu-cite-get-value 'full-name))
167 'mu-register-history)))
168 (when (and (or mu-cite-allow-null-string-registration
169 (not (string-equal return "")))
170 (not (string-equal return return1))
171 (y-or-n-p (format "Register \"%s\"? " return)))
172 (mu-register-add-citation-name return addr))
179 (provide 'mu-register)
181 (mu-cite-load-registration-file)
183 ;;; mu-register.el ends here