diff options
Diffstat (limited to 'emacs/.emacs.d/lisp/my')
-rw-r--r-- | emacs/.emacs.d/lisp/my/my-net.el | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/emacs/.emacs.d/lisp/my/my-net.el b/emacs/.emacs.d/lisp/my/my-net.el index 7713dba..1ffbfae 100644 --- a/emacs/.emacs.d/lisp/my/my-net.el +++ b/emacs/.emacs.d/lisp/my/my-net.el @@ -42,13 +42,22 @@ my-download-dir))) (url-retrieve url 'my-fetch-url-save-and-switch (list file-name)))) + (defun my-fetch-url-save-and-switch (status file-name) - (unless (plist-get status :error) - (my-delete-http-header) - (write-file file-name) - (let ((coding-system-for-read 'utf-8)) + (when (plist-get status :error) + (error "My fetch failed: %s" (plist-get status :error))) + (my-delete-http-header) + (let ((to-insert (buffer-string)) + (buffer (find-file-noselect file-name)) + (coding-system-for-write 'utf-8)) + (kill-buffer) + (with-current-buffer buffer + (insert to-insert) + (goto-char (point-min)) + (save-buffer) (revert-buffer t t)) - (switch-to-buffer (current-buffer)))) + (switch-to-buffer buffer)) + ) (defun my-kill-http-header () (my-skip-http-header) |