Commit 4e44324a authored by Glenn Morris's avatar Glenn Morris

(url-cookie-write-file): Use url-make-private-file and with-temp-buffer.

parent 8703ea53
...@@ -119,19 +119,17 @@ telling Microsoft that." ...@@ -119,19 +119,17 @@ telling Microsoft that."
(set var new))) (set var new)))
(defun url-cookie-write-file (&optional fname) (defun url-cookie-write-file (&optional fname)
(setq fname (or fname url-cookie-file)) (when url-cookies-changed-since-last-save
(unless (file-directory-p (file-name-directory fname)) (or fname (setq fname (expand-file-name url-cookie-file)))
(ignore-errors (make-directory (file-name-directory fname)))) (if (condition-case nil
(cond (progn
((not url-cookies-changed-since-last-save) nil) (url-make-private-file fname)
((not (file-writable-p fname)) nil)
(message "Cookies file %s (see variable `url-cookie-file') is unwritable." fname)) (error t))
(t (message "Error accessing cookie file `%s'" fname)
(url-cookie-clean-up) (url-cookie-clean-up)
(url-cookie-clean-up t) (url-cookie-clean-up t)
(with-current-buffer (get-buffer-create " *cookies*") (with-temp-buffer
(erase-buffer)
(fundamental-mode)
(insert ";; Emacs-W3 HTTP cookies file\n" (insert ";; Emacs-W3 HTTP cookies file\n"
";; Automatically generated file!!! DO NOT EDIT!!!\n\n" ";; Automatically generated file!!! DO NOT EDIT!!!\n\n"
"(setq url-cookie-storage\n '") "(setq url-cookie-storage\n '")
...@@ -144,9 +142,8 @@ telling Microsoft that." ...@@ -144,9 +142,8 @@ telling Microsoft that."
";; no-byte-compile: t\n" ";; no-byte-compile: t\n"
";; End:\n") ";; End:\n")
(set (make-local-variable 'version-control) 'never) (set (make-local-variable 'version-control) 'never)
(write-file fname) (write-file fname))
(setq url-cookies-changed-since-last-save nil) (setq url-cookies-changed-since-last-save nil))))
(kill-buffer (current-buffer))))))
(defun url-cookie-store (name value &optional expires domain localpart secure) (defun url-cookie-store (name value &optional expires domain localpart secure)
"Store a netscape-style cookie." "Store a netscape-style cookie."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment