Subject: bug#74467: 30.1; emacsclient.desktop: x-scheme-handler/org-protocol is inconsistent with %F

From: Ulrich Müller <[email-masked]>
Date: Tue, 22 Jul 2025 10:24:46 +0200

>>>>> On Mon, 21 Jul 2025, Ihor Radchenko wrote:

> Ulrich Müller <[email-masked]> writes:
>> A possible solution would be to drop x-scheme-handler/org-protocol
>> from emacsclient.desktop, and split it off into its own desktop file:
>> ...
>> 
>> However, adding yet another desktop file looks like overkill.
>> (And considering Eli's reply in bug #79066 it won't be a viable option.)

> Also see bug#74467.

Sorry for the duplicate bug. Continuing in #74467.

Looking at the last comments:

>> I'm not sure I understand the proposal.  One problem with having the
>> uri handler active at all times is that it subtly changes how local
>> files whose names just happen to start with "http://" (rare, but
>> still legitimate) are handled.

> My proposal is to add the url-file-handler as ur-file-handler by
> default and change url-handler-mode to add the url's to the URI
> handler. That would make so that file URI's a handled always and the
> existing behavior of url-handler-mode is kept.

> Have encountered files starting with a URI prefix such as http?
> I haven't had that so far. I workaround would be to always first check
> if a file with such a prefix exist in the url-file-handler before
> trying to process the URL/URI.

Such heuristic methods tend to be brittle. IMHO it would be much cleaner
if emacsclient continued to interpret its arguments as plain filenames
by default.

Instead, add an option --uri that would interpret them as URIs in a
well-defined manner. This could then be used in the desktop file
together with the %U field code.

Alternatively (or in addition), emacsclient could have a more general
option like --desktop-file that would do the right thing in that
context:
- process arguments as URIs
- when called without arguments, create a new frame (instead of
  signalling an error)

There's also no good reason for that horrible shell wrapper in the
desktop file; it should just do
"Exec=emacsclient [options]... desktop-file %U"
and leave the rest to emacsclient itself.