bug#81666: 31.1; browse-url fails in emacsclient -nw

Eli Zaretskii <[email protected]>
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
> Cc: [email protected], [email protected], [email protected],
>  [email protected], [email protected], [email protected]
> Date: Fri, 21 Aug 2026 15:19:28 +0300
> From: Eli Zaretskii <[email protected]>
> 
> > >> > (FWIW, I tried to reproduce this in a PGTK build I have here, but
> > >> > couldn't: I see no error in this case.  And frame-parameter returns
> > >> > nil in my case, as expected.)
> > >>
> > >> Hello, thanks for looking into this.
> > >>
> > >> In the emacsclient TTY frame, I get ":0". This does indeed appear to be
> > >> the main culprit, because in an *emacs* TTY frame, I get nil, as you
> > >> describe.
> > 
> > With some grepping it appears to be because of commit:
> > e2b64f8999f79a5820ba00d2987885d7dda492d5
> > 
> > which solves bug#54844
> 
> Thanks, but I still don't see why this should cause the problem in the
> PGTK builds.  That change only affects GUI frames, or at least that's
> my reading of the code.

In any case, I propose the patch below.  Abdulnafé Toulaïmat, can you
please see if it solves your problem?

diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index b6513d1..ca91736 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -932,7 +932,9 @@ browse-url
       (if (stringp dpy)
         (cond
          ((featurep 'pgtk)
-          (setq classname (pgtk-backend-display-class))
+          (setq classname
+                (if (window-system)
+                    (pgtk-backend-display-class)))
           (if (equal classname "GdkWaylandDisplay")
               (progn
                 ;; The `display' frame parameter is probably wrong.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.