From d12b1368079d42a683bfd1098f5e16c300da3612 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Sat, 15 Jul 2023 20:43:32 +1000 Subject: Update fetching mechanism. Before: write process output buffer content to a file. After: open the file, insert the buffer string from the process output buffer, then save the file. This way we start with a "clean" buffer that allows undo etc. --- wiki-utils.el | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/wiki-utils.el b/wiki-utils.el index 4ceeade..ae61d4d 100644 --- a/wiki-utils.el +++ b/wiki-utils.el @@ -52,10 +52,16 @@ Then calls CALLBACK which is a closure taking no argument." (when (plist-get status :error) (error "Wiki fetch failed: %s" (plist-get status :error))) (wiki-delete-http-header) - (write-file file-name) - (let ((coding-system-for-read 'utf-8)) - (revert-buffer t t)) - (switch-to-buffer (current-buffer)) + (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 buffer)) ) (defun wiki-delete-http-header () -- cgit v1.2.3