[2652] in BarnOwl Developers
Re: [PATCH] add a random zsig function
daemon@ATHENA.MIT.EDU (Kevin Riggle)
Sun Sep 19 03:06:26 2010
From: Kevin Riggle <kevinr@free-dissociation.com>
To: barnowl-dev <barnowl-dev@mit.edu>
In-reply-to: <1284878591-28056-1-git-send-email-kevinr@free-dissociation.com>
Date: Sun, 19 Sep 2010 03:06:20 -0400
Argh, sent a slightly wrong patch. Updated patch follows.
- Kevin
Excerpts from Kevin Riggle's message of Sun Sep 19 02:43:11 -0400 2010:
> ---
> perl/lib/BarnOwl.pm | 20 ++++++++++++++++++++
> variable.c | 3 ++-
> 2 files changed, 22 insertions(+), 1 deletions(-)
>
> diff --git a/perl/lib/BarnOwl.pm b/perl/lib/BarnOwl.pm
> index b097cdd..db4f665 100644
> --- a/perl/lib/BarnOwl.pm
> +++ b/perl/lib/BarnOwl.pm
> @@ -560,6 +560,26 @@ sub default_zephyr_signature
> return $zsig;
> }
>
> +=head3 random_zephyr_signature
> +
> +Retrieve a random line from ~/.zsigs (except those beginning with '#')
> +and use it as the zephyr signature.
> +
> +=cut
> +
> +sub random_zephyr_signature
> +{
> + my $zsigfile = "$ENV{'HOME'}/.zsigs";
> + open FILE, $zsigfile or die "No zsigfile $zsigfile";
> + while (<FILE>) {
> + push @lines, $_ unless /^#/ || /^\s*$/;
> + }
> + close FILE;
> + my $zsig = $lines[int(rand(scalar @lines))];
> + chomp $zsig;
> + return $zsig;
> +}
> +
> # Stub for owl::startup / BarnOwl::startup, so it isn't bound to the
> # startup command. This may be redefined in a user's configfile.
> sub startup
> diff --git a/variable.c b/variable.c
> index 1175ede..6bea7e8 100644
> --- a/variable.c
> +++ b/variable.c
> @@ -212,7 +212,8 @@ static owl_variable variables_to_init[] = {
> "zsig perl function",
> "Called every time you start a zephyrgram without an\n"
> "explicit zsig. The default setting implements the policy\n"
> - "described in the documentation for the 'zsig' variable.\n"),
> + "described in the documentation for the 'zsig' variable.\n"
> + "See also BarnOwl::random_zephyr_signature().\n"),
>
> OWLVAR_STRING( "zsig" /* %OwlVarStub */, "",
> "zephyr signature",