From: yamaoka Date: Fri, 17 Mar 2000 09:55:26 +0000 (+0000) Subject: (gnus-re-read-newsrc-el-file): New function. X-Git-Tag: t-gnus-6_14_1-16~4 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=d28461f2ffe383f69e738539a084362a8a84bc20;p=elisp%2Fgnus.git- (gnus-re-read-newsrc-el-file): New function. (gnus-read-newsrc-el-file): If it fails, attempt to re-read the file using `gnus-re-read-newsrc-el-file'. In that case, the compiled format specs in the file which may be created by the other Gnusae should be ignored. --- diff --git a/lisp/gnus-start.el b/lisp/gnus-start.el index 7bbcb30..77d7a61 100644 --- a/lisp/gnus-start.el +++ b/lisp/gnus-start.el @@ -1998,16 +1998,20 @@ If FORCE is non-nil, the .newsrc file is read." (gnus-message 5 "Reading %s..." ding-file) (let (gnus-newsrc-assoc) (when (file-exists-p ding-file) - (condition-case nil - (with-temp-buffer - (insert-file-contents-as-coding-system - gnus-startup-file-coding-system ding-file) - (eval-region (point-min) (point-max))) - (error - (ding) - (unless (gnus-yes-or-no-p - (format "Error in %s; continue? " ding-file)) - (error "Error in %s" ding-file)))) + (with-temp-buffer + (condition-case nil + (progn + (insert-file-contents-as-coding-system + gnus-startup-file-coding-system ding-file) + (eval-region (point-min) (point-max))) + (error + (ding) + (or (not (or (zerop (buffer-size)) + (eq 'binary gnus-startup-file-coding-system) + (gnus-re-read-newsrc-el-file ding-file))) + (gnus-yes-or-no-p + (format "Error in %s; continue? " ding-file)) + (error "Error in %s" ding-file))))) (when gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))) (gnus-make-hashtable-from-newsrc-alist) @@ -2024,6 +2028,35 @@ If FORCE is non-nil, the .newsrc file is read." (apply 'gnus-product-read-variable-file-1 (car list)) (setq list (cdr list)))))) +(defun gnus-re-read-newsrc-el-file (file) + "Attempt to re-read .newsrc.eld file. Returns `nil' if successful. +The backup file \".newsrc.eld_\" will be created before re-reading." + (message "Error in %s; retrying..." file) + (if (and + (condition-case nil + (let ((backup (concat file "_"))) + (copy-file file backup 'ok-if-already-exists 'keep-time) + (message " (The backup file %s has been created)" backup) + t) + (error nil)) + (progn + (insert-file-contents-as-binary file nil nil nil 'replace) + (when (re-search-forward + "^[\t ]*([\t\n\r ]*setq[\t\n\r ]+gnus-format-specs" nil t) + (delete-region (goto-char (match-beginning 0)) (forward-list 1)) + (decode-coding-region (point-min) (point-max) + gnus-startup-file-coding-system) + (condition-case nil + (progn + (eval-region (point-min) (point-max)) + t) + (error nil))))) + (prog1 + nil + (message "Error in %s; retrying...done" file)) + (message "Error in %s; retrying...failed" file) + t)) + (defun gnus-product-read-variable-file-1 (file checking-methods coding &rest variables) (let (gnus-product-file-version method file-ver)