Subject: Re: bug#57752: 28.1.91; emacsclient-mail.desktop doesn't work for me

From: Max Nikulin <[email-masked]>
Date: Fri, 2 Dec 2022 21:52:39 +0700

On 13/09/2022 20:29, Damien Cassou wrote:
> Lars Ingebrigtsen writes:
>> I'd prefer to have a .desktop file that works without any helper
>> scripts.   Can't the emacsclient-mail.desktop file be rewritten to not
>> use quoting here?
> 
> This is maybe possible but I haven't found a way. Moreover, the
> constraints that "Field codes must not be used inside a quoted argument"
> makes things more complex.

It is possible to pass %u to shell using positional parameters:

     sh -c 'echo "$1"' demo ARGUMENT

However POSIX shell is not enough to escape double quote and backslash 
inside %u for elisp. BASH allows to perform substitutions during 
variable expansion. The idea is the following (it needs more backslashes 
to conform XDG spec):

bash -c 'e=${1//\\/\\\\}; e=${e///\"/\\\"}; emacsclient 
--alternate-editor= --display="$DISPLAY" --eval=\(message-mailto\ 
"\"$e\""\)' emacsclient-mailto %u