Mercurial > org-tools
annotate auto-weave.pl @ 15:6ef9ccf7a17e
fixed critical english bug
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 26 Oct 2011 05:13:16 -0700 |
parents | be73e58d4b24 |
children | f433fae15c50 |
rev | line source |
---|---|
rlm@6 | 1 #!/usr/bin/perl |
rlm@6 | 2 |
rlm@6 | 3 use Linux::Inotify2; |
rlm@11 | 4 use WWW::Mechanize::Firefox; |
rlm@11 | 5 my $mech = WWW::Mechanize::Firefox->new(); |
rlm@6 | 6 |
rlm@6 | 7 my $inotify = new Linux::Inotify2 |
rlm@6 | 8 or die "unable to create new inotify object: $!"; |
rlm@6 | 9 |
rlm@6 | 10 @org_files = glob("./org/*.org"); |
rlm@6 | 11 |
rlm@6 | 12 $" = "\n"; |
rlm@8 | 13 print "@org_files\n"; |
rlm@6 | 14 |
rlm@9 | 15 $ignore_next = 0; |
rlm@9 | 16 |
rlm@6 | 17 |
rlm@6 | 18 foreach(@org_files){ |
rlm@6 | 19 # add watchers |
rlm@6 | 20 $inotify->watch ($_, IN_MODIFY, sub |
rlm@6 | 21 { |
rlm@9 | 22 print ("IGNORE : $ignore_next\n"); |
rlm@15 | 23 # ok, for some reason this gets called exactly |
rlm@9 | 24 # twice every time the file is saved from emacs. |
rlm@9 | 25 # so ignore every other invocation. |
rlm@9 | 26 if ($ignore_next) { |
rlm@9 | 27 $ignore_next = 0; |
rlm@9 | 28 return; |
rlm@9 | 29 } |
rlm@13 | 30 $ignore_next = 1; |
rlm@9 | 31 |
rlm@9 | 32 my $e = shift; |
rlm@9 | 33 my $name = $e->fullname; |
rlm@9 | 34 print "$name was modified\n" if $e->IN_MODIFY; |
rlm@9 | 35 $output = `weave $name`; |
rlm@9 | 36 $path = `readlink -f $name`; |
rlm@9 | 37 $path =~ s|/home/r/proj|http://aurellem.localhost|; |
rlm@9 | 38 $path =~ s|org|html|g; |
rlm@11 | 39 $mech->get($path); |
rlm@6 | 40 }); |
rlm@6 | 41 } |
rlm@6 | 42 |
rlm@6 | 43 |
rlm@13 | 44 # manual event loop |
rlm@6 | 45 1 while $inotify->poll; |