Subject: bug#49292: Acknowledgement (Improvements to emacs-mail.desktop)

From: Peter Oliver <[email-masked]>
Date: Wed, 30 Jun 2021 15:43:54 +0100 (BST)

And here’s a slightly improved version of the first patch, which uses exec to prevent the sh process from potentially sticking around.

-- 
Peter Oliver

From 4f5e9f789bc7919aa87327940b54bfde7ee979c2 Mon Sep 17 00:00:00 2001
From: Peter Oliver <[email-masked]>
Date: Wed, 9 Jun 2021 12:44:32 +0100
Subject: [PATCH] Provide an emacsclient-mail.desktop
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

We provide both an emacs.desktop and an emacsclient.desktop, so for
consistency let’s do the same with mail.

* etc/emacs-mail.desktop: Extract suggestions for using emacsclient
from comments to create emacsclient-mail.desktop.
* etc/emacsclient-mail.desktop: Send mail using an existing Emacs
rather than starting a new one.
---
 etc/NEWS                     |  1 +
 etc/emacs-mail.desktop       | 14 +-------------
 etc/emacsclient-mail.desktop | 19 +++++++++++++++++++
 3 files changed, 21 insertions(+), 13 deletions(-)
 create mode 100644 etc/emacsclient-mail.desktop

diff --git a/etc/NEWS b/etc/NEWS
index 701b9a73a8..3106bb1bed 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1073,6 +1073,7 @@ Clicking on a 'mailto:' link in other applications will then open
 Emacs with headers filled out according to the link, e.g.
 "mailto:[email-masked]?subject=This+is+a+test".  If you prefer
 emacsclient, use "emacsclient -e '(message-mailto "%u")'"
+or "emacsclient-mail.desktop".
 
 ---
 *** Change to default value of 'message-draft-headers' user option.
diff --git a/etc/emacs-mail.desktop b/etc/emacs-mail.desktop
index 251afa100c..3a96b9ec8c 100644
--- a/etc/emacs-mail.desktop
+++ b/etc/emacs-mail.desktop
@@ -1,22 +1,10 @@
 [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=false
 Terminal=false
 Type=Application
-
-Exec=emacs -f message-mailto %u
-# # If you prefer to use emacsclient, use this instead:
-# Exec=sh -c 'emacsclient --alternate-editor= --display="$DISPLAY" --eval "(message-mailto \"%u\")"'
-# Actions=new-window;new-instance;
-
-# [Desktop Action new-window]
-# Name=New Window
-# Exec=emacsclient --alternate-editor= --create-frame --eval '(message-mailto "%u")'
-
-# [Desktop Action new-instance]
-# Name=New Instance
-# Exec=emacs -f message-mailto %u
diff --git a/etc/emacsclient-mail.desktop b/etc/emacsclient-mail.desktop
new file mode 100644
index 0000000000..4df79ed300
--- /dev/null
+++ b/etc/emacsclient-mail.desktop
@@ -0,0 +1,19 @@
+[Desktop Entry]
+Categories=Network;Email;
+Comment=GNU Emacs is an extensible, customizable text editor - and more
+Exec=sh -c 'exec emacsclient --alternate-editor= --display="$DISPLAY" --eval "(message-mailto \"%u\")"'
+Icon=emacs
+Name=Emacs (Mail, Client)
+MimeType=x-scheme-handler/mailto;
+NoDisplay=false
+Terminal=false
+Type=Application
+Actions=new-window;new-instance;
+
+[Desktop Action new-window]
+Name=New Window
+Exec=emacsclient --alternate-editor= --create-frame --eval '(message-mailto "%u")'
+
+[Desktop Action new-instance]
+Name=New Instance
+Exec=emacs -f message-mailto %u
-- 
2.31.1