From 336e43005acc5a65209c35167526f54ab6a4457b Mon Sep 17 00:00:00 2001 From: yamaoka Date: Wed, 29 Aug 2001 11:30:18 +0000 Subject: [PATCH] * mu-register.el (mu-cite-load-registration-file): Retry to read a file when failed. --- ChangeLog | 5 +++++ mu-register.el | 48 ++++++++++++++++++++++++++++++++++++------------ 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6ac01fe..8cd5f18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-08-29 Katsumi Yamaoka + + * mu-register.el (mu-cite-load-registration-file): Retry to read + a file when failed. + 2001-08-03 Katsumi Yamaoka * mu-register.el (mu-cite-save-registration-file): Use diff --git a/mu-register.el b/mu-register.el index 911b007..e0cee98 100644 --- a/mu-register.el +++ b/mu-register.el @@ -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))) -- 1.7.10.4