Changeset eb6cedc for perl/lib/BarnOwl


Ignore:
Timestamp:
Jul 17, 2009, 11:52:30 PM (15 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
96f7b07
Parents:
b4ef908
git-author:
Nelson Elhage <nelhage@mit.edu> (07/17/09 23:31:14)
git-committer:
Nelson Elhage <nelhage@mit.edu> (07/17/09 23:52:30)
Message:
Push commands into BarnOwl:: instead of AUTOLOAD'ing them
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/lib/BarnOwl/Hooks.pm

    ree183be reb6cedc  
    33
    44package BarnOwl::Hooks;
     5
     6use Carp;
    57
    68=head1 BarnOwl::Hooks
     
    180182}
    181183
     184sub _new_command {
     185    my $command = shift;
     186    (my $symbol = $command) =~ s/-/_/g;
     187    my $package = "BarnOwl";
     188
     189    if($symbol =~ m{^edit:(.+)$}) {
     190        $symbol = $1;
     191        $package = "BarnOwl::Editwin";
     192    } else {
     193        $symbol =~ s/:/_/;
     194    }
     195    {
     196        no strict 'refs';
     197        if(defined(*{"${package}::${symbol}"}{CODE})) {
     198            return;
     199        }
     200        *{"${package}::${symbol}"} = sub {
     201            if(@_ == 1 && $_[0] =~ m{\s}) {
     202                carp "DEPRECATED: ${package}::${symbol}: Tokenizing argument on ' '.\n"
     203                . "In future versions, the argument list will be passed to\n"
     204                . "'$command' directly. Tokenize yourself, or use BarnOwl::command()\n"
     205            }
     206            BarnOwl::command($command . " " . join(" ", @_))
     207          };
     208    }
     209}
    182210
    1832111;
Note: See TracChangeset for help on using the changeset viewer.