diff options
| author | Glenn Morris | 2007-12-11 05:49:36 +0000 |
|---|---|---|
| committer | Glenn Morris | 2007-12-11 05:49:36 +0000 |
| commit | 9824ded5dded6f1d25ba7c71d959d56ac2f10e7e (patch) | |
| tree | 0dcc8804f96b1f6c4aec41eb25254c767f01e667 | |
| parent | 4e44324af220f05b922fcabed7142b0601949f02 (diff) | |
| download | emacs-9824ded5dded6f1d25ba7c71d959d56ac2f10e7e.tar.gz emacs-9824ded5dded6f1d25ba7c71d959d56ac2f10e7e.zip | |
(url-history-save-history): Use url-make-private-file and with-temp-buffer.
| -rw-r--r-- | lisp/url/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/url/url-history.el | 38 |
2 files changed, 27 insertions, 20 deletions
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog index 9d86733ab98..a1b86af13ae 100644 --- a/lisp/url/ChangeLog +++ b/lisp/url/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2007-12-11 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * url.el (url-configuration-directory): Make it a defcustom. | ||
| 4 | |||
| 5 | * url-util.el (url-make-private-file): New function. | ||
| 6 | * url-cookie.el (url-cookie-write-file): | ||
| 7 | * url-history.el (url-history-save-history): | ||
| 8 | Use url-make-private-file and with-temp-buffer. | ||
| 9 | |||
| 1 | 2007-12-06 Glenn Morris <rgm@gnu.org> | 10 | 2007-12-06 Glenn Morris <rgm@gnu.org> |
| 2 | 11 | ||
| 3 | * url-file.el, url-mailto.el: Remove directory part from filenames | 12 | * url-file.el, url-mailto.el: Remove directory part from filenames |
diff --git a/lisp/url/url-history.el b/lisp/url/url-history.el index 605ffa0145f..bf4acf5d046 100644 --- a/lisp/url/url-history.el +++ b/lisp/url/url-history.el | |||
| @@ -112,29 +112,28 @@ to run the `url-history-setup-save-timer' function manually." | |||
| 112 | (puthash (if (vectorp url) (url-recreate-url url) url) time | 112 | (puthash (if (vectorp url) (url-recreate-url url) url) time |
| 113 | url-history-hash-table)) | 113 | url-history-hash-table)) |
| 114 | 114 | ||
| 115 | (autoload 'url-make-private-file "url-util") | ||
| 116 | |||
| 115 | (defun url-history-save-history (&optional fname) | 117 | (defun url-history-save-history (&optional fname) |
| 116 | "Write the global history file into `url-history-file'. | 118 | "Write the global history file into `url-history-file'. |
| 117 | The type of data written is determined by what is in the file to begin | 119 | The type of data written is determined by what is in the file to begin |
| 118 | with. If the type of storage cannot be determined, then prompt the | 120 | with. If the type of storage cannot be determined, then prompt the |
| 119 | user for what type to save as." | 121 | user for what type to save as." |
| 120 | (interactive) | 122 | (interactive) |
| 121 | (or fname (setq fname (expand-file-name url-history-file))) | 123 | (when url-history-changed-since-last-save |
| 122 | (unless (file-directory-p (file-name-directory fname)) | 124 | (or fname (setq fname (expand-file-name url-history-file))) |
| 123 | (condition-case nil | 125 | (if (condition-case nil |
| 124 | (make-directory (file-name-directory fname)) | 126 | (progn |
| 125 | (error nil))) | 127 | (url-make-private-file fname) |
| 126 | (cond | 128 | nil) |
| 127 | ((not url-history-changed-since-last-save) nil) | 129 | (error t)) |
| 128 | ((not (file-writable-p fname)) | 130 | (message "Error accessing history file `%s'" fname) |
| 129 | (message "%s is unwritable." fname)) | 131 | (let ((make-backup-files nil) |
| 130 | (t | 132 | (version-control nil) |
| 131 | (let ((make-backup-files nil) | 133 | (require-final-newline t) |
| 132 | (version-control nil) | 134 | (count 0)) |
| 133 | (require-final-newline t)) | 135 | (with-temp-buffer |
| 134 | (with-current-buffer (get-buffer-create " *url-tmp*") | 136 | (maphash (lambda (key value) |
| 135 | (erase-buffer) | ||
| 136 | (let ((count 0)) | ||
| 137 | (maphash (lambda (key value) | ||
| 138 | (while (string-match "[\r\n]+" key) | 137 | (while (string-match "[\r\n]+" key) |
| 139 | (setq key (concat (substring key 0 (match-beginning 0)) | 138 | (setq key (concat (substring key 0 (match-beginning 0)) |
| 140 | (substring key (match-end 0) nil)))) | 139 | (substring key (match-end 0) nil)))) |
| @@ -153,9 +152,8 @@ user for what type to save as." | |||
| 153 | ;; (/ count 4))) | 152 | ;; (/ count 4))) |
| 154 | ;; (goto-char (point-max)) | 153 | ;; (goto-char (point-max)) |
| 155 | (insert "\n") | 154 | (insert "\n") |
| 156 | (write-file fname)) | 155 | (write-file fname))) |
| 157 | (kill-buffer (current-buffer)))))) | 156 | (setq url-history-changed-since-last-save nil)))) |
| 158 | (setq url-history-changed-since-last-save nil)) | ||
| 159 | 157 | ||
| 160 | (defun url-have-visited-url (url) | 158 | (defun url-have-visited-url (url) |
| 161 | (url-do-setup) | 159 | (url-do-setup) |