fish_command_not_found: remove legacy event handler

We no longer emit the "fish_command_not_found" event ourselves,
so the event handlers are only useful to users who
1. run "emit fish_command_not_found"
2. copy the definition of "fish_command_not_found" to their config and run
   that with fish < 3.2.

Probably no one does 1; there are no matches in
https://github.com/search?utf8=%E2%9C%93&q=%22emit+fish_command_not_found%22+language%3Afish&type=code

Reason 2 is less relevant after 5 years.

For additional evidence, none of our specializations
("/usr/libexec/pk-command-not-found" etc.)  react to the event,
and no one has ever complained.

Stop registering any fish_command_not_found as event handler,
for consistency and simplicity.

While at it, remove the documentation on how to make it work for
version < 3.2.
This commit is contained in:
Johannes Altmanninger
2026-05-07 16:39:39 +08:00
parent e25ebf1067
commit 6e036740de
3 changed files with 2 additions and 24 deletions

View File

@@ -50,25 +50,3 @@ Or the simple default handler::
function fish_command_not_found
__fish_default_command_not_found_handler $argv
end
Backwards compatibility
-----------------------
This command was introduced in fish 3.2.0. Previous versions of fish used the "fish_command_not_found" :ref:`event <event>` instead.
To define a handler that works in older versions of fish as well, define it the old way::
function __fish_command_not_found_handler --on-event fish_command_not_found
echo COMMAND WAS NOT FOUND MY FRIEND $argv[1]
end
in which case fish will define a ``fish_command_not_found`` that calls it,
or define a wrapper::
function fish_command_not_found
echo "G'day mate, could not find your command: $argv"
end
function __fish_command_not_found_handler --on-event fish_command_not_found
fish_command_not_found $argv
end

View File

@@ -14,7 +14,7 @@ end
if not status is-interactive
# Hook up the default as the command_not_found handler
# if we are not interactive to avoid custom handlers.
function fish_command_not_found --on-event fish_command_not_found
function fish_command_not_found
__fish_default_command_not_found_handler $argv
end
end

View File

@@ -71,7 +71,7 @@ else if type -q pkgfile
# end
else
# Use standard fish command not found handler otherwise
function fish_command_not_found --on-event fish_command_not_found
function fish_command_not_found
__fish_default_command_not_found_handler $argv
end
end