diff auto-weave.pl @ 9:d09937a6cb4b

trying to build something to automatically refresh the browser.
author Robert McIntyre <rlm@mit.edu>
date Tue, 25 Oct 2011 05:33:36 -0700
parents 73beed20f7de
children 24ff8a9c76c4
line wrap: on
line diff
     1.1 --- a/auto-weave.pl	Tue Oct 25 01:08:31 2011 -0700
     1.2 +++ b/auto-weave.pl	Tue Oct 25 05:33:36 2011 -0700
     1.3 @@ -13,22 +13,34 @@
     1.4  $" = "\n";
     1.5  print "@org_files\n";
     1.6  
     1.7 +$ignore_next = 0;
     1.8 +
     1.9  
    1.10  foreach(@org_files){
    1.11  # add watchers
    1.12  $inotify->watch ($_, IN_MODIFY, sub 
    1.13  {
    1.14 -  my $e = shift;
    1.15 -  my $name = $e->fullname;
    1.16 -  print "$name was modified\n" if $e->IN_MODIFY;
    1.17 -  system ("weave $name");
    1.18 -  print ("$name\n");
    1.19 -  $path = `readlink -f $name`;
    1.20 -  $path =~ s|/home/r/proj|http://aurellem.localhost|;
    1.21 -  print ("$path\n");
    1.22 -  $path =~ s|org|html|g;
    1.23 -  print ("$path\n");
    1.24 -  system ("firefox $path");
    1.25 +    print ("IGNORE : $ignore_next\n");
    1.26 +    # ok, for some reason this get's called exactly 
    1.27 +    # twice every time the file is saved from emacs.
    1.28 +    # so ignore every other invocation.
    1.29 +    if ($ignore_next) {
    1.30 +	$ignore_next = 0;
    1.31 +	return;
    1.32 +    }
    1.33 +
    1.34 +    my $e = shift;
    1.35 +    my $name = $e->fullname;
    1.36 +    print "$name was modified\n" if $e->IN_MODIFY;
    1.37 +    $output = `weave $name`;
    1.38 +    print ("$name\n");
    1.39 +    $path = `readlink -f $name`;
    1.40 +    $path =~ s|/home/r/proj|http://aurellem.localhost|;
    1.41 +    print ("$path\n");
    1.42 +    $path =~ s|org|html|g;
    1.43 +    print ("$path\n");
    1.44 +    #system ("firefox $path");
    1.45 +    $ignore_next = 1;
    1.46  
    1.47  });
    1.48  }