* mu-register.el (mu-cite-load-registration-file): Retry to read a file
authoryamaoka <yamaoka>
Wed, 29 Aug 2001 11:30:18 +0000 (11:30 +0000)
committeryamaoka <yamaoka>
Wed, 29 Aug 2001 11:30:18 +0000 (11:30 +0000)
 when failed.

ChangeLog
mu-register.el

index 6ac01fe..8cd5f18 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2001-08-29  Katsumi Yamaoka   <yamaoka@jpl.org>
+
+       * mu-register.el (mu-cite-load-registration-file): Retry to read
+       a file when failed.
+
 2001-08-03  Katsumi Yamaoka   <yamaoka@jpl.org>
 
        * mu-register.el (mu-cite-save-registration-file): Use
index 911b007..e0cee98 100644 (file)
@@ -86,18 +86,42 @@ registration id read.")
             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))))
+       (let (exp)
+         (if (or (condition-case nil
+                     (progn
+                       (setq exp (read (current-buffer)))
+                       t)
+                   (error nil))
+                 ;; Under XEmacs, the function `insert-file-contents'
+                 ;; does not handle the coding-system magic cookie.
+                 (progn
+                   (insert-file-contents-as-raw-text mu-registration-file
+                                                     nil 0 3000 t)
+                   (goto-char (point-min))
+                   (if (looking-at "\
+^[^\n]*-\\*-[^\n]*coding: \\([^\t\n ;]+\\)[^\n]*-\\*-")
+                       (progn
+                         (insert-file-contents-as-coding-system
+                          (intern (match-string 1)) mu-registration-file
+                          nil nil nil t)
+                         (goto-char (point-min))
+                         (condition-case nil
+                             (progn
+                               (setq exp (read (current-buffer)))
+                               t)
+                           (error nil))))))
+             (progn
+               (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)))
+               (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)))