Mercurial > org-tools
annotate auto-weave.pl @ 18:993b8d7d9bec
buggy garbage
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 02 Nov 2011 09:24:54 -0700 |
parents | 6da973a6b93d |
children | c14f3a4af7fd |
rev | line source |
---|---|
rlm@6 | 1 #!/usr/bin/perl |
rlm@6 | 2 |
rlm@6 | 3 use Linux::Inotify2; |
rlm@6 | 4 |
rlm@6 | 5 my $inotify = new Linux::Inotify2 |
rlm@6 | 6 or die "unable to create new inotify object: $!"; |
rlm@6 | 7 |
rlm@16 | 8 $org_files = `find /home/r/proj -name "*.org" -print0`; |
rlm@16 | 9 @org_files = split /\0/, $org_files; |
rlm@6 | 10 |
rlm@16 | 11 for $file(@org_files){print "$file\n";} |
rlm@9 | 12 $ignore_next = 0; |
rlm@18 | 13 |
rlm@6 | 14 |
rlm@6 | 15 foreach(@org_files){ |
rlm@6 | 16 # add watchers |
rlm@6 | 17 $inotify->watch ($_, IN_MODIFY, sub |
rlm@6 | 18 { |
rlm@9 | 19 print ("IGNORE : $ignore_next\n"); |
rlm@15 | 20 # ok, for some reason this gets called exactly |
rlm@9 | 21 # twice every time the file is saved from emacs. |
rlm@9 | 22 # so ignore every other invocation. |
rlm@9 | 23 if ($ignore_next) { |
rlm@18 | 24 $ignore_next = 0; |
rlm@18 | 25 return; |
rlm@9 | 26 } |
rlm@13 | 27 $ignore_next = 1; |
rlm@9 | 28 |
rlm@9 | 29 my $e = shift; |
rlm@9 | 30 my $name = $e->fullname; |
rlm@9 | 31 print "$name was modified\n" if $e->IN_MODIFY; |
rlm@18 | 32 system "weave $name &"; |
rlm@18 | 33 |
rlm@6 | 34 }); |
rlm@6 | 35 } |
rlm@6 | 36 |
rlm@13 | 37 # manual event loop |
rlm@6 | 38 1 while $inotify->poll; |