diff options
author | Yuchen Pei <id@ypei.org> | 2023-07-23 17:26:54 +1000 |
---|---|---|
committer | Yuchen Pei <id@ypei.org> | 2023-07-23 17:26:54 +1000 |
commit | 4ca924fc02249b0ff7d9e379358a26dda10482f8 (patch) | |
tree | f40cbbf7a672438d8ad41c8222fa1f7ae6cf7504 /emacs | |
parent | a4b7de02b0389feff60570afb9d97f0123bbbc0f (diff) |
Better my-fetch-url
Diffstat (limited to 'emacs')
-rw-r--r-- | emacs/.emacs.d/init/ycp-prog.el | 7 | ||||
-rw-r--r-- | emacs/.emacs.d/lisp/my/my-net.el | 19 |
2 files changed, 18 insertions, 8 deletions
diff --git a/emacs/.emacs.d/init/ycp-prog.el b/emacs/.emacs.d/init/ycp-prog.el index 7b4f8f3..63cdb36 100644 --- a/emacs/.emacs.d/init/ycp-prog.el +++ b/emacs/.emacs.d/init/ycp-prog.el @@ -215,7 +215,6 @@ "C-c C-z" #'ielm "C-," #'my-insert-current-prefix) (add-hook 'emacs-lisp-mode-hook (lambda () (auto-fill-mode 1))) - (setq print-length 1000) (my-keybind global-map "<f5>" #'my-toggle-debug-on-error-quit "C-c e e" (lambda () (interactive) @@ -242,8 +241,10 @@ (setq debugger-stack-frame-as-list t) (setq display-raw-bytes-as-hex t) -(setq eval-expression-print-length 300) -(setq eval-expression-print-level 10) +;; No limit in printing +(setq print-length nil + eval-expression-print-length nil + eval-expression-print-level nil) ;;; paredit (my-package paredit 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) |