aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2017-12-17 02:28:38 +0100
committerTeddy Wing2017-12-17 02:28:38 +0100
commit0ff1eb62d053d4e6de33e14bc9d65209ba17c9e3 (patch)
treee8e6787f5645c2b3a696a42ee6356839df6bbba1
parent5a62f7556529a3a9bb981afb32cdaf072b08cebb (diff)
downloadirssi-vimput-0ff1eb62d053d4e6de33e14bc9d65209ba17c9e3.tar.bz2
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<Tab> 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.
-rw-r--r--vimput.pl21
1 files 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 = <<HELP;
%9Details:%9
@@ -208,6 +209,16 @@ Irssi::command_bind('help', sub {
HELP
Irssi::print($help, MSGLEVEL_CLIENTCRAP);
+});
+
+Irssi::command_bind('help', sub {
+ my ($data, $server, $item) = @_;
+
+ if ($data !~ /^vimput\s*$/) {
+ return;
+ }
+
+ Irssi::command_runsub('help', $data, $server, $item);
Irssi::signal_stop();
});