unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#57752: 28.1.91; emacsclient-mail.desktop doesn't work for me
@ 2022-09-12 18:31 Damien Cassou
  2022-09-13 12:19 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 42+ messages in thread
From: Damien Cassou @ 2022-09-12 18:31 UTC (permalink / raw)
  To: 57752; +Cc: Peter Oliver

Hi,

The file emacsclient-mail.desktop that is provided by Emacs (see below
for an excerpt) doesn't seem to work for me. I would like mailto: links
in the web browser to open with emacsclient but nothing happens. How to
reproduce:

1. start the Emacs daemon (if not already done)

2. go to
https://lists.gnu.org/archive/html/emacs-devel/2022-09/msg00320.html in
a non-Emacs web browser

3. click the "Eli Zaretskii" button after "reply via email to"

Expected: An Emacs client frame appears with a buffer in message mode
Actual: Nothing happens

If you try to reproduce and you get a different application opening to
compose your email, you might want to add the following to
~/.config/mimeapps.list:

  [Default Applications]
  x-scheme-handler/mailto=emacsclient-mail.desktop

It feels like launching my web browser from the terminal sometimes makes
it work, but that's not really reliable.

The freedesktop Desktop Entry Specification [1] contains:

  Field codes must not be used inside a quoted argument, the result of
  field code expansion inside a quoted argument is undefined.

It seems to me that the .desktop file Emacs provides does just that: use
a field code (%u) inside a quoted argument. I might be wrong in the
interpretation of the spec though as the next sentence in the spec seems
to contradict this interpretation.

Anyway, I found a way to always have it working:

1. create a file emacs-compose-email.sh that starts emacsclient
2. add the executable bit to the file
3. reference the shell script from emacsclient-mail.desktop

See below for the script and .desktop file. Another advantage of this
approach is that the desktop file becomes much simpler with much less
backslashes.

My question is: do you want a patch with this change?

emacs-compose-email.sh:
  #!/usr/bin/env bash
  emacsclient --alternate-editor= --eval "(message-mailto \"$1\")"

Working emacsclient-mail.desktop:
  [Desktop Entry]
  Exec=emacs-compose-email.sh %u
  MimeType=x-scheme-handler/mailto
  Name=Emacs (Mail, Client)
  NoDisplay=true
  Terminal=false
  Type=Application
  Version=1.4

Excerpt of the existing (non-working) emacsclient-mail.desktop:
  [Desktop Entry]
  Exec=sh -c "exec emacsclient --alternate-editor= --display=\\"\\$DISPLAY\\" --eval \\\\(message-mailto\\\\ \\\\\\"%u\\\\\\"\\\\)"
  Name=Emacs (Mail, Client)
  MimeType=x-scheme-handler/mailto;
  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

[1]: https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill





^ permalink raw reply	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2023-07-26  5:14 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-12 18:31 bug#57752: 28.1.91; emacsclient-mail.desktop doesn't work for me Damien Cassou
2022-09-13 12:19 ` Lars Ingebrigtsen
2022-09-13 13:29   ` Damien Cassou
2022-09-13 13:41     ` Eli Zaretskii
2022-09-13 13:58       ` Damien Cassou
2022-09-13 14:57         ` Robert Pluim
2022-09-13 15:32           ` Damien Cassou
2022-09-15 18:30         ` Jim Porter
2022-09-16  9:54           ` Lars Ingebrigtsen
2022-09-16 10:09             ` Robert Pluim
2022-09-16 10:14               ` Lars Ingebrigtsen
2022-09-16 14:18                 ` Robert Pluim
2022-09-16 15:21                   ` Jim Porter
2022-09-16 12:38               ` Damien Cassou
2022-09-16 12:50                 ` Gregory Heytings
2022-09-16 14:46                   ` Damien Cassou
2022-09-16 15:07                     ` Gregory Heytings
2022-09-16 16:18                       ` Peter Oliver
2022-09-16 16:42                         ` Gregory Heytings
2022-09-16 17:21                           ` Jim Porter
2022-09-16 18:26                             ` Gregory Heytings
2022-09-16 19:33                               ` Jim Porter
2022-09-16 20:04                                 ` Gregory Heytings
2022-09-18 13:58                                   ` Robert Pluim
2022-09-16 14:19                 ` Robert Pluim
2022-09-16 14:47                   ` Damien Cassou
2022-09-16 15:17             ` Jim Porter
2022-09-18 10:23               ` Lars Ingebrigtsen
2022-09-18 14:46                 ` Robert Pluim
2022-09-19  8:09                   ` Lars Ingebrigtsen
2022-09-18 18:31                 ` Jim Porter
2022-09-19  8:12                   ` Lars Ingebrigtsen
2022-09-19 15:48                     ` Jim Porter
2022-09-19 18:45                       ` Lars Ingebrigtsen
2022-09-19  8:56                 ` Gregory Heytings
2022-09-19 12:00                   ` Lars Ingebrigtsen
2022-09-19 16:05                   ` Jim Porter
2022-09-19 17:01                     ` Gregory Heytings
2022-12-02 14:52     ` Max Nikulin
2023-07-26  5:14       ` Max Nikulin
2022-09-16 19:42   ` Jim Porter
2022-09-18 10:26     ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).