From 5bb0f2351ac398b8df5ebc81093539e2f593e30c Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Thu, 22 Jul 2010 15:45:54 +0100 Subject: added messagelevel docs to irssi.pod, more stuff in guide, and a little script to dump .xs func definitions --- docs/Guide.pod | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 4 deletions(-) (limited to 'docs/Guide.pod') diff --git a/docs/Guide.pod b/docs/Guide.pod index b540e75..a5a20f2 100644 --- a/docs/Guide.pod +++ b/docs/Guide.pod @@ -21,7 +21,15 @@ better, create a symlink to it) into F<~/.irssi/scripts/autorun/>. =head2 Testing -B +=for comment B + +=head3 C + +B + +B + +B =head2 Loading @@ -142,7 +150,33 @@ B =head3 Using Functions -B +Because scripts exist in a well-defined namespace of C, +it is possible to manipulate the perl symbol table to call functions directly on them, +assuming they are loaded. + +Because the following code depends on I, it is necessary to +tell Perl to allow them, despite normally being prohibited by C. +The C line takes care of this, and reenables them at the end +of the snippet. + + no strict 'refs'; + if (defined %{ 'Irssi::Script::SOMEPACKAGE::' }) { + if (defined &{'Irssi::Script::SOMEPACKAGE::SOME_FUNC'} ) { + (&{'Irssi::Script::SOMEPAKAGE::SOME_FUNC'}(@args)); + } else { + print("Err: can't find Irssi::Script::SOMEPACKAGE::SOME_FUNC"); + } + } + use strict 'refs'; + +Here, C is the name of the script package which contains the +function you want to call, and C is the name of the function within +it you wish to call. The first 2 C lines take care of ensuring +that the package and function exist, and generate an error otherwise. Other +error handling is possible, including executing a C to load the +necessary script and retry, but is not shown here. + +I on Freenode/#irssi.> =head2 If In Doubt, Dump! @@ -170,8 +204,20 @@ of their file. Whilst better than no documentation at all, a preferable approac is to allow that help to be accessed from within Irssi itself, using the C command. -B + our $help = "this is help for b"; + + Irssi::command_bind('help', sub { + if ($_[0] eq 'test_b') { + Irssi::print($help, MSGLEVEL_CLIENTCRAP); + Irssi::signal_stop; + return; + } + } + ); + +This example demonstrates overriding the C command, and if the argument +matches our command, print some custom help and prevent the internal Irssi help +function from being called. Otherwise, it falls back to the default help. =head3 Use Tab Completion @@ -227,6 +273,17 @@ The following example demonstrates how to use subcommands from within a script: print "subcommand called with: $args"; } +=head1 AUTHOR & THANKS + +This page was written by Tom Feist C, but draws +on the help of many many people. + +The denizens of Freenode/#irssi have been particularly helpful, especially +C and C. + +To report bugs or suggestions, email me at the address before, or come talk to +me in C<#irssi> on C. + =head1 OTHER RESOURCES The documentation assembled here and elsewhere on this site has been drawn from -- cgit v1.2.3