After upgrading from Emacs 28 to 29 and switching from xorg to
wayland, I have noticed emacs sometimes fail to open URLs. It seems to
be an ordering issue in my session: it seems like Emacs sometimes
starts before Sway is fully setup and the environment properly
populated, which makes it use the incorrect WAYLAND_DISPLAY variable.
This, in itself, is a bug in my setup: Emacs should be started
properly.
*But* my bug here is this fails completely silently. No URL gets
opened at all, which is *really* disruptive because I can open a bunch
of URLs while reading my mail, then i go to my browser and nothing is
there and now I've lost data.
Instead, browse-url should fail noisily if it fails to load a URL. If
I look at the `browse-url' source, for example at the end we see this
kind of failure, which happens when no browser can be found at all:
(if (functionp function)
(apply function url args)
(error "No suitable browser for URL %s" url))))
That is what I would expect the handler to do in this case, something
like "uh, we can't find your wayland display, so we're just dropping
this URL to the floor, sorry".
That function also has that mysterious blob:
(progn
;; The `display' frame parameter is probably wrong.
;; See bug#53969 for some context.
;; (setenv "WAYLAND_DISPLAY" dpy)
)
(setenv "DISPLAY" dpy)))
... which refers to:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=53969
... which I'm struggling to understand. If I uncomment that blob, the
bug, actually, just completely goes away which i find quite puzzling.
A.