Refreshing the preview fails on Windows
The html is updated, but the address passed to eww contains the drive letter twice, so fails to load.
Wrote x:/org files/Inbox.html
eww-reload: Opening input file: No such file or directory, x:/x:/org files/Inbox.html
mouse-minibuffer-check: Minibuffer window is not active
The preview initially loaded correctly though.
- GNU Emacs 29.1
- org-preview-html installed with Doom's package manger, at origin/HEAD 785e1f5 2022-08-09 05:33:43 -0500
Hi. I don't have a Windows machine to test on. If you can make a fix let me know. Regardless I will try to take a look and see if this is an issue. Sorry for not getting to this issue.
This seems to work but I don't know if it has side effects on other OSes, or could be neater?
(defun org-preview-html--reload-preview ()
"Reload the preview in the browser."
(when (bound-and-true-p org-preview-html--browser-buffer)
(pop-to-buffer org-preview-html--browser-buffer)
(cond ((eq org-preview-html-viewer 'xwidget) (xwidget-webkit-reload))
((eq org-preview-html-viewer 'eww)
(let* ((original-buffer (get-buffer org-preview-html--previewed-buffer-name))
(html-file (with-current-buffer original-buffer
(concat (file-name-sans-extension buffer-file-name) ".html"))))
(eww-open-file html-file))))))
Okay, I guess what you're doing here is calling to open the file rather than using eww-reload like we currently do. I do not know why eww-reload would cause the drive path to be doubled on Windows. We haven't had other Windows issues except https://github.com/jakebox/org-preview-html/issues/15 which was resolved. I can look into this further though
Yep, that's how I could get it to work. Maybe the real bug lies on eww?
Can you try to open an HTML file manually with EWW, and call eww-reload, and see if the behavior is the same?
Ah, yes the same problem happens.
I'm on GNU Emacs 30.1 (build 2, x86_64-w64-mingw32) of 2025-02-23
Ok, good to know. Perhaps we add a conditional, for users of Emacs with mingw32. Let me make a fix and you can try it out, and if it works, we'll put in master. Thanks very much for your help with this!
Hi @r4dian can you try that branch out? If you just want to update one function you can paste this into an elisp buffer and evaluate it.
https://github.com/jakebox/org-preview-html/blob/4f1844cfa92bf6cfc5eb1a3d7c4a6c24322480d7/org-preview-html.el#L136
Thanks, I'll be offline for a week but will test when I can.
On 12 August 2025 19:16:37 BST, Jacob Boxerman @.***> wrote:
jakebox left a comment (jakebox/org-preview-html#22)
Hi @r4dian can you try that branch out? If you just want to update one function you can paste this into an elisp buffer and evaluate it. https://github.com/jakebox/org-preview-html/blob/785e1f5c99c0f2d76a9a6611a06b4552a343e221/org-preview-html.el#L136
-- Reply to this email directly or view it on GitHub: https://github.com/jakebox/org-preview-html/issues/22#issuecomment-3180472816 You are receiving this because you were mentioned.
Message ID: @.***>
Tried branch:
GNU Emacs 30.1 (build 2, x86_64-w64-mingw32) of 2025-06-12
git clone --branch=mingw32-eww-fix https://github.com/jakebox/org-preview-html.git
init.el (org-preview-html not installed)
(add-to-list 'load-path "~/.emacs.d/org-preview-html") (require 'org-preview-html)
The results for different refresh modes:
save: if: Wrong type argument: stringp, nil
export (org-html-export-to-html): if: Wrong type argument: stringp, nil
manual (org-preview-html-refresh): if: Wrong type argument:stringp, nil
timer: Error running timer ‘org-preview-html-refresh’: (wrong-type-argument stringp nil) [2 times]
additionally, in "export mode" C e h h (C e h o)
apply: Wrong number of arguments: #[nil ((let ((save-selected-window--state (internal--before-save-selected-window))) (save-current-buffer (unwind-protect (progn (pop-to-buffer org-preview-html--browser-buffer) (cond ((eq org-preview-html-viewer 'xwidget) (xwidget-webkit-reload)) ((eq org-preview-html-viewer 'eww) (if (string-match-p "mingw32" system-configuration) (eww-open-file org-preview-html--html-file) (let ... ...))))) (internal--after-save-selected-window save-selected-window--state))))) (t) nil "Reload preview."], 4
Thanks for testing. Is system-configuration set? C-h v <RET> system-configuration
Ok, I added a manual variable to enable the workaround in d327417. If it doesn't work by default, you can: (setq org-preview-html-mingw-workaround t). Let me know if this works. Sorry I don't have a Windows machine to test on.
Tried, unfortunately the same result.
system-configuration "x86_64-w64-mingw32" org-preview-html-mingw-workaround t nil - without a difference.
if: Wrong type argument: stringp, nil
Drat, I'm out of practice with my Elisp. Give it one more try, I just pushed (I think) a fix – came to me overnight.
The same result, but I used toggle-debug-on-error ("save" mode). Perhaps you can find something useful here?
Debugger entered--Lisp error: (wrong-type-argument stringp nil) eww-open-file(nil) (if (org-preview-html--mingw-p) (eww-open-file org-preview-html--html-file) (let ((save-selected-window--state (internal--before-with-selected-window (selected-window)))) (save-current-buffer (unwind-protect (progn (select-window (car save-selected-window--state) 'norecord) (let ((eww-point ...) (eww-window-start ...)) (eww-reload) (goto-char eww-point) (set-window-start nil eww-window-start))) (internal--after-with-selected-window save-selected-window--state))))) (cond ((eq org-preview-html-viewer 'xwidget) (xwidget-webkit-reload)) ((eq org-preview-html-viewer 'eww) (if (org-preview-html--mingw-p) (eww-open-file org-preview-html--html-file) (let ((save-selected-window--state (internal--before-with-selected-window (selected-window)))) (save-current-buffer (unwind-protect (progn (select-window ... ...) (let ... ... ... ...)) (internal--after-with-selected-window save-selected-window--state))))))) (progn (pop-to-buffer org-preview-html--browser-buffer) (cond ((eq org-preview-html-viewer 'xwidget) (xwidget-webkit-reload)) ((eq org-preview-html-viewer 'eww) (if (org-preview-html--mingw-p) (eww-open-file org-preview-html--html-file) (let ((save-selected-window--state (internal--before-with-selected-window ...))) (save-current-buffer (unwind-protect (progn ... ...) (internal--after-with-selected-window save-selected-window--state)))))))) (unwind-protect (progn (pop-to-buffer org-preview-html--browser-buffer) (cond ((eq org-preview-html-viewer 'xwidget) (xwidget-webkit-reload)) ((eq org-preview-html-viewer 'eww) (if (org-preview-html--mingw-p) (eww-open-file org-preview-html--html-file) (let ((save-selected-window--state ...)) (save-current-buffer (unwind-protect ... ...))))))) (internal--after-save-selected-window save-selected-window--state)) (save-current-buffer (unwind-protect (progn (pop-to-buffer org-preview-html--browser-buffer) (cond ((eq org-preview-html-viewer 'xwidget) (xwidget-webkit-reload)) ((eq org-preview-html-viewer 'eww) (if (org-preview-html--mingw-p) (eww-open-file org-preview-html--html-file) (let (...) (save-current-buffer ...)))))) (internal--after-save-selected-window save-selected-window--state))) (let ((save-selected-window--state (internal--before-save-selected-window))) (save-current-buffer (unwind-protect (progn (pop-to-buffer org-preview-html--browser-buffer) (cond ((eq org-preview-html-viewer 'xwidget) (xwidget-webkit-reload)) ((eq org-preview-html-viewer 'eww) (if (org-preview-html--mingw-p) (eww-open-file org-preview-html--html-file) (let ... ...))))) (internal--after-save-selected-window save-selected-window--state)))) org-preview-html--reload-preview() org-preview-html-refresh() run-hooks(after-save-hook) basic-save-buffer(t) save-buffer(1) funcall-interactively(save-buffer 1) command-execute(save-buffer)