-;; get citation-name from the database
-(defmacro mu-register/get-citation-name (from)
- (` (cdr (assoc (, from) mu-register/citation-name-alist))))
-
-;; register citation-name to the database
-(defun mu-register/add-citation-name (name from)
- (let* ((elt (assoc from mu-register/citation-name-alist)))
- (if elt
- (setq mu-register/citation-name-alist
- (delq elt mu-register/citation-name-alist)))
- (setq elt (cons from name))
- (setq mu-register/citation-name-alist
- (cons elt
- mu-register/citation-name-alist))
- (mu-register/save-to-file)
- ))
-
-;; save to file
-(defun mu-register/save-to-file ()
- (let* ((filename mu-register/registration-file)
- (buffer (get-buffer-create " *mu-register*")))
- (save-excursion
- (set-buffer buffer)
- (setq buffer-file-name filename)
- (erase-buffer)
- (insert ";; generated automatically by mu-register.\n")
- (insert (format "(setq %s
- '(" mu-register/registration-symbol))
+(defcustom mu-registration-file (expand-file-name "~/.mu-cite.el")
+ "The name of the user environment file for mu-cite."
+ :type 'file
+ :group 'mu-cite)
+
+(defcustom mu-registration-file-modes 384
+ "Mode bits of `mu-registration-file', as an integer."
+ :type 'integer
+ :group 'mu-cite)
+
+(defcustom mu-registration-file-coding-system-for-write
+ (static-if (boundp 'MULE)
+ '*iso-2022-jp*
+ 'iso-2022-7bit)
+ "Coding-system used when writing a registration file. If you set this
+to nil, the value of `mu-registration-file-coding-system' will be used
+for writing a file."
+ :group 'mu-cite)
+
+(defcustom mu-cite-allow-null-string-registration nil
+ "If non-nil, null-string citation-name can be registered."
+ :type 'boolean
+ :group 'mu-cite)
+
+(defvar mu-registration-symbol 'mu-citation-name-alist
+ "*Name of the variable to register citation prefix strings.")
+
+(defvar mu-registration-file-coding-system-for-read nil
+ "*Coding-system used when reading a registration file. Normally, you
+have no need to set this option. If you have many friends in various
+countries and the file contains their names in various languages, you
+may avoid mis-decoding them by setting this option to `iso-2022-7bit'
+or the other universal coding-system. Note that when you change this
+value, you should save the file manually using the same coding-system
+in advance.")
+
+(defvar mu-registration-file-coding-system nil
+ "Internal variable used to keep a default coding-system for writing
+a current registration file. The value will be renewed whenever a
+registration file is read.")
+
+(defvar mu-register-history nil)
+
+
+;;; @ load / save registration file
+;;;
+
+(defun mu-cite-load-registration-file ()
+ (if (file-readable-p mu-registration-file)
+ (with-temp-buffer
+ (set-buffer-multibyte t)
+ (if mu-registration-file-coding-system-for-read
+ (insert-file-contents-as-coding-system
+ mu-registration-file-coding-system-for-read
+ mu-registration-file)
+ (insert-file-contents mu-registration-file))
+ (setq mu-registration-file-coding-system
+ (static-cond
+ ((boundp 'buffer-file-coding-system)
+ (symbol-value 'buffer-file-coding-system))
+ ((boundp 'file-coding-system)
+ (symbol-value 'file-coding-system))
+ (t
+ nil)))
+ (let ((exp (read (current-buffer))))
+ (or (eq (car (cdr exp)) mu-registration-symbol)
+ (setcar (cdr exp) mu-registration-symbol))
+ (eval exp))))
+ (or (boundp mu-registration-symbol)
+ (set mu-registration-symbol nil)))
+
+(defun mu-cite-save-registration-file ()
+ (with-temp-buffer
+ (set-buffer-multibyte t)
+ (let ((name (file-name-nondirectory mu-registration-file))
+ (coding-system (or mu-registration-file-coding-system-for-write
+ mu-registration-file-coding-system)))
+ (insert (format "\
+;;; %s -*- mode: emacs-lisp; coding: %s -*-
+;; This file is generated automatically by MU-CITE v%s.
+
+"
+ name coding-system mu-cite-version))
+ (insert "(setq "
+ (symbol-name mu-registration-symbol)
+ "\n '(")