From 371cd9ed4be5d2aa54df93a35074a234f734289c Mon Sep 17 00:00:00 2001 From: kaoru Date: Sun, 30 Jan 2005 15:53:46 +0000 Subject: [PATCH] * elmo-util.el (elmo-passwd-alist-load, elmo-passwd-alist-save): Use `with-temp-buffer'. --- elmo/ChangeLog | 5 +++++ elmo/elmo-util.el | 25 ++++++++----------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/elmo/ChangeLog b/elmo/ChangeLog index a1e38b8..b9102c0 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,3 +1,8 @@ +2005-01-30 TAKAHASHI Kaoru + + * elmo-util.el (elmo-passwd-alist-load, elmo-passwd-alist-save): + Use `with-temp-buffer'. + 2005-01-30 Hiroya Murata * elmo-flag.el (elmo-folder-initialize): Fixed the last change. diff --git a/elmo/elmo-util.el b/elmo/elmo-util.el index dbaebc7..3a5e66d 100644 --- a/elmo/elmo-util.el +++ b/elmo/elmo-util.el @@ -364,23 +364,18 @@ Return value is a cons cell of (STRUCTURE . REST)" (defvar elmo-passwd-alist nil) (defun elmo-passwd-alist-load () - (save-excursion + (with-temp-buffer (let ((filename (expand-file-name elmo-passwd-alist-file-name elmo-msgdb-directory)) - (tmp-buffer (get-buffer-create " *elmo-passwd-alist-tmp*")) insert-file-contents-pre-hook ; To avoid autoconv-xmas... insert-file-contents-post-hook ret-val) (if (not (file-readable-p filename)) () - (set-buffer tmp-buffer) (insert-file-contents filename) - (setq ret-val - (condition-case nil - (read (current-buffer)) - (error nil nil)))) - (kill-buffer tmp-buffer) - ret-val))) + (condition-case nil + (read (current-buffer)) + (error nil nil)))))) (defun elmo-passwd-alist-clear () "Clear password cache." @@ -393,15 +388,12 @@ Return value is a cons cell of (STRUCTURE . REST)" (defun elmo-passwd-alist-save () "Save password into file." (interactive) - (save-excursion + (with-temp-buffer (let ((filename (expand-file-name elmo-passwd-alist-file-name elmo-msgdb-directory)) - (tmp-buffer (get-buffer-create " *elmo-passwd-alist-tmp*")) print-length print-level) - (set-buffer tmp-buffer) - (erase-buffer) - (prin1 elmo-passwd-alist tmp-buffer) - (princ "\n" tmp-buffer) + (prin1 elmo-passwd-alist (current-buffer)) + (princ "\n" (current-buffer)) ;;; (if (and (file-exists-p filename) ;;; (not (equal 384 (file-modes filename)))) ;;; (error "%s is not safe.chmod 600 %s!" filename filename)) @@ -410,8 +402,7 @@ Return value is a cons cell of (STRUCTURE . REST)" (write-region (point-min) (point-max) filename nil 'no-msg) (set-file-modes filename 384)) - (message "%s is not writable." filename)) - (kill-buffer tmp-buffer)))) + (message "%s is not writable." filename))))) (defun elmo-get-passwd (key) "Get password from password pool." -- 1.7.10.4