Changeset 2650a10 for perlwrap.pm


Ignore:
Timestamp:
Apr 29, 2008, 1:21:17 AM (17 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
811ad93
Parents:
52f8dd6
Message:
Support the `style' command again. Note that it is deprecated.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perlwrap.pm

    rb67ab6b r2650a10  
    685685# Internal startup/shutdown routines called by the C code
    686686
     687sub _load_perl_commands {
     688    # Load builtin perl commands
     689    BarnOwl::new_command(style => \&BarnOwl::Style::style_command,
     690                       {
     691                           summary => "creates a new style",
     692                           usage   => "style <name> perl <function_name>",
     693                           description =>
     694                           "A style named <name> will be created that will\n" .
     695                           "format messages using the perl function <function_name>.\n\n" .
     696                           "SEE ALSO: show styles, view -s, filter -s\n\n" .
     697                           "DEPRECATED in favor of BarnOwl::create_style(NAME, OBJECT)",
     698                          });
     699}
     700
    687701sub _load_owlconf {
    688702    # load the config  file
     
    710724
    711725sub _startup {
     726    _load_perl_commands();
    712727    _load_owlconf();
    713728
     
    9911006}
    9921007
     1008sub style_command {
     1009    my $command = shift;
     1010    if(scalar @_ != 3 || $_[1] ne 'perl') {
     1011        die("Usage: style <name> perl <function>\n");
     1012    }
     1013    my $name = shift;
     1014    my $perl = shift;
     1015    my $fn   = shift;
     1016    {
     1017        no strict 'refs';
     1018        unless(*{$fn}{CODE}) {
     1019            die("Unable to create style '$name': no perl function '$fn'\n");
     1020        }
     1021    }
     1022    BarnOwl::create_style($name, BarnOwl::Style::Legacy->new($fn));
     1023}
     1024
    9931025package BarnOwl::Style::Legacy;
    9941026
     
    10041036}
    10051037
    1006 sub description {shift->{description}};
     1038sub description {
     1039    my $self = shift;
     1040    return $self->{description} ||
     1041    ("User-defined perl style that calls " . $self->{function});
     1042};
    10071043
    10081044sub format_message {
Note: See TracChangeset for help on using the changeset viewer.