Subject: Re: bug#64310: 29.0.92; pure-GTK warning under Wayland

From: Pankaj Jangid <[email-masked]>
Date: Sat, 01 Jul 2023 14:55:01 +0530

Po Lu <[email-masked]> writes:

> This dialog cannot be displayed if Emacs is using the GDK Wayland
> backend.  Perhaps the WAYLAND_DISPLAY environment variable was not set
> when Emacs was started to handle the mailto URI.

$WAYLAND_DISPLAY is reporting value "wayland-0" (without quotes).

> How did you configure Emacs to handle such URIs?

I configured it using Gnome Settings UI. There is section for "Default
Applications". This lists three options for Mail - (1) Emacs (Mail,
Client) (2) Emacs (Mail) and (3) Evolution. I selected the first option.

Following are the relevant sections from ~/.config/mimeapps.list,

--8<---------------cut here---------------start------------->8---
[Added Associations]
x-scheme-handler/mailto=thunderbird.desktop;userapp-Thunderbird-9Y4UF1.desktop;emacs-mail.desktop;emacsclient-mail.desktop;

[Default Applications]
x-scheme-handler/mailto=emacsclient-mail.desktop
--8<---------------cut here---------------end--------------->8---

And contents of ~/.local/share/emacs/29.0.92/etc/emacsclient-mail.desktop

--8<---------------cut here---------------start------------->8---
[Desktop Entry]
Categories=Network;Email;
Comment=GNU Emacs is an extensible, customizable text editor - and more
# We want to pass the following commands to the shell wrapper:
# u=$(echo "$1" | sed 's/[\"]/\\&/g'); exec emacsclient --alternate-editor= --display="$DISPLAY" --eval "(message-mailto \"$u\")"
# Special chars '"', '$', and '\' must be escaped as '\\"', '\\$', and '\\\\'.
Exec=sh -c "u=\\$(echo \\"\\$1\\" | sed 's/[\\\\\\"]/\\\\\\\\&/g'); exec emacsclient --alternate-editor= --display=\\"\\$DISPLAY\\" --eval \\"(message-mailto \\\\\\"\\$u\\\\\\")\\"" sh %u
Icon=emacs
Name=Emacs (Mail, Client)
MimeType=x-scheme-handler/mailto;
NoDisplay=true
Terminal=false
Type=Application
Keywords=emacsclient;
Actions=new-window;new-instance;

[Desktop Action new-window]
Name=New Window
Exec=sh -c "u=\\$(echo \\"\\$1\\" | sed 's/[\\\\\\"]/\\\\\\\\&/g'); exec emacsclient --alternate-editor= --create-frame --eval \\"(message-mailto \\\\\\"\\$u\\\\\\")\\"" sh %u

[Desktop Action new-instance]
Name=New Instance
Exec=emacs -f message-mailto %u
--8<---------------cut here---------------end--------------->8---

And ~/.local/share/emacs/29.0.92/etc/emacs-mail.desktop contains,

--8<---------------cut here---------------start------------->8---
[Desktop Entry]
Categories=Network;Email;
Comment=GNU Emacs is an extensible, customizable text editor - and more
Exec=emacs -f message-mailto %u
Icon=emacs
Name=Emacs (Mail)
MimeType=x-scheme-handler/mailto;
NoDisplay=true
Terminal=false
Type=Application
--8<---------------cut here---------------end--------------->8---