]> git.eshelyaron.com Git - emacs.git/commitdiff
(url-history-save-history): Use url-make-private-file and with-temp-buffer.
authorGlenn Morris <rgm@gnu.org>
Tue, 11 Dec 2007 05:49:36 +0000 (05:49 +0000)
committerGlenn Morris <rgm@gnu.org>
Tue, 11 Dec 2007 05:49:36 +0000 (05:49 +0000)
lisp/url/ChangeLog
lisp/url/url-history.el

index 9d86733ab98ab1ec215fd0a31b87796ff4bdebb3..a1b86af13ae785b3aa45425f62667a88af329ff2 100644 (file)
@@ -1,3 +1,12 @@
+2007-12-11  Glenn Morris  <rgm@gnu.org>
+
+       * url.el (url-configuration-directory): Make it a defcustom.
+
+       * url-util.el (url-make-private-file): New function.
+       * url-cookie.el (url-cookie-write-file):
+       * url-history.el (url-history-save-history):
+       Use url-make-private-file and with-temp-buffer.
+
 2007-12-06  Glenn Morris  <rgm@gnu.org>
 
        * url-file.el, url-mailto.el: Remove directory part from filenames
index 605ffa0145fa22cde6b928031fbcb6d98521fbaf..bf4acf5d0466191d01b7fab2bedf7d21542e63c1 100644 (file)
@@ -112,29 +112,28 @@ to run the `url-history-setup-save-timer' function manually."
   (puthash (if (vectorp url) (url-recreate-url url) url) time
            url-history-hash-table))
 
+(autoload 'url-make-private-file "url-util")
+
 (defun url-history-save-history (&optional fname)
   "Write the global history file into `url-history-file'.
 The type of data written is determined by what is in the file to begin
 with.  If the type of storage cannot be determined, then prompt the
 user for what type to save as."
   (interactive)
-  (or fname (setq fname (expand-file-name url-history-file)))
-  (unless (file-directory-p (file-name-directory fname))
-    (condition-case nil
-        (make-directory (file-name-directory fname))
-      (error nil)))
-  (cond
-   ((not url-history-changed-since-last-save) nil)
-   ((not (file-writable-p fname))
-    (message "%s is unwritable." fname))
-   (t
-    (let ((make-backup-files nil)
-         (version-control nil)
-         (require-final-newline t))
-      (with-current-buffer (get-buffer-create " *url-tmp*")
-       (erase-buffer)
-       (let ((count 0))
-         (maphash (lambda (key value)
+  (when url-history-changed-since-last-save
+    (or fname (setq fname (expand-file-name url-history-file)))
+    (if (condition-case nil
+            (progn
+              (url-make-private-file fname)
+              nil)
+          (error t))
+        (message "Error accessing history file `%s'" fname)
+      (let ((make-backup-files nil)
+            (version-control nil)
+            (require-final-newline t)
+            (count 0))
+        (with-temp-buffer
+          (maphash (lambda (key value)
                      (while (string-match "[\r\n]+" key)
                        (setq key (concat (substring key 0 (match-beginning 0))
                                          (substring key (match-end 0) nil))))
@@ -153,9 +152,8 @@ user for what type to save as."
          ;;          (/ count 4)))
          ;; (goto-char (point-max))
          (insert "\n")
-         (write-file fname))
-       (kill-buffer (current-buffer))))))
-  (setq url-history-changed-since-last-save nil))
+         (write-file fname)))
+      (setq url-history-changed-since-last-save nil))))
 
 (defun url-have-visited-url (url)
   (url-do-setup)