From: Glenn Morris Date: Tue, 11 Dec 2007 05:49:10 +0000 (+0000) Subject: (url-cookie-write-file): Use url-make-private-file and with-temp-buffer. X-Git-Tag: emacs-pretest-23.0.90~8945 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4e44324af220f05b922fcabed7142b0601949f02;p=emacs.git (url-cookie-write-file): Use url-make-private-file and with-temp-buffer. --- diff --git a/lisp/url/url-cookie.el b/lisp/url/url-cookie.el index bc0fea4de44..40791d29fb6 100644 --- a/lisp/url/url-cookie.el +++ b/lisp/url/url-cookie.el @@ -119,19 +119,17 @@ telling Microsoft that." (set var new))) (defun url-cookie-write-file (&optional fname) - (setq fname (or fname url-cookie-file)) - (unless (file-directory-p (file-name-directory fname)) - (ignore-errors (make-directory (file-name-directory fname)))) - (cond - ((not url-cookies-changed-since-last-save) nil) - ((not (file-writable-p fname)) - (message "Cookies file %s (see variable `url-cookie-file') is unwritable." fname)) - (t + (when url-cookies-changed-since-last-save + (or fname (setq fname (expand-file-name url-cookie-file))) + (if (condition-case nil + (progn + (url-make-private-file fname) + nil) + (error t)) + (message "Error accessing cookie file `%s'" fname) (url-cookie-clean-up) (url-cookie-clean-up t) - (with-current-buffer (get-buffer-create " *cookies*") - (erase-buffer) - (fundamental-mode) + (with-temp-buffer (insert ";; Emacs-W3 HTTP cookies file\n" ";; Automatically generated file!!! DO NOT EDIT!!!\n\n" "(setq url-cookie-storage\n '") @@ -144,9 +142,8 @@ telling Microsoft that." ";; no-byte-compile: t\n" ";; End:\n") (set (make-local-variable 'version-control) 'never) - (write-file fname) - (setq url-cookies-changed-since-last-save nil) - (kill-buffer (current-buffer)))))) + (write-file fname)) + (setq url-cookies-changed-since-last-save nil)))) (defun url-cookie-store (name value &optional expires domain localpart secure) "Store a netscape-style cookie."