X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=mu-register.el;h=008108835613d795f7c034f6308ac64ba3c80aff;hb=2eff1bc783be812044b70b2ff4afc9c441dcc9e9;hp=fff102320ebbc29502d7f004061a8d96e9d87861;hpb=9c301ddb2c1f6804b69ef2b694dd578898be531f;p=elisp%2Fmu-cite.git diff --git a/mu-register.el b/mu-register.el index fff1023..0081088 100644 --- a/mu-register.el +++ b/mu-register.el @@ -1,6 +1,6 @@ ;;; mu-register.el --- registration feature of mu-cite - -;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc. +;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001 +;; Free Software Foundation, Inc. ;; Author: MINOURA Makoto ;; MORIOKA Tomohiko @@ -22,8 +22,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Code: @@ -45,35 +45,39 @@ :type 'integer :group 'mu-cite) -(defcustom mu-registration-file-coding-system-for-read nil - "Coding system used when reading a registration file." +(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 is registered." + "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 - "Coding system used when writing a current registration file.") + "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) -(static-when (featurep 'xemacs) - (define-obsolete-variable-alias - 'mu-cite/registration-file 'mu-registration-file) - - (define-obsolete-variable-alias - 'mu-cite/allow-null-string-registration - 'mu-cite-allow-null-string-registration) - - (define-obsolete-variable-alias - 'mu-cite/registration-symbol 'mu-registration-symbol) - ) - ;;; @ load / save registration file ;;; @@ -81,6 +85,7 @@ (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 @@ -103,31 +108,36 @@ (defun mu-cite-save-registration-file () (with-temp-buffer - (insert ";;; " (file-name-nondirectory mu-registration-file) "\n") - (insert ";;; This file is generated automatically by mu-cite " - mu-cite-version "\n\n") - (insert "(setq " - (symbol-name mu-registration-symbol) - "\n '(") - (insert (mapconcat - (function - (lambda (elem) - (format "(%s . %s)" - (prin1-to-string - (mu-cite-remove-text-properties (car elem))) - (prin1-to-string - (mu-cite-remove-text-properties (cdr elem)))))) - (symbol-value mu-registration-symbol) "\n ")) - (insert "\n ))\n\n") - (insert ";;; " - (file-name-nondirectory mu-registration-file) - " ends here\n") - (write-region-as-coding-system mu-registration-file-coding-system - (point-min)(point-max) - mu-registration-file nil 'nomsg) - (condition-case nil - (set-file-modes mu-registration-file mu-registration-file-modes) - (error nil)))) + (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 '(") + (insert (mapconcat + (function + (lambda (elem) + (format "(%s . %s)" + (prin1-to-string + (mu-cite-remove-text-properties (car elem))) + (prin1-to-string + (mu-cite-remove-text-properties (cdr elem)))))) + (symbol-value mu-registration-symbol) "\n\t")) + (insert "))\n\n") + (insert ";;; " name " ends here\n") + (write-region-as-coding-system coding-system + (point-min) (point-max) + mu-registration-file nil 'nomsg) + (condition-case nil + (set-file-modes mu-registration-file mu-registration-file-modes) + (error nil))))) ;;; @ database accessors @@ -160,6 +170,7 @@ (mu-cite-remove-text-properties (read-string "Citation name? " (or (mu-cite-get-value 'x-attribution) + (mu-cite-get-value 'x-cite-me) (mu-cite-get-value 'full-name)) 'mu-register-history)))) @@ -178,6 +189,7 @@ (read-string "Citation name? " (or return1 (mu-cite-get-value 'x-attribution) + (mu-cite-get-value 'x-cite-me) (mu-cite-get-value 'full-name)) 'mu-register-history)))) (if (and (or mu-cite-allow-null-string-registration