On 21/06/2025 13:54, Ihor Radchenko wrote:
Exec=emacsclient --alternate-editor= --eval "(message-mailto (pop
server-eval-args-left))" %u
line in emacsclient-mail.desktop?
That would be backwards-incompatible change.
There is no way to fix it keeping absolute backward compatibility. In
<https://debbugs.gnu.org/74467#101>
Eli correctly pointed out that there is no way to distinguish
SCHEME:SOMETHING as a URL and as a file name in the current directory.
Technically, one can already do
emacsclient --eval "(org-protocol-check-filename-for-protocol (pop
server-eval-args-left))" PROTOCOL-URL
I have never tried greedy sub-protocols, perhaps they are broken during
migration to new style advice, but the handler should receive all
arguments, not just first one (and perhaps %U, not %u in .desktop file).
but that honestly looks awful if we consider scripts directly calling
capture (or any other) protocol from shell, not from URL handler.
In the .desktop file I would strongly prefer to see something like
Exec=emacsclient-url -- %U
A more realistic command is (assuming a new function)
emacsclient --eval "(dispatch-url)" %U
An important point here is that it should be limited set of allowed
schemes, not all ones supported by `url-handler-mode'. I do not like
initializing Org mode for a remote file due to https:// URL leaked to
emacsclient due to some desktop environment bug.
Taking into account stance of Emacs developers, my expectation of result
in a .desktop file is (if I properly escaped new quote characters and if
WAYLAND_DISPLAY does not require special treatment)
Exec=sh -c "if [ -n \\"\\$*\\" ]; then exec emacsclient
--alternate-editor= --display=\\"\\$DISPLAY\\" --eval
\\"(dispatch-url)\\" \\"\\$@\\"; else exec emacsclient
--alternate-editor= --create-frame; fi" sh %U
to handle both "mailto:", and "org-protocol:" with perspectives for
"mid:", etc.