It seems that w32-shell-execute cannot handle file://-URIs with url-escaped spaces, causing browse-url-of-file to fail. I observed this issue when trying to to markdown-export-and-preview from markdown-mode.el, but the issue also occurs with browse-url-of-buffer.

To reproduce, create a file C-x f c:/tmp/file with spaces.html and execute M-: (browse-url-of-buffer).

It will generate the backtrace

Debugger entered--Lisp error: (error "ShellExecute failed: Das System kann die angegebene Datei nicht finden.")
  w32-shell-execute("open" "file:///c:/tmp/a%20file%20with%20spaces.html")
  browse-url-default-windows-browser("file:///c:/tmp/a%20file%20with%20spaces.html" nil)
  apply(browse-url-default-windows-browser "file:///c:/tmp/a%20file%20with%20spaces.html" nil)
  browse-url-default-browser("file:///c:/tmp/a%20file%20with%20spaces.html" nil)
  apply(browse-url-default-browser "file:///c:/tmp/a%20file%20with%20spaces.html" nil)
  browse-url("file:///c:/tmp/a%20file%20with%20spaces.html")
  browse-url-of-file("c:/tmp/a file with spaces.html")
  browse-url-of-buffer()

For reference, calling

(browse-url "file:///c:/tmp/a file with spaces.html")

works as intended.


In GNU Emacs 25.1.1 (x86_64-w64-mingw32)
 of 2016-09-17 built on KAEL
Windowing system distributor 'Microsoft Corp.', version 10.0.14393
Configured using:
 'configure --prefix=/tmp/emacs --without-imagemagick 'CFLAGS=-O2
 -fomit-frame-pointer -g0''

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND DBUS NOTIFY ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS