From 6e036740de70b0dbc344777751a380de7bf74969 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Thu, 7 May 2026 16:39:39 +0800 Subject: [PATCH] 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. --- doc_src/cmds/fish_command_not_found.rst | 22 --------------------- share/config.fish | 2 +- share/functions/fish_command_not_found.fish | 2 +- 3 files changed, 2 insertions(+), 24 deletions(-) diff --git a/doc_src/cmds/fish_command_not_found.rst b/doc_src/cmds/fish_command_not_found.rst index 48a215a8a..9d547be79 100644 --- a/doc_src/cmds/fish_command_not_found.rst +++ b/doc_src/cmds/fish_command_not_found.rst @@ -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 ` 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 diff --git a/share/config.fish b/share/config.fish index 1d3a91c21..de40ef4c5 100644 --- a/share/config.fish +++ b/share/config.fish @@ -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 diff --git a/share/functions/fish_command_not_found.fish b/share/functions/fish_command_not_found.fish index e5943f62e..a033fe170 100644 --- a/share/functions/fish_command_not_found.fish +++ b/share/functions/fish_command_not_found.fish @@ -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