- Timestamp:
- Jul 17, 2009, 11:52:30 PM (14 years ago)
- 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)
- Location:
- perl/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/lib/BarnOwl.pm
r22b54a7 reb6cedc 167 167 $m->legacy_populate_global(); 168 168 return &BarnOwl::Hooks::_receive_msg($m); 169 }170 171 =head2 AUTOLOAD172 173 BarnOwl.pm has a C<AUTOLOAD> method that translates unused names in174 the BarnOwl:: namespace to a call to BarnOwl::command() with that175 command. Underscores are also translated to C<->s, so you can do176 e.g. C<BarnOwl::start_command()> and it will be translated into177 C<start-command>.178 179 So, if you're looking for functionality that you can't find in the180 perl interface, check C<:show commands> or C<commands.c> in the181 BarnOwl source tree -- there's a good chance it exists as a BarnOwl182 command.183 184 =head3 BUGS185 186 There are horrible quoting issues here. The AUTOLOAD simple joins your187 commands with spaces and passes them unmodified to C<::command>188 189 =cut190 191 # make BarnOwl::<command>("foo") be aliases to BarnOwl::command("<command> foo");192 sub AUTOLOAD {193 our $AUTOLOAD;194 my $called = $AUTOLOAD;195 $called =~ s/.*:://;196 $called =~ s/_/-/g;197 return &BarnOwl::command("$called ".join(" ",@_));198 169 } 199 170 -
perl/lib/BarnOwl/Hooks.pm
ree183be reb6cedc 3 3 4 4 package BarnOwl::Hooks; 5 6 use Carp; 5 7 6 8 =head1 BarnOwl::Hooks … … 180 182 } 181 183 184 sub _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 } 182 210 183 211 1;
Note: See TracChangeset
for help on using the changeset viewer.