Changeset 836e6263


Ignore:
Timestamp:
Mar 23, 2007, 3:09:45 PM (18 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:
9729dba
Parents:
b547aa4
git-author:
Nelson Elhage <nelhage@mit.edu> (03/23/07 15:09:38)
git-committer:
Nelson Elhage <nelhage@mit.edu> (03/23/07 15:09:45)
Message:
Implement loading of unpacked modules, and module reloading.
Files:
2 edited

Legend:

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

    r2622450 r836e6263  
    1515                  $ENV{HOME} . "/.owl/modules" ) {
    1616        opendir(my $dh, $dir) or next;
     17        while(defined(my $f = readdir($dh))) {
     18            next if $f =~ /^\./;
     19            if(-f "$dir/$f" && $f =~ /^(.+)\.par$/) {
     20                $modules{$1} = 1;
     21            } elsif(-d "$dir/$f" && -d "$dir/$f/lib") {
     22                push @INC, "$dir/$f/lib" unless grep m{^$dir/$f/lib$}, @INC;
     23                $modules{$f} = 1;
     24            }
     25        }
    1726        @modules = grep /\.par$/, readdir($dh);
    1827        closedir($dh);
     
    3039}
    3140
     41sub reload {
     42    my $class = shift;
     43    for my $m (keys %INC) {
     44        delete $INC{$m} if $m =~ m{^BarnOwl/};
     45    }
     46    # Restore core modules from perlwrap.pm
     47    $INC{$_} = 1 for (qw(BarnOwl.pm BarnOwl/Hooks.pm
     48                         BarnOwl/Message.pm BarnOwl/Style.pm));
     49
     50    $BarnOwl::Hooks::startup->clear;
     51    local $SIG{__WARN__} = \&squelch_redefine;
     52    $class->load_all;
     53    $BarnOwl::Hooks::startup->run(1);
     54    BarnOwl::startup() if *BarnOwl::startup{CODE};
     55}
     56
     57sub squelch_redefine {
     58    my $warning = shift;
     59    warn $warning unless $warning =~ /redefined/;
     60}
     61
    32621;
  • perlwrap.pm

    r0337203 r836e6263  
    425425    }
    426426   
    427     $startup->run;
     427    $startup->run(0);
    428428    BarnOwl::startup() if *BarnOwl::startup{CODE};
    429429}
Note: See TracChangeset for help on using the changeset viewer.