From 0ff1eb62d053d4e6de33e14bc9d65209ba17c9e3 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 17 Dec 2017 02:28:38 +0100 Subject: Fix `/help` completion When I removed the `/vimput` command in 84ab68f96634cc29eb63a266a30b3147fec835e5, it broke help completion. You were no longer able to get to our help from: /help vi This was because I had removed the command, and Irssi relies on commands in order to set up completion for `/help`. To hack completion into `/help`, use Irssi's subcommand feature to provide a custom `/help vimput` subcommand to `/help`, and have it display our help as before. --- vimput.pl | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/vimput.pl b/vimput.pl index 019ef49..1ab536e 100644 --- a/vimput.pl +++ b/vimput.pl @@ -189,11 +189,12 @@ sub is_ok_message { } -Irssi::command_bind('help', sub { - if ($_[0] !~ /^vimput\s*$/) { - return; - } - +# Since we don't provide a command, we have to do some tricks to print help +# output. /HELP won't list us in its output, but you can still use +# `/help vimput`. While a `command_bind` to 'help' would work, it doesn't give +# us completion for 'vimput'. Here, we hack the subcommand functionality to put +# us in the completion list for `/help`. +Irssi::command_bind('help vimput', sub { my $help = <